[libcxx-commits] [PATCH] D94817: [MSVC] Don't add -nostdinc++ -isystem to runtimes builds

Reid Kleckner via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 15 12:38:13 PST 2021


rnk created this revision.
rnk added reviewers: mstorsjo, ldionne.
Herald added a subscriber: mgorny.
rnk requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94817

Files:
  runtimes/CMakeLists.txt


Index: runtimes/CMakeLists.txt
===================================================================
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -77,12 +77,15 @@
 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
+# the host compiler is MSVC or clang-cl, then the runtime compiler will be
+# clang-cl. clang-cl doesn't support -nostdinc++ or -isystem, so don't use them.
+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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94817.317047.patch
Type: text/x-patch
Size: 1205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210115/c1b86db9/attachment.bin>


More information about the libcxx-commits mailing list