llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.51k stars 11.3k forks source link

[compiler-rt] Multiple Builtins-sparc-linux tests failing on 64-bit Linux SPARC #77358

Open glaubitz opened 7 months ago

glaubitz commented 7 months ago

A lot of if not all of the Builtins-sparc-linux tests are failing on 64-bit Linux SPARC due to incorrect target settings which results in a linker failure:

--

********************
FAIL: Builtins-sparc-linux :: ctzsi2_test.c (31 of 74554)
******************** TEST 'Builtins-sparc-linux :: ctzsi2_test.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/./bin/clang   -gline-tables-only  -m32  -fno-builtin -I /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/llvm/compiler-rt/lib/builtins -nodefaultlibs /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/llvm/compiler-rt/test/builtins/Unit/ctzsi2_test.c /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/./lib/../lib/clang/18/lib/sparcv9-unknown-linux-gnu/libclang_rt.builtins.a -lc -lm -o /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/projects/compiler-rt/test/builtins/Unit/SPARCLinuxConfig/Output/ctzsi2_test.c.tmp &&  /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/projects/compiler-rt/test/builtins/Unit/SPARCLinuxConfig/Output/ctzsi2_test.c.tmp
+ /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/./bin/clang -gline-tables-only -m32 -fno-builtin -I /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/llvm/compiler-rt/lib/builtins -nodefaultlibs /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/llvm/compiler-rt/test/builtins/Unit/ctzsi2_test.c /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/./lib/../lib/clang/18/lib/sparcv9-unknown-linux-gnu/libclang_rt.builtins.a -lc -lm -o /var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/projects/compiler-rt/test/builtins/Unit/SPARCLinuxConfig/Output/ctzsi2_test.c.tmp
/usr/bin/ld: sparc:v9 architecture of input file `/var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/stage1/./lib/../lib/clang/18/lib/sparcv9-unknown-linux-gnu/libclang_rt.builtins.a(ctzsi2.c.o)' is incompatible with sparc:v8plus output
clang: error: linker command failed with exit code 1 (use -v to see invocation)

--

Full build log available at: https://lab.llvm.org/staging/#/builders/159/builds/12

CC @jrtc27 @koachan @thesamesam

koachan commented 7 months ago

Any way I can reproduce this? The log link only gives me an empty page...

glaubitz commented 7 months ago

Any way I can reproduce this? The log link only gives me an empty page...

Hmm, for some reason the information for this particular build is no longer available.

Basically, this is with compiler-rt and sanitizers enabled, then the testsuite being run.

I will try to extract the cmake command line.

glaubitz commented 7 months ago

Try with:

cmake -G Ninja ../llvm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=True -DLLVM_LIT_ARGS='-v' -DCMAKE_INSTALL_PREFIX=../stage1.install -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_PARALLEL_LINK_JOBS=4 -DLLVM_TARGETS_TO_BUILD=Sparc -DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra;compiler-rt;llvm

This is on Linux (Debian unstable sparc64).

koachan commented 6 months ago

Try with:

cmake -G Ninja ../llvm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=True -DLLVM_LIT_ARGS='-v' -DCMAKE_INSTALL_PREFIX=../stage1.install -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_PARALLEL_LINK_JOBS=4 -DLLVM_TARGETS_TO_BUILD=Sparc -DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra;compiler-rt;llvm

This is on Linux (Debian unstable sparc64).

Hmm, weird. I tried this then followed by ninja check-builtins but I don't see this kind of error? The only failure I get is this which I don't think is related?

FAIL: Builtins-sparcv9-linux :: compiler_rt_logbl_test.c (95 of 218)                                                                    
******************** TEST 'Builtins-sparcv9-linux :: compiler_rt_logbl_test.c' FAILED ********************                                                                                                                                                                      
Exit Code: 1                                                                                                                            

Command Output (stdout):                                                                                                                
--                                                                                                                                                                                                                                                                              
error: in __compiler_rt_logbl([BFFF000000000000 0]) = [3FFE000000000000 0] !=  [0 0]                                                                                                                                                                                            

--                                                                                                                                      
Command Output (stderr):                                                                                                                
--                                                                                                                                                                                                                                                                              
RUN: at line 1: /home/k/llvm-debug/src/llvm-project/out/./bin/clang   -gline-tables-only  -m64  -fno-builtin -I /home/k/llvm-debug/src/llvm-project/compiler-rt/lib/builtins -nodefaultlibs /home/k/llvm-debug/src/llvm-project/compiler-rt/test/builtins/Unit/compiler_rt_logbl
_test.c /home/k/llvm-debug/src/llvm-project/out/./lib/../lib/clang/18/lib/sparcv9-unknown-linux-gnu/libclang_rt.builtins.a -lc -lm -o /home/k/llvm-debug/src/llvm-project/out/projects/compiler-rt/test/builtins/Unit/SPARCV9LinuxConfig/Output/compiler_rt_logbl_test.c.tmp && 
 /home/k/llvm-debug/src/llvm-project/out/projects/compiler-rt/test/builtins/Unit/SPARCV9LinuxConfig/Output/compiler_rt_logbl_test.c.tmp 
+ /home/k/llvm-debug/src/llvm-project/out/./bin/clang -gline-tables-only -m64 -fno-builtin -I /home/k/llvm-debug/src/llvm-project/compiler-rt/lib/builtins -nodefaultlibs /home/k/llvm-debug/src/llvm-project/compiler-rt/test/builtins/Unit/compiler_rt_logbl_test.c /home/k/ll
vm-debug/src/llvm-project/out/./lib/../lib/clang/18/lib/sparcv9-unknown-linux-gnu/libclang_rt.builtins.a -lc -lm -o /home/k/llvm-debug/src/llvm-project/out/projects/compiler-rt/test/builtins/Unit/SPARCV9LinuxConfig/Output/compiler_rt_logbl_test.c.tmp                      
+ /home/k/llvm-debug/src/llvm-project/out/projects/compiler-rt/test/builtins/Unit/SPARCV9LinuxConfig/Output/compiler_rt_logbl_test.c.tmp                                                                                                                                        

--                                                                                                                                      

********************
brad0 commented 6 months ago

cc @rorth

rorth commented 6 months ago

I had to clean out previous Linux/sparc64 builds to make root for LLVM 18.1.0 rc1. When doing a runtimes build on main (like test-release.sh would do), I found that in that case the builtins tests still aren't run at all: check-all misses 3200+ compiler-rt tests in runtimes build #72511 .

I'll run a projects build once the release build is done, but the latter is dog slow on my system, on the order of several days.

rorth commented 4 days ago

The only builtins test that FAILs for me on Linux/sparc64 is

Builtins-sparcv9-linux :: compiler_rt_logbl_test.c

The test errors out with

error: in __compiler_rt_logbl([BFFF000000000000 0]) = [3FFE000000000000 0] !=  [0 0]

Initially, I could reduce the testcase to the attached crlt.c. Looking further, the miscompilation happens at the call to _Qp_itoq. Compiling the testcase with gcc-14 works while compiling the identical testcase withclang-20 breaks.

It's even easier to see with the further reduced ti.c.

Compile with

gcc-14 -m64 -g3 -O0  -fno-builtin -I compiler-rt/lib/builtins -nodefaultlibs crlt.c -lgcc -lc -lm -o crlt

(same with clang-20) or

gcc-14 -m64 -g3 -O0 -o ti ti.c

FWIW, the test always works on Solaris/sparcv9, both with gcc and clang.

rorth commented 4 days ago

crlt.c.txt ti.c.txt Testcases.