diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -87,12 +87,16 @@ include(CheckLibraryExists) include(CheckCCompilerFlag) +include(CheckCXXCompilerFlag) -# Disable use of the installed C++ standard library when building runtimes. If -# MSVC is true, we must be using the clang-cl driver, which doesn't understand -# these flags. -if (NOT MSVC) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++ -nostdlib++") +# Disable use of the installed C++ standard library when building runtimes. +check_cxx_compiler_flag(-nostdinc++ LLVM_RUNTIMES_SUPPORT_NOSTDINCXX_FLAG) +if (LLVM_RUNTIMES_SUPPORT_NOSTDINCXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++") +endif() +check_c_compiler_flag(-nostdlib++ LLVM_RUNTIMES_SUPPORT_NOSTDLIBXX_FLAG) +if (LLVM_RUNTIMES_SUPPORT_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") endif() # Avoid checking whether the compiler is working.