Skip to content

Linking error with static feature #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
benjamin-lieser opened this issue Nov 13, 2024 · 0 comments
Open

Linking error with static feature #13

benjamin-lieser opened this issue Nov 13, 2024 · 0 comments

Comments

@benjamin-lieser
Copy link

benjamin-lieser commented Nov 13, 2024

When trying to compile a Rust project depending on netlib-src with the static feature I get the following error:

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/mpg08/blieser/.rustup/toolchains/nightly-2024-10-30-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/mpg08/blieser/.rustup/toolchains/nightly-2024-10-30-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/opt/sw/rev/23.12/linux-scientific7-haswell/gcc-11.4.0/cmake-3.27.7-qcx6sx/bin:/opt/sw/rev/23.12/linux-scientific7-haswell/gcc-4.8.5/gcc-11.4.0-jgoe5h/bin:/home/mpg08/blieser/miniforge3/envs/rna/bin:/home/mpg08/blieser/miniforge3/condabin:/usr/users/blieser/.cargo/bin:/usr/local/slurm/slurm/current/install/bin:/usr/local/slurm/tools:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/users/blieser/miniforge3/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustc8Ks58I/symbols.o" "/home/mpg08/blieser/phylo_grad/target/release/deps/phylo_grad-6141d27cf7c034ac.phylo_grad.12abffe0bc466d06-cgu.10.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/tmp/rustc8Ks58I/libnetlib_src-7397d9ffe106da33.rlib" "/home/mpg08/blieser/.rustup/toolchains/nightly-2024-10-30-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-0e6386368b0a24e8.rlib" "-Wl,-Bdynamic" "-lgfortran" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-B/home/mpg08/blieser/.rustup/toolchains/nightly-2024-10-30-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/mpg08/blieser/phylo_grad/target/release/build/netlib-src-f48f2a5ae082bfbc/out/lib" "-L" "/home/mpg08/blieser/.rustup/toolchains/nightly-2024-10-30-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/mpg08/blieser/phylo_grad/target/release/deps/phylo_grad-6141d27cf7c034ac" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: rust-lld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
          >>> defined in /tmp/rustc8Ks58I/libnetlib_src-7397d9ffe106da33.rlib(dorgtr.f.o)
          >>> referenced by dorgtr.f:166 (/home/mpg08/blieser/.cargo/registry/src/index.crates.io-6f17d22bba15001f/netlib-src-0.8.0/source/SRC/dorgtr.f:166)
          >>>               dorgtr.f.o:(dorgtr_) in archive /tmp/rustc8Ks58I/libnetlib_src-7397d9ffe106da33.rlib

          rust-lld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
          >>> defined in /tmp/rustc8Ks58I/libnetlib_src-7397d9ffe106da33.rlib(dlansy.f.o)
          >>> referenced by dlansy.f:166 (/home/mpg08/blieser/.cargo/registry/src/index.crates.io-6f17d22bba15001f/netlib-src-0.8.0/source/SRC/dlansy.f:166)
          >>>               dlansy.f.o:(dlansy_) in archive /tmp/rustc8Ks58I/libnetlib_src-7397d9ffe106da33.rlib

There are quite a bit more failed relocations.

It works without static. I am not sure what other information might be helpful here. The gcc version is 11.4

Edit:

I compared the files with my local Ubuntu 22.04 machine, where is compiles without problems. It contains the very similar relocations.

Using ld instead of rust-lld gives the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants