diff --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn index f1f1f37686e2d5..4d7cdbefb2e600 100644 --- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn +++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn @@ -1,52 +1,68 @@ -import("//clang/resource_dir.gni") import("//libcxx/config.gni") import("//llvm/utils/gn/build/write_cmake_config.gni") -libcxx_needs_site_config = - libcxx_abi_version != 1 || libcxx_abi_namespace != "" || libcxx_abi_unstable +write_cmake_config("write_config") { + input = "__config_site.in" + output = "$target_gen_dir/__config_site" -if (libcxx_needs_site_config) { - write_cmake_config("write_config") { - input = "__config_site.in" - output = "$target_gen_dir/__config_site" - - values = [] - if (libcxx_abi_version != 1) { - values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ] - } - if (libcxx_abi_namespace != "") { - values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ] - } - if (libcxx_abi_unstable) { - values += [ "_LIBCPP_ABI_UNSTABLE=1" ] - } + 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_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS=1", + "_LIBCPP_NO_VCRUNTIME=", + "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=", + "_LIBCPP_ABI_NAMESPACE=", + "_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=" ] } - - # 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 = [ "$target_gen_dir/__config" ] - args = [ - "$target_gen_dir/__config_site", - "__config", - "-o", - "$target_gen_dir/__config", - ] - deps = [ ":write_config" ] + if (libcxx_abi_namespace != "") { + values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ] } - - copy("copy_config") { - sources = [ "$target_gen_dir/__config" ] - outputs = [ "$clang_resource_dir/include/c++/v1/{{source_file_part}}" ] - deps = [ ":concat_config" ] + 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", + "__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" ] +} + copy("include") { sources = [ "__availability", @@ -235,7 +251,7 @@ copy("include") { "wchar.h", "wctype.h", ] - deps = [] + 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 @@ -247,10 +263,5 @@ copy("include") { # don't get copied on macOS due to that. deps += [ "//libcxxabi/include" ] } - if (!libcxx_needs_site_config) { - sources += [ "__config" ] - } else { - deps += [ ":copy_config" ] - } outputs = [ "$root_build_dir/include/c++/v1/{{source_target_relative}}" ] }