[gn build] (manually) port 5d796645d6 (libcxx __config change)

This commit is contained in:
Nico Weber 2020-10-21 12:50:22 -04:00
parent 4a8b52b53d
commit 37c030f81a
3 changed files with 254 additions and 240 deletions

View File

@ -1,4 +1,3 @@
import("//clang/resource_dir.gni")
import("//libcxx/config.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
@ -7,252 +6,267 @@ declare_args() {
libcxx_install_support_headers = true
}
libcxx_needs_site_config =
libcxx_abi_version != 1 || libcxx_abi_namespace != "" || libcxx_abi_unstable
libcxx_generated_include_dir = "$root_build_dir/include/c++/v1"
if (libcxx_needs_site_config) {
write_cmake_config("write_config") {
# 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 = "$target_gen_dir/__config_site"
output = "$libcxx_generated_include_dir/__config_site"
values = []
values = [
"_LIBCPP_ABI_FORCE_ITANIUM=",
"_LIBCPP_ABI_FORCE_MICROSOFT=",
"_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
"_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_NO_VCRUNTIME=",
"_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=",
"_LIBCPP_HAS_PARALLEL_ALGORITHMS=",
"_LIBCPP_HAS_NO_RANDOM_DEVICE=",
"_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" ]
}
values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
if (libcxx_abi_unstable) {
values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
} else {
values += [ "_LIBCPP_ABI_UNSTABLE=" ]
}
}
# 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",
copy("copy_headers") {
sources = [
"__bit_reference",
"__bsd_locale_defaults.h",
"__bsd_locale_fallbacks.h",
"__config",
"__debug",
"__errc",
"__functional_03",
"__functional_base",
"__functional_base_03",
"__hash_table",
"__libcpp_version",
"__locale",
"__mutex_base",
"__node_handle",
"__nullptr",
"__split_buffer",
"__sso_allocator",
"__std_stream",
"__string",
"__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",
"condition_variable",
"csetjmp",
"csignal",
"cstdarg",
"cstdbool",
"cstddef",
"cstdint",
"cstdio",
"cstdlib",
"cstring",
"ctgmath",
"ctime",
"ctype.h",
"cwchar",
"cwctype",
"deque",
"errno.h",
"exception",
"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",
"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",
"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",
]
outputs = [ "$target_gen_dir/__config" ]
args = [
"$target_gen_dir/__config_site",
"__config",
"-o",
"$target_gen_dir/__config",
]
deps = [ ":write_config" ]
}
copy("copy_config") {
sources = [ "$target_gen_dir/__config" ]
outputs = [ "$clang_resource_dir/include/c++/v1/{{source_file_part}}" ]
deps = [ ":concat_config" ]
}
}
copy("include") {
sources = [
"__bit_reference",
"__bsd_locale_defaults.h",
"__bsd_locale_fallbacks.h",
"__debug",
"__errc",
"__functional_03",
"__functional_base",
"__functional_base_03",
"__hash_table",
"__libcpp_version",
"__locale",
"__mutex_base",
"__node_handle",
"__nullptr",
"__split_buffer",
"__sso_allocator",
"__std_stream",
"__string",
"__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",
"condition_variable",
"csetjmp",
"csignal",
"cstdarg",
"cstdbool",
"cstddef",
"cstdint",
"cstdio",
"cstdlib",
"cstring",
"ctgmath",
"ctime",
"ctype.h",
"cwchar",
"cwctype",
"deque",
"errno.h",
"exception",
"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",
"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",
"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 = []
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 {
deps += [ ":copy_config" ]
}
if (libcxx_install_support_headers) {
sources += [
"support/android/locale_bionic.h",
"support/fuchsia/xlocale.h",
"support/ibm/limits.h",
"support/ibm/locale_mgmt_aix.h",
"support/ibm/support.h",
"support/ibm/xlocale.h",
"support/musl/xlocale.h",
"support/newlib/xlocale.h",
"support/solaris/floatingpoint.h",
"support/solaris/wchar.h",
"support/solaris/xlocale.h",
"support/xlocale/__nop_locale_mgmt.h",
"support/xlocale/__posix_l_fallback.h",
"support/xlocale/__strtonum_fallback.h",
]
if (target_os == "win") {
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_install_support_headers) {
sources += [
"support/win32/limits_msvc_win32.h",
"support/win32/locale_win32.h",
"support/android/locale_bionic.h",
"support/fuchsia/xlocale.h",
"support/ibm/limits.h",
"support/ibm/locale_mgmt_aix.h",
"support/ibm/support.h",
"support/ibm/xlocale.h",
"support/musl/xlocale.h",
"support/newlib/xlocale.h",
"support/solaris/floatingpoint.h",
"support/solaris/wchar.h",
"support/solaris/xlocale.h",
"support/xlocale/__nop_locale_mgmt.h",
"support/xlocale/__posix_l_fallback.h",
"support/xlocale/__strtonum_fallback.h",
]
if (target_os == "win") {
sources += [
"support/win32/limits_msvc_win32.h",
"support/win32/locale_win32.h",
]
}
}
outputs = [ "$libcxx_generated_include_dir/{{source_target_relative}}" ]
}
outputs = [ "$root_build_dir/include/c++/v1/{{source_target_relative}}" ]
}
config("include_config") {
include_dirs = [ libcxx_generated_include_dir ]
}
group("include") {
if (current_toolchain == default_toolchain) {
deps = [
":copy_headers",
":write_config_site",
]
}
public_configs = [ ":include_config" ]
}

View File

@ -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",
@ -203,6 +201,7 @@ if (libcxx_enable_shared) {
sources = cxx_sources
deps = [
"//compiler-rt/lib/builtins",
"//libcxx/include",
"//libcxxabi/src:cxxabi_shared",
"//libunwind/src:unwind_shared",
]
@ -252,6 +251,7 @@ if (libcxx_enable_static) {
}
deps = [
"//compiler-rt/lib/builtins",
"//libcxx/include",
"//libcxxabi/src:cxxabi_static",
"//libunwind/src:unwind_static",
]
@ -268,6 +268,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",

View File

@ -59,10 +59,7 @@ if (target_os == "linux" || target_os == "fuchsia") {
}
config("cxxabi_config") {
include_dirs = [
"//libcxxabi/include",
"//libcxx/include",
]
include_dirs = [ "//libcxxabi/include" ]
cflags_cc = [ "-nostdinc++" ]
defines = [ "_LIBCXXABI_BUILDING_LIBRARY" ]
if (target_os == "win") {
@ -86,6 +83,7 @@ if (libcxxabi_enable_shared) {
public = cxxabi_headers
deps = [
"//compiler-rt/lib/builtins",
"//libcxx/include",
"//libunwind/src:unwind_shared",
]
configs += [ ":cxxabi_config" ]
@ -116,6 +114,7 @@ if (libcxxabi_enable_static) {
}
deps = [
"//compiler-rt/lib/builtins",
"//libcxx/include",
"//libunwind/src:unwind_static",
]
configs += [ ":cxxabi_config" ]