[llvm] fb0b19c - Reland "[gn build] port 48e4b0f (__config_site)"
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 30 17:32:43 PDT 2021
Author: Nico Weber
Date: 2021-03-30T20:32:36-04:00
New Revision: fb0b19c3de3b49bd6c343d6c02293cbcc77520fb
URL: https://github.com/llvm/llvm-project/commit/fb0b19c3de3b49bd6c343d6c02293cbcc77520fb
DIFF: https://github.com/llvm/llvm-project/commit/fb0b19c3de3b49bd6c343d6c02293cbcc77520fb.diff
LOG: Reland "[gn build] port 48e4b0f (__config_site)"
This reverts commit 13aff21f0da7007c42d407b4ec5c1f6b24cb6831,
since the CMake part relanded in c06a8f9caa51c7ea7.
The GN part is a bit simpler than last time due to the
prior simplifications in acea470c167fc40.
Added:
Modified:
llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
llvm/utils/gn/secondary/libcxx/include/BUILD.gn
llvm/utils/gn/secondary/libcxx/src/BUILD.gn
llvm/utils/gn/secondary/libcxxabi/src/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 a91ee25224d85..24a95e1968bec 100644
--- a/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -86,7 +86,7 @@ executable("clang") {
# 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" ]
+ deps += [ "//libcxx/include:copy_headers" ]
}
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 cb89a7de71cce..371afc5969957 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -1,273 +1,278 @@
import("//libcxx/config.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
-write_cmake_config("write_config") {
- input = "__config_site.in"
- output = "$target_gen_dir/__config_site"
+libcxx_generated_include_dir = "$root_build_dir/include/c++/v1"
- values = [
- "_LIBCPP_ABI_FORCE_ITANIUM=",
- "_LIBCPP_ABI_FORCE_MICROSOFT=",
- "_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
- "_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY=",
- "_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE=",
- "_LIBCPP_HAS_NO_STDIN=",
- "_LIBCPP_HAS_NO_STDOUT=",
- "_LIBCPP_HAS_NO_THREADS=",
- "_LIBCPP_HAS_NO_MONOTONIC_CLOCK=",
- "_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS=",
- "_LIBCPP_HAS_MUSL_LIBC=",
- "_LIBCPP_HAS_THREAD_API_PTHREAD=",
- "_LIBCPP_HAS_THREAD_API_EXTERNAL=",
- "_LIBCPP_HAS_THREAD_API_WIN32=",
- "_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL=",
- "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=",
- "_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS=1",
- "_LIBCPP_NO_VCRUNTIME=",
- "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=",
- "_LIBCPP_HAS_PARALLEL_ALGORITHMS=",
- "_LIBCPP_HAS_NO_RANDOM_DEVICE=",
- "_LIBCPP_HAS_NO_LOCALIZATION=",
- "_LIBCPP_ABI_DEFINES=",
- ]
- if (libcxx_abi_version != 1) {
- values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
- } else {
- values += [ "_LIBCPP_ABI_VERSION=" ]
- }
- if (libcxx_abi_namespace != "") {
- values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
- } else {
- values += [ "_LIBCPP_ABI_NAMESPACE=" ]
+# This is a bit weird. For now, we assume that __config_site is identical
+# in all toolchains, and only copy it (and all other libcxx headers)
+# to 'include' in the root build dir, so that it's the same for all toolchains.
+# Maybe we wnt to make this per-toolchain eventually (and then use root_out_dir
+# in libcxx_generated_include_dir) -- e.g. for cross-builds that for example
+# use for-linux-configured libc++ for the host build but for-windows-configured
+# libc++ for the target build.
+if (current_toolchain == default_toolchain) {
+ write_cmake_config("write_config_site") {
+ input = "__config_site.in"
+ output = "$libcxx_generated_include_dir/__config_site"
+
+ values = [
+ "_LIBCPP_ABI_FORCE_ITANIUM=",
+ "_LIBCPP_ABI_FORCE_MICROSOFT=",
+ "_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
+ "_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY=",
+ "_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE=",
+ "_LIBCPP_HAS_NO_STDIN=",
+ "_LIBCPP_HAS_NO_STDOUT=",
+ "_LIBCPP_HAS_NO_THREADS=",
+ "_LIBCPP_HAS_NO_MONOTONIC_CLOCK=",
+ "_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS=",
+ "_LIBCPP_HAS_MUSL_LIBC=",
+ "_LIBCPP_HAS_THREAD_API_PTHREAD=",
+ "_LIBCPP_HAS_THREAD_API_EXTERNAL=",
+ "_LIBCPP_HAS_THREAD_API_WIN32=",
+ "_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL=",
+ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=",
+ "_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS=1",
+ "_LIBCPP_NO_VCRUNTIME=",
+ "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=",
+ "_LIBCPP_HAS_PARALLEL_ALGORITHMS=",
+ "_LIBCPP_HAS_NO_RANDOM_DEVICE=",
+ "_LIBCPP_HAS_NO_LOCALIZATION=",
+ "_LIBCPP_ABI_DEFINES=",
+ ]
+ if (libcxx_abi_version != 1) {
+ values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
+ } else {
+ values += [ "_LIBCPP_ABI_VERSION=" ]
+ }
+ if (libcxx_abi_namespace != "") {
+ values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
+ } else {
+ values += [ "_LIBCPP_ABI_NAMESPACE=" ]
+ }
+ if (libcxx_abi_unstable) {
+ values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
+ } else {
+ values += [ "_LIBCPP_ABI_UNSTABLE=" ]
+ }
}
- if (libcxx_abi_unstable) {
- values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
- } else {
- values += [ "_LIBCPP_ABI_UNSTABLE=" ]
+
+ copy("copy_headers") {
+ sources = [
+ "__availability",
+ "__bit_reference",
+ "__bits",
+ "__bsd_locale_defaults.h",
+ "__bsd_locale_fallbacks.h",
+ "__debug",
+ "__errc",
+ "__functional_03",
+ "__functional_base",
+ "__functional_base_03",
+ "__hash_table",
+ "__libcpp_version",
+ "__locale",
+ "__memory/allocator_traits.h",
+ "__memory/base.h",
+ "__memory/pointer_traits.h",
+ "__memory/utilities.h",
+ "__mutex_base",
+ "__node_handle",
+ "__nullptr",
+ "__split_buffer",
+ "__sso_allocator",
+ "__std_stream",
+ "__string",
+ "__support/android/locale_bionic.h",
+ "__support/fuchsia/xlocale.h",
+ "__support/ibm/gettod_zos.h",
+ "__support/ibm/limits.h",
+ "__support/ibm/locale_mgmt_aix.h",
+ "__support/ibm/locale_mgmt_zos.h",
+ "__support/ibm/nanosleep.h",
+ "__support/ibm/support.h",
+ "__support/ibm/xlocale.h",
+ "__support/musl/xlocale.h",
+ "__support/newlib/xlocale.h",
+ "__support/nuttx/xlocale.h",
+ "__support/openbsd/xlocale.h",
+ "__support/solaris/floatingpoint.h",
+ "__support/solaris/wchar.h",
+ "__support/solaris/xlocale.h",
+ "__support/win32/limits_msvc_win32.h",
+ "__support/win32/locale_win32.h",
+ "__support/xlocale/__nop_locale_mgmt.h",
+ "__support/xlocale/__posix_l_fallback.h",
+ "__support/xlocale/__strtonum_fallback.h",
+ "__threading_support",
+ "__tree",
+ "__tuple",
+ "__undef_macros",
+ "algorithm",
+ "any",
+ "array",
+ "atomic",
+ "barrier",
+ "bit",
+ "bitset",
+ "cassert",
+ "ccomplex",
+ "cctype",
+ "cerrno",
+ "cfenv",
+ "cfloat",
+ "charconv",
+ "chrono",
+ "cinttypes",
+ "ciso646",
+ "climits",
+ "clocale",
+ "cmath",
+ "codecvt",
+ "compare",
+ "complex",
+ "complex.h",
+ "concepts",
+ "condition_variable",
+ "csetjmp",
+ "csignal",
+ "cstdarg",
+ "cstdbool",
+ "cstddef",
+ "cstdint",
+ "cstdio",
+ "cstdlib",
+ "cstring",
+ "ctgmath",
+ "ctime",
+ "ctype.h",
+ "cwchar",
+ "cwctype",
+ "deque",
+ "errno.h",
+ "exception",
+ "execution",
+ "experimental/__config",
+ "experimental/__memory",
+ "experimental/algorithm",
+ "experimental/coroutine",
+ "experimental/deque",
+ "experimental/filesystem",
+ "experimental/forward_list",
+ "experimental/functional",
+ "experimental/iterator",
+ "experimental/list",
+ "experimental/map",
+ "experimental/memory_resource",
+ "experimental/propagate_const",
+ "experimental/regex",
+ "experimental/set",
+ "experimental/simd",
+ "experimental/string",
+ "experimental/type_traits",
+ "experimental/unordered_map",
+ "experimental/unordered_set",
+ "experimental/utility",
+ "experimental/vector",
+ "ext/__hash",
+ "ext/hash_map",
+ "ext/hash_set",
+ "fenv.h",
+ "filesystem",
+ "float.h",
+ "format",
+ "forward_list",
+ "fstream",
+ "functional",
+ "future",
+ "initializer_list",
+ "inttypes.h",
+ "iomanip",
+ "ios",
+ "iosfwd",
+ "iostream",
+ "istream",
+ "iterator",
+ "latch",
+ "limits",
+ "limits.h",
+ "list",
+ "locale",
+ "locale.h",
+ "map",
+ "math.h",
+ "memory",
+ "module.modulemap",
+ "mutex",
+ "new",
+ "numbers",
+ "numeric",
+ "optional",
+ "ostream",
+ "queue",
+ "random",
+ "ratio",
+ "regex",
+ "scoped_allocator",
+ "semaphore",
+ "set",
+ "setjmp.h",
+ "shared_mutex",
+ "span",
+ "sstream",
+ "stack",
+ "stdbool.h",
+ "stddef.h",
+ "stdexcept",
+ "stdint.h",
+ "stdio.h",
+ "stdlib.h",
+ "streambuf",
+ "string",
+ "string.h",
+ "string_view",
+ "strstream",
+ "system_error",
+ "tgmath.h",
+ "thread",
+ "tuple",
+ "type_traits",
+ "typeindex",
+ "typeinfo",
+ "unordered_map",
+ "unordered_set",
+ "utility",
+ "valarray",
+ "variant",
+ "vector",
+ "version",
+ "wchar.h",
+ "wctype.h",
+ ]
+ deps = [ ":write_config_site" ]
+ 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" ]
+ }
+ outputs = [ "$root_build_dir/include/c++/v1/{{source_target_relative}}" ]
}
}
-# Generate a custom __config header. The new header is created
-# by prepending __config_site to the current __config header.
-action("concat_config") {
- script = "//libcxx/utils/cat_files.py"
- inputs = [
- "$target_gen_dir/__config_site",
- "__config",
- ]
- outputs = [ "$root_build_dir/include/c++/v1/__config" ]
- args = [
- rebase_path("$target_gen_dir/__config_site", root_build_dir),
- rebase_path("__config", root_build_dir),
- "-o",
- rebase_path(outputs[0], root_build_dir),
- ]
- deps = [ ":write_config" ]
+config("include_config") {
+ include_dirs = [ libcxx_generated_include_dir ]
}
-copy("include") {
- sources = [
- "__availability",
- "__bit_reference",
- "__bits",
- "__bsd_locale_defaults.h",
- "__bsd_locale_fallbacks.h",
- "__debug",
- "__errc",
- "__functional_03",
- "__functional_base",
- "__functional_base_03",
- "__hash_table",
- "__libcpp_version",
- "__locale",
- "__memory/allocator_traits.h",
- "__memory/base.h",
- "__memory/pointer_traits.h",
- "__memory/utilities.h",
- "__mutex_base",
- "__node_handle",
- "__nullptr",
- "__split_buffer",
- "__sso_allocator",
- "__std_stream",
- "__string",
- "__support/android/locale_bionic.h",
- "__support/fuchsia/xlocale.h",
- "__support/ibm/gettod_zos.h",
- "__support/ibm/limits.h",
- "__support/ibm/locale_mgmt_aix.h",
- "__support/ibm/locale_mgmt_zos.h",
- "__support/ibm/nanosleep.h",
- "__support/ibm/support.h",
- "__support/ibm/xlocale.h",
- "__support/musl/xlocale.h",
- "__support/newlib/xlocale.h",
- "__support/nuttx/xlocale.h",
- "__support/openbsd/xlocale.h",
- "__support/solaris/floatingpoint.h",
- "__support/solaris/wchar.h",
- "__support/solaris/xlocale.h",
- "__support/win32/limits_msvc_win32.h",
- "__support/win32/locale_win32.h",
- "__support/xlocale/__nop_locale_mgmt.h",
- "__support/xlocale/__posix_l_fallback.h",
- "__support/xlocale/__strtonum_fallback.h",
- "__threading_support",
- "__tree",
- "__tuple",
- "__undef_macros",
- "algorithm",
- "any",
- "array",
- "atomic",
- "barrier",
- "bit",
- "bitset",
- "cassert",
- "ccomplex",
- "cctype",
- "cerrno",
- "cfenv",
- "cfloat",
- "charconv",
- "chrono",
- "cinttypes",
- "ciso646",
- "climits",
- "clocale",
- "cmath",
- "codecvt",
- "compare",
- "complex",
- "complex.h",
- "concepts",
- "condition_variable",
- "csetjmp",
- "csignal",
- "cstdarg",
- "cstdbool",
- "cstddef",
- "cstdint",
- "cstdio",
- "cstdlib",
- "cstring",
- "ctgmath",
- "ctime",
- "ctype.h",
- "cwchar",
- "cwctype",
- "deque",
- "errno.h",
- "exception",
- "execution",
- "experimental/__config",
- "experimental/__memory",
- "experimental/algorithm",
- "experimental/coroutine",
- "experimental/deque",
- "experimental/filesystem",
- "experimental/forward_list",
- "experimental/functional",
- "experimental/iterator",
- "experimental/list",
- "experimental/map",
- "experimental/memory_resource",
- "experimental/propagate_const",
- "experimental/regex",
- "experimental/set",
- "experimental/simd",
- "experimental/string",
- "experimental/type_traits",
- "experimental/unordered_map",
- "experimental/unordered_set",
- "experimental/utility",
- "experimental/vector",
- "ext/__hash",
- "ext/hash_map",
- "ext/hash_set",
- "fenv.h",
- "filesystem",
- "float.h",
- "format",
- "forward_list",
- "fstream",
- "functional",
- "future",
- "initializer_list",
- "inttypes.h",
- "iomanip",
- "ios",
- "iosfwd",
- "iostream",
- "istream",
- "iterator",
- "latch",
- "limits",
- "limits.h",
- "list",
- "locale",
- "locale.h",
- "map",
- "math.h",
- "memory",
- "module.modulemap",
- "mutex",
- "new",
- "numbers",
- "numeric",
- "optional",
- "ostream",
- "queue",
- "random",
- "ratio",
- "regex",
- "scoped_allocator",
- "semaphore",
- "set",
- "setjmp.h",
- "shared_mutex",
- "span",
- "sstream",
- "stack",
- "stdbool.h",
- "stddef.h",
- "stdexcept",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "streambuf",
- "string",
- "string.h",
- "string_view",
- "strstream",
- "system_error",
- "tgmath.h",
- "thread",
- "tuple",
- "type_traits",
- "typeindex",
- "typeinfo",
- "unordered_map",
- "unordered_set",
- "utility",
- "valarray",
- "variant",
- "vector",
- "version",
- "wchar.h",
- "wctype.h",
+
+group("include") {
+ deps = [
+ ":copy_headers($default_toolchain)",
]
- deps = [ ":concat_config" ]
- 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" ]
- }
- outputs = [ "$root_build_dir/include/c++/v1/{{source_target_relative}}" ]
+ public_configs = [ ":include_config" ]
}
diff --git a/llvm/utils/gn/secondary/libcxx/src/BUILD.gn b/llvm/utils/gn/secondary/libcxx/src/BUILD.gn
index 0b0b22f5669b5..d91233d465991 100644
--- a/llvm/utils/gn/secondary/libcxx/src/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/src/BUILD.gn
@@ -1,4 +1,5 @@
import("//clang/runtimes.gni")
+import("//libcxx/config.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
declare_args() {
@@ -37,10 +38,7 @@ declare_args() {
}
config("cxx_config") {
- include_dirs = [
- "//libcxxabi/include",
- "//libcxx/include",
- ]
+ include_dirs = [ "//libcxxabi/include" ]
cflags = [
"-Wall",
"-Wextra",
@@ -212,6 +210,7 @@ if (libcxx_enable_shared) {
sources = cxx_sources
deps = [
"//compiler-rt/lib/builtins",
+ "//libcxx/include",
"//libcxxabi/src:cxxabi_shared",
"//libunwind/src:unwind_shared",
]
@@ -261,6 +260,7 @@ if (libcxx_enable_static) {
}
deps = [
"//compiler-rt/lib/builtins",
+ "//libcxx/include",
"//libcxxabi/src:cxxabi_static",
"//libunwind/src:unwind_static",
]
@@ -277,6 +277,7 @@ if (libcxx_enable_experimental) {
output_dir = runtimes_dir
output_name = "c++experimental"
sources = [ "experimental/memory_resource.cpp" ]
+ deps = [ "//libcxx/include" ]
configs += [ ":cxx_config" ]
configs -= [
"//llvm/utils/gn/build:no_exceptions",
diff --git a/llvm/utils/gn/secondary/libcxxabi/src/BUILD.gn b/llvm/utils/gn/secondary/libcxxabi/src/BUILD.gn
index 2cce12921e381..8a981d2aba5e3 100644
--- a/llvm/utils/gn/secondary/libcxxabi/src/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxxabi/src/BUILD.gn
@@ -61,7 +61,6 @@ if (target_os == "linux" || target_os == "fuchsia") {
config("cxxabi_config") {
include_dirs = [
"//libcxxabi/include",
- "//libcxx/include",
# stdlib_stdexcept.cpp depends on libc++ internals.
"//libcxx",
@@ -89,6 +88,7 @@ if (libcxxabi_enable_shared) {
public = cxxabi_headers
deps = [
"//compiler-rt/lib/builtins",
+ "//libcxx/include",
"//libunwind/src:unwind_shared",
]
configs += [ ":cxxabi_config" ]
@@ -119,6 +119,7 @@ if (libcxxabi_enable_static) {
}
deps = [
"//compiler-rt/lib/builtins",
+ "//libcxx/include",
"//libunwind/src:unwind_static",
]
configs += [ ":cxxabi_config" ]
More information about the llvm-commits
mailing list