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

UI test asm/sym.rs fails with a linker error when executed with 1 CGU #84025

Closed
the8472 opened this issue Apr 9, 2021 · 1 comment
Closed
Labels
A-inline-assembly Area: inline asm!(..) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`)

Comments

@the8472
Copy link
Member

the8472 commented Apr 9, 2021

This was discovered in #81942 which lowers the UI test default CGU count to 1. The test was modified to explicitly request a higher CGU count to make it pass, but the underlying issue remains.

Steps to reproduce:

  1. add the compile flag -Ccodegen-units=1 to src/test/ui/asm/sym.rs
  2. run UI test

output

---- [ui] ui/asm/sym.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit code: 1
command: "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/home/the8472/workspace/rust/src/test/ui/asm/sym.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Clink-args=-fuse-ld=lld" "-Clink-arg=-Wl,--threads=1" "-C" "codegen-units=1" "-L" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/auxiliary"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
error: linking with `cc` failed: exit code: 1
   |
   = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/a.sym.7rcbfp3g-cgu.0.rcgu.o" "-o" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/a" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/auxiliary" "-L" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-L" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-43e6546d3a194262" "-Wl,--end-group" "-Wl,-Bstatic" "/home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-cde4ccb55295e33e.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,-rpath,$ORIGIN/../../../../stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-rpath,/home/the8472/workspace/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--enable-new-dtags" "-fuse-ld=lld" "-Wl,--threads=1"
   = note: ld.lld: error: can't create dynamic relocation R_X86_64_TPOFF32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
           >>> defined in /home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/a.sym.7rcbfp3g-cgu.0.rcgu.o
           >>> referenced by sym.7rcbfp3g-cgu.0
           >>>               /home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/a.sym.7rcbfp3g-cgu.0.rcgu.o:(std::sys_common::backtrace::__rust_begin_short_backtrace::h6af211e3164ab612)
           
           ld.lld: error: can't create dynamic relocation R_X86_64_TPOFF32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
           >>> defined in /home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/a.sym.7rcbfp3g-cgu.0.rcgu.o
           >>> referenced by sym.7rcbfp3g-cgu.0
           >>>               /home/the8472/workspace/rust/build/x86_64-unknown-linux-gnu/test/ui/asm/sym/a.sym.7rcbfp3g-cgu.0.rcgu.o:(sym::main::h2d3f4ca36c63deb0)
           collect2: error: ld returned 1 exit status
           

error: aborting due to previous error


------------------------------------------



failures:
    [ui] ui/asm/sym.rs
@jonas-schievink jonas-schievink added A-inline-assembly Area: inline asm!(..) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) labels Apr 9, 2021
@Amanieu
Copy link
Member

Amanieu commented Apr 12, 2021

This is due to an LLVM bug: https://bugs.llvm.org/show_bug.cgi?id=49932

Incidentally it probably wasn't triggering with multiple codegen units because the constmerge pass isn't executed on ThinLTO: https://bugs.llvm.org/show_bug.cgi?id=33630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: inline asm!(..) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants