Skip to content

Commit 5a90df8

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_properties()` and removes the flag from the global `EXTRA_FLAGS`.
1 parent 09984be commit 5a90df8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler-rt/lib/profile/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ 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_property(SOURCE InstrProfilingRuntime.cpp APPEND_STRING
147+
PROPERTY COMPILE_FLAGS " -nostdinc++")
148+
endif()
146149
# XRay uses C++ standard library headers.
147150
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
148151

0 commit comments

Comments
 (0)