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

rustc hides linker warnings #83436

Open
ahl opened this issue Mar 24, 2021 · 0 comments · May be fixed by #119286
Open

rustc hides linker warnings #83436

ahl opened this issue Mar 24, 2021 · 0 comments · May be fixed by #119286
Labels
A-linkage Area: linking into static, shared libraries and binaries C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ahl
Copy link
Contributor

ahl commented Mar 24, 2021

I encountered an issue with the linkme crate on illumos (OpenSolaris/OmniOS/Helios) demonstrated with this repo. Of note, the build executes without error or warning, but in fact the linker is emitting an error:

$ cargo run
   Compiling cmd v0.1.0 (/home/ahl/linkme-test/cmd)
    Finished dev [unoptimized + debuginfo] target(s) in 0.28s
     Running `target/debug/cmd`
$ cargo rustc
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s

I can make the linker fail on warnings:

$ cargo rustc -- -C link-arg=-Wl,-zfatal-warnings
   Compiling cmd v0.1.0 (/home/ahl/linkme-test/cmd)
error: linking with `gcc` failed: exit code: 1
  |
  = note: "gcc" "-m64" "-std=c99" "-L" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.1m65hci6o5zni2mr.rcgu.o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.1r2sofzghiioxykg.rcgu.o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.2i3xjlynwxgqlmzu.rcgu.o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.3hvsf4zj59kihrhf.rcgu.o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.3lsh1pzemq0xblzm.rcgu.o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.3zpatajw7m7uqqns.rcgu.o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.4yxic0y84aboqmeb.rcgu.o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.a1lfmxsp6lqzsbn.rcgu.o" "-o" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69" "/home/ahl/linkme-test/cmd/target/debug/deps/cmd-26e8351dc3f3fb69.3n70o9wfzqm9tbsh.rcgu.o" "-Wl,-zignore" "-nodefaultlibs" "-L" "/home/ahl/linkme-test/cmd/target/debug/deps" "-L" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib" "-Wl,-Bstatic" "/home/ahl/linkme-test/cmd/target/debug/deps/liblib-3d689bd64c3873d5.rlib" "/home/ahl/linkme-test/cmd/target/debug/deps/liblinkme-21c998585e123796.rlib" "-Wl,--start-group" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libstd-cd23cc7e75a2851c.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libpanic_unwind-566bad254d0594e5.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libminiz_oxide-96e54319d1590148.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libadler-4dbe2335326bb316.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libobject-b0fd875741b20fc0.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libaddr2line-089ce7b4c263282a.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libgimli-ca92a564b7883a12.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/librustc_demangle-ce8ee413f3ea18b6.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libhashbrown-17e15682bef35ec2.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/librustc_std_workspace_alloc-2dc950a425ee77d8.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libunwind-50867a64287c1bd2.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libcfg_if-129bada4e936c5a0.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/liblibc-a98e4fa0f203a39a.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/liballoc-35c480f88f8f320a.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/librustc_std_workspace_core-86dc76527c7e216a.rlib" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libcore-093275d7382c1a2f.rlib" "-Wl,--end-group" "/opt/ooce/rust/lib/rustlib/x86_64-unknown-illumos/lib/libcompiler_builtins-358913705748e96c.rlib" "-Wl,-Bdynamic" "-lsocket" "-lposix4" "-lpthread" "-lresolv" "-lnsl" "-lumem" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-Wl,-zfatal-warnings" "-lssp"
  = note: ld: warning: reserved symbol '__start_set_linkme_DOERS' already defined in file /home/ahl/linkme-test/cmd/target/debug/deps/liblib-3d689bd64c3873d5.rlib(lib-3d689bd64c3873d5.2vwi8dtk7ky9hvmq.rcgu.o)
          ld: warning: reserved symbol '__stop_set_linkme_DOERS' already defined in file /home/ahl/linkme-test/cmd/target/debug/deps/liblib-3d689bd64c3873d5.rlib(lib-3d689bd64c3873d5.2vwi8dtk7ky9hvmq.rcgu.o)
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: could not compile `cmd`.

To learn more, run the command again with --verbose.

These linker warnings need not have been fatal, but I think it would be reasonable for cargo build / cargo run / cargo rustc to display these warnings. In this case those warnings would have helped determine the underlying issues much earlier. Indeed, it seems rare that linker warnings would truly be specious.

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.47.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-illumos
release: 1.47.0
LLVM version: 11.0
@ahl ahl added the C-bug Category: This is a bug. label Mar 24, 2021
@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Mar 24, 2021
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 26, 2024
show linker output even if the linker succeeds

- show stderr by default
- show stdout if `--verbose` is passed
- remove both from RUSTC_LOG
- hide the linker cli args unless `--verbose` is passed

fixes rust-lang#83436. fixes rust-lang#38206. fixes rust-lang#109979. helps with rust-lang#46998. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134

this is based on rust-lang#119129 for convenience so i didn't have to duplicate the changes around saving `--verbose` in rust-lang@cb6d033#diff-7a49efa20548d6806dbe1c66dd4dc445fda18fcbbf1709520cadecc4841aae12

r? `@bjorn3`
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 30, 2024
show linker output even if the linker succeeds

- show stderr by default
- show stdout if `--verbose` is passed
- remove both from RUSTC_LOG
- hide the linker cli args unless `--verbose` is passed

fixes rust-lang#83436. fixes rust-lang#38206. fixes rust-lang#109979. helps with rust-lang#46998. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134

this is based on rust-lang#119129 for convenience so i didn't have to duplicate the changes around saving `--verbose` in rust-lang@cb6d033#diff-7a49efa20548d6806dbe1c66dd4dc445fda18fcbbf1709520cadecc4841aae12

r? `@bjorn3`
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 11, 2024
show linker output even if the linker succeeds

- show stderr by default
- show stdout if `--verbose` is passed
- remove both from RUSTC_LOG
- hide the linker cli args unless `--verbose` is passed

fixes rust-lang#83436. fixes rust-lang#38206. fixes rust-lang#109979. helps with rust-lang#46998. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134

this is based on rust-lang#119129 for convenience so i didn't have to duplicate the changes around saving `--verbose` in rust-lang@cb6d033#diff-7a49efa20548d6806dbe1c66dd4dc445fda18fcbbf1709520cadecc4841aae12

r? `@bjorn3`
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 11, 2024
show linker output even if the linker succeeds

- show stderr by default
- show stdout if `--verbose` is passed
- remove both from RUSTC_LOG
- hide the linker cli args unless `--verbose` is passed

fixes rust-lang#83436. fixes rust-lang#38206. fixes rust-lang#109979. helps with rust-lang#46998. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134

this is based on rust-lang#119129 for convenience so i didn't have to duplicate the changes around saving `--verbose` in rust-lang@cb6d033#diff-7a49efa20548d6806dbe1c66dd4dc445fda18fcbbf1709520cadecc4841aae12

r? `@bjorn3`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants