diff options
author | Reid Kleckner <rnk@google.com> | 2021-01-15 12:35:42 -0800 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2021-01-15 13:22:07 -0800 |
commit | 98c89ccfbd7467f946874c2af170d0f504355dd1 (patch) | |
tree | 9ec5362fd133545021665c76b365b018da0e8510 /runtimes | |
parent | 6a42cbf6d2116b52cb59aa3e23bef93a30cf2dc8 (diff) | |
download | llvm-98c89ccfbd7467f946874c2af170d0f504355dd1.tar.gz |
[MSVC] Don't add -nostdinc++ -isystem to runtimes builds
If the host compiler is MSVC or clang-cl, then the compiler used to
buidl the runtimes will be clang-cl, and it doesn't support either of
those flags.
Worse, because -isystem is a space separated flag, it causes all cmake
try_compile tests to fail, so none of the -Wno-* flags make it to the
compiler in libcxx. I noticed that we weren't passing
-Wno-user-defined-literals to clang-cl and were getting warnings in the
build, and this fixes that for me.
Differential Revision: https://reviews.llvm.org/D94817
Diffstat (limited to 'runtimes')
-rw-r--r-- | runtimes/CMakeLists.txt | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 4bb822e07599..a1017d91f36a 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -77,12 +77,15 @@ endif() include(CheckLibraryExists) include(CheckCCompilerFlag) -# We don't have libc++ (yet)... -set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++ -nostdlib++") - -# ...but we need access to libc++ headers for CMake checks to succeed. -if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -isystem ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include") +# 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++") + + if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -isystem ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include") + endif() endif() # Avoid checking whether the compiler is working. |