Skip to content

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

@the8472

Description

@the8472
Member

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

Activity

added
A-inline-assemblyArea: Inline assembly (`asm!(…)`)
A-testsuiteArea: The testsuite used to check the correctness of rustc
C-bugCategory: This is a bug.
F-asm`#![feature(asm)]` (not `llvm_asm`)
on Apr 9, 2021
Amanieu

Amanieu commented on Apr 12, 2021

@Amanieu
Member

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

added a commit that references this issue on Apr 29, 2021
eeaefc3
added a commit that references this issue on Apr 30, 2021
eadcbb5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)A-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.F-asm`#![feature(asm)]` (not `llvm_asm`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Amanieu@the8472@jonas-schievink

      Issue actions

        UI test `asm/sym.rs` fails with a linker error when executed with 1 CGU · Issue #84025 · rust-lang/rust