[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("//libcxx/config.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni") import("//llvm/utils/gn/build/write_cmake_config.gni")
@ -7,56 +6,61 @@ declare_args() {
libcxx_install_support_headers = true libcxx_install_support_headers = true
} }
libcxx_needs_site_config = libcxx_generated_include_dir = "$root_build_dir/include/c++/v1"
libcxx_abi_version != 1 || libcxx_abi_namespace != "" || libcxx_abi_unstable
if (libcxx_needs_site_config) { # This is a bit weird. For now, we assume that __config_site is identical
write_cmake_config("write_config") { # 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" 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) { if (libcxx_abi_version != 1) {
values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ] 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) { if (libcxx_abi_unstable) {
values += [ "_LIBCPP_ABI_UNSTABLE=1" ] values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
} else {
values += [ "_LIBCPP_ABI_UNSTABLE=" ]
} }
} }
# Generate a custom __config header. The new header is created copy("copy_headers") {
# 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 = [ "$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 = [ sources = [
"__bit_reference", "__bit_reference",
"__bsd_locale_defaults.h", "__bsd_locale_defaults.h",
"__bsd_locale_fallbacks.h", "__bsd_locale_fallbacks.h",
"__config",
"__debug", "__debug",
"__errc", "__errc",
"__functional_03", "__functional_03",
@ -225,11 +229,6 @@ copy("include") {
# don't get copied on macOS due to that. # don't get copied on macOS due to that.
deps += [ "//libcxxabi/include" ] deps += [ "//libcxxabi/include" ]
} }
if (!libcxx_needs_site_config) {
sources += [ "__config" ]
} else {
deps += [ ":copy_config" ]
}
if (libcxx_install_support_headers) { if (libcxx_install_support_headers) {
sources += [ sources += [
"support/android/locale_bionic.h", "support/android/locale_bionic.h",
@ -254,5 +253,20 @@ copy("include") {
] ]
} }
} }
outputs = [ "$root_build_dir/include/c++/v1/{{source_target_relative}}" ] outputs = [ "$libcxx_generated_include_dir/{{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("//clang/runtimes.gni")
import("//libcxx/config.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni") import("//llvm/utils/gn/build/symlink_or_copy.gni")
declare_args() { declare_args() {
@ -37,10 +38,7 @@ declare_args() {
} }
config("cxx_config") { config("cxx_config") {
include_dirs = [ include_dirs = [ "//libcxxabi/include" ]
"//libcxxabi/include",
"//libcxx/include",
]
cflags = [ cflags = [
"-Wall", "-Wall",
"-Wextra", "-Wextra",
@ -203,6 +201,7 @@ if (libcxx_enable_shared) {
sources = cxx_sources sources = cxx_sources
deps = [ deps = [
"//compiler-rt/lib/builtins", "//compiler-rt/lib/builtins",
"//libcxx/include",
"//libcxxabi/src:cxxabi_shared", "//libcxxabi/src:cxxabi_shared",
"//libunwind/src:unwind_shared", "//libunwind/src:unwind_shared",
] ]
@ -252,6 +251,7 @@ if (libcxx_enable_static) {
} }
deps = [ deps = [
"//compiler-rt/lib/builtins", "//compiler-rt/lib/builtins",
"//libcxx/include",
"//libcxxabi/src:cxxabi_static", "//libcxxabi/src:cxxabi_static",
"//libunwind/src:unwind_static", "//libunwind/src:unwind_static",
] ]
@ -268,6 +268,7 @@ if (libcxx_enable_experimental) {
output_dir = runtimes_dir output_dir = runtimes_dir
output_name = "c++experimental" output_name = "c++experimental"
sources = [ "experimental/memory_resource.cpp" ] sources = [ "experimental/memory_resource.cpp" ]
deps = [ "//libcxx/include" ]
configs += [ ":cxx_config" ] configs += [ ":cxx_config" ]
configs -= [ configs -= [
"//llvm/utils/gn/build:no_exceptions", "//llvm/utils/gn/build:no_exceptions",

View File

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