[llvm] 3dc4797 - [gn build] make 'clang' target depend on libcxx/include on mac

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 04:43:58 PST 2020


Author: Nico Weber
Date: 2020-02-10T07:43:42-05:00
New Revision: 3dc47979bb9eb99e5bec5fb33215d256cbaa3eb1

URL: https://github.com/llvm/llvm-project/commit/3dc47979bb9eb99e5bec5fb33215d256cbaa3eb1
DIFF: https://github.com/llvm/llvm-project/commit/3dc47979bb9eb99e5bec5fb33215d256cbaa3eb1.diff

LOG: [gn build] make 'clang' target depend on libcxx/include on mac

On macOS, libc++ headers are distributed with the compiler, not
the sysroot. Without this, compiling a file that includes something
like <string> won't compile with gn-built clang without manual tweaks.

I used to do the manual tweaks, but now that other people are starting
to use this on mac, let's make it Just Work.

(This is marginally nicer than the cmake build now in that you can
just build 'clang' and it'll do the right thing.)

Differential Revision: https://reviews.llvm.org/D74247

Added: 
    

Modified: 
    llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
    llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
index 52214141c5f1..a91ee25224d8 100644
--- a/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -80,6 +80,13 @@ executable("clang") {
     plist = get_target_outputs(":write_info_plist")
     ldflags = [ "-Wl,-sectcreate,__TEXT,__info_plist," +
                 rebase_path(plist[0], root_out_dir) ]
+
+    # On macOS, libcxx headers are bundled with the compiler, not with the
+    # sysroot. As a convenience, automatically copy them over when buildling
+    # clang.  This is 
diff erent from the CMake build, which requires devs to
+    # explicitly build the "libcxx" target (which also needlessly compiles the
+    # libcxx sources) to get a working compiler.
+    deps += [ "//libcxx/include" ]
   }
   sources = [
     "cc1_main.cpp",

diff  --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index 80c07c948675..904ace07585f 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -210,7 +210,18 @@ copy("include") {
     "wchar.h",
     "wctype.h",
   ]
-  deps = [ "//libcxxabi/include" ]
+  deps = []
+  if (target_os != "mac" && target_os != "win") {
+    # libcxx/cmake/Modules/HandleLibCXXABI.cmake sets
+    # LIBCXX_CXX_ABI_HEADER_TARGET if the libcxx abi library either of
+    # "libstdc++", "libsupc++", "libcxxabi", "libcxxrt", but not if it's "none",
+    # "default", or "vcruntime". So on Windows, these don't get copied due to
+    # LIBCXX_CXX_ABI_HEADER_TARGET not being set.
+    # On macOS, libcxx/CMakeLists.txt sets LIBCXX_CXX_ABI_SYSTEM to 1, which
+    # causes an empty header list to be passed to setup_abi_lib, so these
+    # don't get copied on macOS due to that.
+    deps += [ "//libcxxabi/include" ]
+  }
   if (!libcxx_needs_site_config) {
     sources += [ "__config" ]
   } else {


        


More information about the llvm-commits mailing list