[PATCH] D120626: [ELF] Move section assignment from initializeSymbols to postParse
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 17:23:00 PDT 2022
MaskRay added a comment.
In D120626#3384404 <https://reviews.llvm.org/D120626#3384404>, @haowei wrote:
>> In D120626#3383810 <https://reviews.llvm.org/D120626#3383810>, @haowei wrote:
>>
>>> We are seeing build failures in cmake config step for the clang runtime builds after this patch. Example of error messages:
>>
>> Thanks for the report, but with `Host compiler does not support '-fuse-ld=lld'` it might be difficult to know for sure whether the culprit was in an lld change or a brittle configure.
>> Providing CMakeError.log or CMakeOutput.log with the linker diagnostic could make me more sure that it was related to this lld change.
>> Anycase, I think the issue was exactly the one for i386 sanitizers and it should have been fixed by the aforementioned commit.
>
> I looked up my local CMakeError.log file for this patch and it contains:
>
> [2/2] Linking C executable cmTC_5b689
> FAILED: cmTC_5b689
> : && /mnt/nvme_sec/SRC/llvm-project/build-repro/./bin/clang --target=i386-unknown-linux-gnu --sysroot=/usr/local/google/home/haowei/SRC/fuchsia-sysroot --target=i386-unknown-linux-gnu -fuse-ld=lld -v CMakeFiles/cmTC_5b689.dir/CMakeCCompilerABI.c.o -o cmTC_5b689 && :
> Fuchsia clang version 15.0.0 (git at github.com:llvm/llvm-project.git c30e6447c0225f675773d07f2b6d4e3c2b962155)
> Target: i386-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /mnt/nvme_sec/SRC/llvm-project/build-repro/./bin
> Found candidate GCC installation: /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8
> Found candidate GCC installation: /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.8
> Selected GCC installation: /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8
> Candidate multilib: .;@m32
> Selected multilib: .;@m32
> "/mnt/nvme_sec/SRC/llvm-project/build-repro/./bin/ld.lld" --sysroot=/usr/local/google/home/haowei/SRC/fuchsia-sysroot --build-id --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o cmTC_5b689 /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crt1.o /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crti.o /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8/crtbegin.o -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8 -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/lib/i386-linux-gnu -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/lib -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib CMakeFiles/cmTC_5b689.dir/CMakeCCompilerABI.c.o /mnt/nvme_sec/SRC/llvm-project/build-repro/lib/clang/15.0.0/lib/i386-unknown-linux-gnu/libclang_rt.builtins.a -lc /mnt/nvme_sec/SRC/llvm-project/build-repro/lib/clang/15.0.0/lib/i386-unknown-linux-gnu/libclang_rt.builtins.a /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8/crtend.o /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crtn.o
> ld.lld: error: relocation refers to a symbol in a discarded section: __x86.get_pc_thunk.bx
> >>> defined in /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crti.o
> >>> referenced by /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crti.o:(.init+0x5)
> >>> referenced by /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crti.o:(.fini+0x5)
> >>> referenced by elf-init.oS:(__libc_csu_init) in archive /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/libc_nonshared.a
> clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
> ninja: build stopped: subcommand failed.
>
> So it is indeed the same type of error mentioned by @vitalybuka . I tested your fix in 6be457c14dafd634989c2c0b702a9231b438e2c4 <https://reviews.llvm.org/rG6be457c14dafd634989c2c0b702a9231b438e2c4> in our builder. but I am still seeing the same error: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8819586782274771361/overview . The CMakeError.log contains:
>
> [2/2] Linking C executable cmTC_ace5f
> FAILED: cmTC_ace5f
> : && /mnt/nvme_sec/SRC/llvm-project/build-repro-mitigate/./bin/clang --target=i386-unknown-linux-gnu --sysroot=/usr/local/google/home/haowei/SRC/fuchsia-sysroot --target=i386-unknown-linux-gnu -fuse-ld=lld -v CMakeFiles/cmTC_ace5f.dir/CMakeCCompilerABI.c.o -o cmTC_ace5f && :
> Fuchsia clang version 15.0.0 (git at github.com:llvm/llvm-project.git 6be457c14dafd634989c2c0b702a9231b438e2c4)
> Target: i386-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /mnt/nvme_sec/SRC/llvm-project/build-repro-mitigate/./bin
> Found candidate GCC installation: /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8
> Found candidate GCC installation: /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.8
> Selected GCC installation: /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8
> Candidate multilib: .;@m32
> Selected multilib: .;@m32
> "/mnt/nvme_sec/SRC/llvm-project/build-repro-mitigate/./bin/ld.lld" --sysroot=/usr/local/google/home/haowei/SRC/fuchsia-sysroot --build-id --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o cmTC_ace5f /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crt1.o /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crti.o /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8/crtbegin.o -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8 -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/lib/i386-linux-gnu -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/lib -L/usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib CMakeFiles/cmTC_ace5f.dir/CMakeCCompilerABI.c.o /mnt/nvme_sec/SRC/llvm-project/build-repro-mitigate/lib/clang/15.0.0/lib/i386-unknown-linux-gnu/libclang_rt.builtins.a -lc /mnt/nvme_sec/SRC/llvm-project/build-repro-mitigate/lib/clang/15.0.0/lib/i386-unknown-linux-gnu/libclang_rt.builtins.a /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/gcc/i586-linux-gnu/4.8/crtend.o /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crtn.o
> ld.lld: error: duplicate symbol: __x86.get_pc_thunk.bx
> >>> defined in /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/crti.o
> >>> defined in /usr/local/google/home/haowei/SRC/fuchsia-sysroot/usr/lib/i386-linux-gnu/libc_nonshared.a(elf-init.oS)
> clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
> ninja: build stopped: subcommand failed.
>
> Still complaining the same symbol but with a slightly different error: `ld.lld: error: duplicate symbol: __x86.get_pc_thunk.bx`. compared to earlier `ld.lld: error: relocation refers to a symbol in a discarded section: __x86.get_pc_thunk.bx`
>
> Could you take a look?
I just suppressed the error in c1d4c67718db88be48f451b91f7bddab8fff2424 <https://reviews.llvm.org/rGc1d4c67718db88be48f451b91f7bddab8fff2424>.
Can you provide i386-linux-gnu/crti.o and i386-linux-gnu/libc_nonshared.a(elf-init.oS)?
I need to understand the issue better to craft a better test. I believe the state before this patch worked for such symbols were accidental.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120626/new/
https://reviews.llvm.org/D120626
More information about the llvm-commits
mailing list