[ 83%] Building C object SingleSource/Regression/C/gcc-c-torture/execute/ieee/CMakeFiles/GCC-C-execute-ieee-fp-cmp-8e.dir/fp-cmp-8e.c.o [ 83%] Building C object SingleSource/Regression/C/gcc-c-torture/execute/ieee/CMakeFiles/GCC-C-execute-ieee-fp-cmp-3.dir/fp-cmp-3.c.o CMakeFiles/GCC-C-execute-ieee-compare-fp-3.dir/compare-fp-3.c.o: In function `test2': compare-fp-3.c:(.text+0x4d): undefined reference to `link_error0' CMakeFiles/GCC-C-execute-ieee-compare-fp-3.dir/compare-fp-3.c.o: In function `test3': compare-fp-3.c:(.text+0x8d): undefined reference to `link_error0' CMakeFiles/GCC-C-execute-ieee-compare-fp-3.dir/compare-fp-3.c.o: In function `test5': compare-fp-3.c:(.text+0x113): undefined reference to `link_error1' CMakeFiles/GCC-C-execute-ieee-compare-fp-3.dir/compare-fp-3.c.o: In function `test6': compare-fp-3.c:(.text+0x163): undefined reference to `link_error1' CMakeFiles/GCC-C-execute-ieee-compare-fp-3.dir/compare-fp-3.c.o: In function `all_tests': compare-fp-3.c:(.text+0x1f0): undefined reference to `link_error0' compare-fp-3.c:(.text+0x223): undefined reference to `link_error0' compare-fp-3.c:(.text+0x2f6): undefined reference to `link_error1' compare-fp-3.c:(.text+0x344): undefined reference to `link_error1' [ 83%] Linking C executable GCC-C-execute-ieee-fp-cmp-1 clang-12: error: linker command failed with exit code 1 (use -v to see invocation) [ 83%] Building C object SingleSource/Regression/C/gcc-c-torture/execute/ieee/CMakeFiles/GCC-C-execute-ieee-fp-cmp-8l.dir/fp-cmp-8l.c.o
if(TEST_SUITE_PROFILE_GENERATE) find_program(TEST_SUITE_LLVM_PROFDATA NAMES "llvm-profdata" HINTS ${CMAKE_C_COMPILER_DIRECTORY}) mark_as_advanced(TEST_SUITE_LLVM_PROFDATA) if(TEST_SUITE_LLVM_PROFDATA STREQUAL"TEST_SUITE_LLVM_PROFDATA-NOTFOUND") message(FATAL_ERROR "llvm-profdata not found. Make sure it is in your path or set TEST_SUITE_PROFILE_GENERATE to OFF") endif()
# in ~ [21:19:43] C:1 $ clang -fprofile-instr-generate compare-fp-3.c
# in ~ [21:19:51] $ clang -O3 -fprofile-instr-generate compare-fp-3.c /tmp/compare-fp-3-227c03.o: In function `test2': compare-fp-3.c:(.text+0x4d): undefined reference to `link_error0' /tmp/compare-fp-3-227c03.o: In function `test3': compare-fp-3.c:(.text+0x8d): undefined reference to `link_error0' /tmp/compare-fp-3-227c03.o: In function `test5': compare-fp-3.c:(.text+0x113): undefined reference to `link_error1' /tmp/compare-fp-3-227c03.o: In function `test6': compare-fp-3.c:(.text+0x163): undefined reference to `link_error1' /tmp/compare-fp-3-227c03.o: In function `all_tests': compare-fp-3.c:(.text+0x1f0): undefined reference to `link_error0' compare-fp-3.c:(.text+0x223): undefined reference to `link_error0' compare-fp-3.c:(.text+0x2f6): undefined reference to `link_error1' compare-fp-3.c:(.text+0x344): undefined reference to `link_error1' clang-12: error: linker command failed with exit code 1 (use -v to see invocation) # in ~ [21:20:34] C:1 $ clang -O0 -fprofile-instr-generate compare-fp-3.c
复现成功!这时突然注意到,最开始构建test-suite的时候,是开启了O3优化
1 2 3 4 5
% mkdir test-suite-build % cd test-suite-build % cmake -DCMAKE_C_COMPILER=<path to llvm build>/bin/clang \ -C../test-suite/cmake/caches/O3.cmake \ ../test-suite
So CMake is ignoring your -C option here and tries to load your CMakeCache.txt as an actual variable cache file. And those files have a different formatting/syntax of NAME:TYPE=VALUE.