Skip to content
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

Fix link error on Arch Linux #2510

Closed
wants to merge 1 commit into from
Closed

Conversation

crabtw
Copy link
Contributor

@crabtw crabtw commented Jun 6, 2012

There is a link error during make check.
I add the "-lm" flag to fix the problem.

cfg: shell host triple x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: unix-y environment
cfg: using gcc
cfg: no pandoc found, omitting doc/rust.pdf
cfg: no llnextgen found, omitting grammar-verification
cfg: no pandoc found, omitting library doc build
cfg: including dist rules
cfg: including test rules
check: formatting
compile_and_link: x86_64-unknown-linux-gnu/test/rustctest.stage2-x86_64-unknown-linux-gnu
error: linking with cc failed with code 1
note: cc arguments: -L/home/jyyou/src/rust-git/b/x86_64-unknown-linux-gnu/stage2/lib/rustc/x86_64-unknown-linux-gnu/lib -m64 -o x86_64-unknown-linux-gnu/test/rustctest.stage2-x86_64-unknown-linux-gnu x86_64-unknown-linux-gnu/test/rustctest.o -L/home/jyyou/src/rust-git/b/x86_64-unknown-linux-gnu/stage2/lib/rustc/x86_64-unknown-linux-gnu/lib -lcore-d27e4777a53c3e50-0.2 -L/home/jyyou/src/rust-git/b/x86_64-unknown-linux-gnu/stage2/lib/rustc/x86_64-unknown-linux-gnu/lib -lstd-d399da1ab6f5bec0-0.2 -L/home/jyyou/src/rust-git/b/x86_64-unknown-linux-gnu/stage2/lib/rustc/x86_64-unknown-linux-gnu/lib -lsyntax-b45cc7d0b085bc34-0.2 -Lrustllvm -lrustllvm -lrustrt -lrt -ldl -lmorestack -Wl,-rpath,$ORIGIN/../stage2/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,/home/jyyou/src/rust-git/b/x86_64-unknown-linux-gnu/stage2/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib
note: /usr/bin/ld: x86_64-unknown-linux-gnu/test/rustctest.o: undefined reference to symbol 'fmod@@GLIBC_2.2.5'
/usr/bin/ld: note: 'fmod@@GLIBC_2.2.5' is defined in DSO /lib/libm.so.6 so try adding it to the linker command line
/lib/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

error: aborting due to 1 previous errors
make: *** [x86_64-unknown-linux-gnu/test/rustctest.stage2-x86_64-unknown-linux-gnu] Error 101

@brson
Copy link
Contributor

brson commented Jun 6, 2012

For a long while rustc was adding '-lm' to the linker flags and nobody knew why so we removed it. I am very curious about why this is happening and why it happens specifically when building a rustc test runner.

I suspect that linking libm to every crate is ultimately not the right thing to do, since rust code doesn't have any inherent dependency on it nor does the runtime link to it.

If we can't figure out what the real issue is then maybe we have to do this, but this time with comments explaining why.

@crabtw
Copy link
Contributor Author

crabtw commented Jun 6, 2012

After some experiments, I find that LLVM generates instructions to call "fmod" function for the "frem" instruction, and the "%" operator is implemeted in "frem".

If I write "a % b" and type is float, it fails to find the "fmod" function.
ld seems not to link libm automatically.

@brson
Copy link
Contributor

brson commented Jun 6, 2012

OK, this looks unavoidable to me without defining out own fmod (compiler-rt doesn't appear to contain it)

@brson
Copy link
Contributor

brson commented Jun 6, 2012

Merged. Thanks!

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

Successfully merging this pull request may close these issues.

2 participants