Skip to content

Commit 07317bb

Browse files
committed
[compiler-rt] Build libfuzzer sources with the chosen C++ compiler
I was getting build failures due to missing <cstddef> when building the libfuzzer tests. It turns out that the custom command was using COMPILER_RT_TEST_COMPILER when building the source file rather than the COMPILER_RT_TEST_CXX_COMPILER. Pull Request: #83090
1 parent a2e7827 commit 07317bb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler-rt/cmake/Modules/CompilerRTCompile.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@ function(clang_compile object_file source)
7070
if (TARGET CompilerRTUnitTestCheckCxx)
7171
list(APPEND SOURCE_DEPS CompilerRTUnitTestCheckCxx)
7272
endif()
73+
string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
74+
if (is_cxx)
75+
set(compiler ${COMPILER_RT_TEST_COMPILER})
76+
else()
77+
set(compiler ${COMPILER_RT_TEST_CXX_COMPILER})
78+
endif()
7379
if(COMPILER_RT_STANDALONE_BUILD)
7480
# Only add global flags in standalone build.
75-
string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
7681
if(is_cxx)
7782
string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
7883
else()
@@ -102,7 +107,7 @@ function(clang_compile object_file source)
102107

103108
add_custom_command(
104109
OUTPUT ${object_file}
105-
COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c
110+
COMMAND ${compiler} ${compile_flags} -c
106111
-o "${object_file}"
107112
${source_rpath}
108113
MAIN_DEPENDENCY ${source}

0 commit comments

Comments
 (0)