-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[compiler-rt][NFC] Apply -nostdinc++ only to C++ source in profile runtime #139038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-pgo Author: Wang Qiang (ReVe1uv) ChangesAvoid passing the C++-specific
We only need
Full diff: https://github.com/llvm/llvm-project/pull/139038.diff 1 Files Affected:
diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed1..2a6a79a41cb97 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -142,7 +142,13 @@ if(MSVC)
endif()
# We don't use the C++ Standard Library here, so avoid including it by mistake.
-append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ EXTRA_FLAGS)
+if(COMPILER_RT_HAS_NOSTDINCXX_FLAG)
+ set_source_files_properties(
+ InstrProfilingRuntime.cpp
+ PROPERTIES
+ COMPILE_FLAGS "-nostdinc++"
+ )
+endif()
# XRay uses C++ standard library headers.
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
efe9453
to
83a1734
Compare
…ntime 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`.
83a1734
to
5a90df8
Compare
Avoid passing the C++-specific
-nostdinc++
flag to C source files in the profile runtime library, which triggers warnings when building with GCC:We only need
-nostdinc++
forInstrProfilingRuntime.cpp
to prevent accidental inclusion of the C++ standard library headers. This patch scopes the flag to that file usingset_property()
and removes the flag from the globalEXTRA_FLAGS
.