Skip to content

Commit efe9453

Browse files
committed
[compiler-rt][NFC] Apply -nostdinc++ only to C++ source in profile runtime
Avoid passing the C++-specific `-nostdinc++` flag to C source files in the profile runtime library, which triggers warnings when building with GCC: cc1: warning: command-line option ‘-nostdinc++’ is valid for C++/ObjC++ but not for C We only need `-nostdinc++` for `InstrProfilingRuntime.cpp` to prevent accidental inclusion of the C++ standard library headers. This patch scopes the flag to that file using `set_source_files_properties()` and removes the flag from the global `EXTRA_FLAGS`.
1 parent 09984be commit efe9453

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler-rt/lib/profile/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ if(MSVC)
142142
endif()
143143

144144
# We don't use the C++ Standard Library here, so avoid including it by mistake.
145-
append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ EXTRA_FLAGS)
145+
if(COMPILER_RT_HAS_NOSTDINCXX_FLAG)
146+
set_source_files_properties(
147+
InstrProfilingRuntime.cpp
148+
PROPERTIES
149+
COMPILE_FLAGS "-nostdinc++"
150+
)
151+
endif()
146152
# XRay uses C++ standard library headers.
147153
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
148154

0 commit comments

Comments
 (0)