[compiler-rt][CMake] Fix build when specifying --stdlib= (with 2 dashes) (#136111)
You can pass the stdlib argument either as -stdlib and --stdlib - the previous regex did not account for this however - which caused the build to fail, as a --stdlib argument would be replaced with a single dash, causing clang to assume reading from stdin and the build to fail: clang++: error: -E or -x required when input is from standard input clang++: error: cannot specify -o when generating multiple output files The files [libcxxabi/CMakeLists.txt](bf6986f9f0/libcxxabi/CMakeLists.txt (L261)) and [libunwind/CMakeLists.txt](bf6986f9f0/libunwind/CMakeLists.txt (L257)) account for this by removing --stdlib first. Co-authored-by: Vitaly Buka <vitalybuka@google.com>
This commit is contained in:
parent
bf4ed7903a
commit
b2ce908a48
@ -607,8 +607,8 @@ append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ SANITIZER_COMMON_CFLA
|
||||
append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SANITIZER_COMMON_LINK_FLAGS)
|
||||
|
||||
# Remove -stdlib= which is unused when passing -nostdinc++...
|
||||
string(REGEX MATCHALL "-stdlib=[a-zA-Z+]*" stdlib_flag "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX MATCHALL "-?-stdlib=[a-zA-Z+]*" stdlib_flag "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE "-?-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# ...we need it to build some runtimes and tests so readd it where appropriate.
|
||||
list(APPEND COMPILER_RT_COMMON_CFLAGS ${stdlib_flag})
|
||||
|
||||
@ -39,7 +39,7 @@ append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS)
|
||||
# append_list_if(COMPILER_RT_HAS_SANITIZER_COMMON ${SANITIZER_COMMON_CFLAGS} GWP_ASAN_CFLAGS)
|
||||
|
||||
# Remove -stdlib= which is unused when passing -nostdinc++.
|
||||
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE "-?-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# Options parsing support is optional. This is an optional library that can be
|
||||
# used by an allocator to automatically parse GwpAsan options from the
|
||||
|
||||
@ -46,7 +46,7 @@ set(MSAN_UNITTEST_COMMON_CFLAGS
|
||||
-fno-sanitize-memory-param-retval # unittests test mostly this mode.
|
||||
)
|
||||
# Remove -stdlib= which is unused when passing -nostdinc++.
|
||||
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "-?-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
set(MSAN_UNITTEST_INSTRUMENTED_CFLAGS
|
||||
${MSAN_UNITTEST_COMMON_CFLAGS}
|
||||
|
||||
@ -163,7 +163,7 @@ 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)
|
||||
# XRay uses C++ standard library headers.
|
||||
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE "-?-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# This appears to be a C-only warning banning the use of locals in aggregate
|
||||
# initializers. All other compilers accept this, though.
|
||||
|
||||
@ -13,7 +13,7 @@ list(APPEND SCUDO_CFLAGS
|
||||
-nostdinc++)
|
||||
|
||||
# Remove -stdlib= which is unused when passing -nostdinc++.
|
||||
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE "-?-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SCUDO_CFLAGS)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user