[libcxx-commits] [PATCH] D69973: [libcxxabi] Prevent cmake from removing our explicit system C++ include paths

Sam Clegg via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 7 15:04:58 PST 2019


sbc100 created this revision.
Herald added subscribers: libcxx-commits, ldionne, christof, aheejin, mgorny.
Herald added a reviewer: EricWF.
Herald added a project: libc++.
sbc100 edited the summary of this revision.
sbc100 added a reviewer: dschuff.
Herald added a reviewer: mclow.lists.
sbc100 edited the summary of this revision.
Herald added a subscriber: sunfish.

We build with `-nostdinc++` and add our own header path via
`LIBCXXABI_LIBCXX_INCLUDES`.  However cmake tries to be clever and if
`LIBCXXABI_LIBCXX_INCLUDES` happens to match the compilers system path
it will remove the `-I` flag meaning we can't access any C++ headers.

This problem only happens when `LIBCXXABI_LIBCXX_INCLUDES` and the
compilers default C++ include path are the same thing.  This happens on the
wasm waterfall where we build and install libcxx into the compiler default
location before we build libcxxabi.

Ideally cmake would be able see that we are using `-nostdinc++` and
disable this behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69973

Files:
  libcxxabi/CMakeLists.txt


Index: libcxxabi/CMakeLists.txt
===================================================================
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -270,6 +270,12 @@
 
 if (LIBCXXABI_HAS_NOSTDINCXX_FLAG)
   list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++)
+  # Recent versions of cmake have a behaviour where system include paths are
+  # detected and removed from user flags.  Here we build with -nostdinc++ and
+  # explictly add libcxx (system) include paths with -I on the command line.
+  # Setting CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES effecticly prevents cmake
+  # from removing these.
+  set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "")
   # Remove -stdlib flags to prevent them from causing an unused flag warning.
   string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
   string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69973.228324.patch
Type: text/x-patch
Size: 892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20191107/a33e4546/attachment.bin>


More information about the libcxx-commits mailing list