[compiler-rt] COMPILER_RT_DEFAULT_TARGET_ONLY should explicitly pass the triple to test #187836
[compiler-rt] COMPILER_RT_DEFAULT_TARGET_ONLY should explicitly pass the triple to test #187836
Conversation
|
I tried this with the repro form #176913 and it doesn't build: |
…pass the triple to tests COMPILER_RT_DEFAULT_TARGET_ONLY normally requires CMAKE_C_COMPILER_TARGET, which should ensure that CMake builds with the specified target triple. However, test cflags do not currently pass the triple. This can cause issues (llvm#176913) when the default architecture (i.e. the host architecture) does not match the architecture being tested -- for example i386 on x86_64. Closes llvm#176913
fbd4666 to
db5c057
Compare
|
@zmodem Could you try again now? This seems to work for me now on linux with your cmdline except i.e. it looks like tests are running with the explicit |
|
Now it gets further, but it fails to link the 32-bit crt: |
|
Ok. I think this is a step in the right direction, since we actually invoke clang with the correct target triple now ( Unfortunately, I don't have any knowledge of MSVC or windows at all -- from afar, it looks like something picked the 64-bit libcmt If I had to guess, we could fix this by passing I think this change as-is probably still fixes a real issue when testing builtins built with an explicit i386 triple on linux, so we should probably take it. |
|
This could be worth a try (in place of the line changed by this PR)? We could at least confirm if we actually need It's kindof ugly, though. |
Yes, it's doing this based on environment variables. The overall build is targeting x86_64 windows, with the LIB environment variable pointing to the 64-bit runtime library.
It's failing when building the test, compiler-rt/test/builtins/Unit/absvsi2_test.c, which has a main(), uses printf() etc. which is why it's trying to link the standard library.
Sadly that doesn't help (I also tried your suggestion below). IIRC it doesn't have any deeper effect than changing the target triple to 32-bit. Maybe the best fix for now would be to not try to run the 32-bit tests in 64-bit builds and vice versa. |
|
@zmodem Are you building/testing any other compiler-rt components here? If you really can't link simple test programs, that shouldn't be a builtins-specific issue (Any other compiler-rt test should fail -- if they pass, then we should figure out what they are doing and copy it). I think you should probably just set |
COMPILER_RT_DEFAULT_TARGET_ONLY normally requires CMAKE_C_COMPILER_TARGET, which ensures that CMake builds with the specified target triple (e.g. by CMake automatically appending the -target flag)
However, when running tests no target triple is currently passed. This can cause issues (#176913) when the default architecture assumed by
clang(i.e. the host architecture) does not match the architecture being tested -- for example i386 on x86_64. To solve this, we add -target to the cflags used for the tests as well.Closes #176913
rdar://172833755