Index: libcxx/trunk/CMakeLists.txt =================================================================== --- libcxx/trunk/CMakeLists.txt +++ libcxx/trunk/CMakeLists.txt @@ -138,8 +138,7 @@ # Setup the default options if LIBCXX_CXX_ABI is not specified. if (LIBCXX_CXX_ABI STREQUAL "default") find_path( - LIBCXX_LIBCXXABI_INCLUDES_INTERNAL - cxxabi.h + LIBCXX_LIBCXXABI_INCLUDES_INTERNAL cxxabi.h PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include Index: llvm/trunk/utils/gn/secondary/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/BUILD.gn +++ llvm/trunk/utils/gn/secondary/BUILD.gn @@ -13,6 +13,7 @@ if (current_os == "linux") { deps += [ "//compiler-rt", + "//libcxx", "//libcxxabi", "//libunwind", ] Index: llvm/trunk/utils/gn/secondary/libcxx/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/libcxx/BUILD.gn +++ llvm/trunk/utils/gn/secondary/libcxx/BUILD.gn @@ -0,0 +1,6 @@ +group("libcxx") { + deps = [ + "include", + "src(//llvm/utils/gn/build/toolchain:stage2_unix)", + ] +} Index: llvm/trunk/utils/gn/secondary/libcxx/include/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/libcxx/include/BUILD.gn +++ llvm/trunk/utils/gn/secondary/libcxx/include/BUILD.gn @@ -0,0 +1,276 @@ +import("//clang/resource_dir.gni") +import("//libcxx/config.gni") +import("//llvm/utils/gn/build/write_cmake_config.gni") + +declare_args() { + # Install libc++ support headers. + libcxx_install_support_headers = true +} + +libcxx_needs_site_config = + libcxx_abi_version != 1 || libcxx_abi_namespace != "" || libcxx_abi_unstable + +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=" ] + } + } + + # 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", + ] + } + + 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", + "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/any", + "experimental/chrono", + "experimental/coroutine", + "experimental/deque", + "experimental/filesystem", + "experimental/forward_list", + "experimental/functional", + "experimental/iterator", + "experimental/list", + "experimental/map", + "experimental/memory_resource", + "experimental/numeric", + "experimental/optional", + "experimental/propagate_const", + "experimental/ratio", + "experimental/regex", + "experimental/set", + "experimental/simd", + "experimental/string", + "experimental/string_view", + "experimental/system_error", + "experimental/tuple", + "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", + "limits", + "limits.h", + "list", + "locale", + "locale.h", + "map", + "math.h", + "memory", + "module.modulemap", + "mutex", + "new", + "numeric", + "optional", + "ostream", + "queue", + "random", + "ratio", + "regex", + "scoped_allocator", + "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 = [ + "//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") { + sources += [ + "support/win32/limits_msvc_win32.h", + "support/win32/locale_win32.h", + ] + } + } + outputs = [ + "$clang_resource_dir/include/c++/v1/{{source_target_relative}}", + ] +} + +copy("cxxabi_include") { + sources = [ + "//libcxxabi/include/__cxxabi_config.h", # ignore for sync script + "//libcxxabi/include/cxxabi.h", # ignore for sync script + ] + outputs = [ + "$clang_resource_dir/include/c++/v1/{{source_target_relative}}", + ] +} Index: llvm/trunk/utils/gn/secondary/libcxx/src/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/libcxx/src/BUILD.gn +++ llvm/trunk/utils/gn/secondary/libcxx/src/BUILD.gn @@ -0,0 +1,301 @@ +import("//clang/runtimes.gni") +import("//llvm/utils/gn/build/symlink_or_copy.gni") + +declare_args() { + # Build libc++ with definitions for operator new/delete. + libcxx_enable_new_delete_definitions = true + + # Build libc++ as a shared library. + libcxx_enable_shared = true + + # Build libc++ as a static library. + libcxx_enable_static = true + + # Build filesystem as part of libc++fs.a. + libcxx_enable_filesystem = target_os != "win" + + # Build libc++experimental.a. + libcxx_enable_experimental = true + + # Use compiler-rt builtins. + libcxx_use_compiler_rt = true + + # Use exceptions. + libcxx_enable_exceptions = true + + # Use run time type information. + libcxx_enable_rtti = true + + # Do not export any symbols from the static library. + libcxx_hermetic_static_library = true + + # Use and install a linker script for the given ABI library. + libcxx_enable_abi_linker_script = true +} + +config("cxx_config") { + include_dirs = [ + "//libcxxabi/include", + "//libcxx/include", + ] + cflags = [ + "-Wall", + "-Wextra", + "-W", + "-Wwrite-strings", + "-Wno-unused-parameter", + "-Wno-long-long", + "-Werror=return-type", + "-Wextra-semi", + "-Wno-user-defined-literals", + "-Wno-covered-switch-default", + ] + cflags_cc = [ "-nostdinc++" ] + if (target_os == "win") { + cflags_cc += [ "/std:c++11" ] + } else { + cflags_cc += [ "-std=c++11" ] + } + defines = [ "_LIBCPP_BUILDING_LIBRARY" ] + if (target_os == "win") { + cflags += [ "/Zl" ] + defines += [ + # Ignore the -MSC_VER mismatch, as we may build + # with a different compatibility version. + "_ALLOW_MSC_VER_MISMATCH", + + # Don't check the msvcprt iterator debug levels + # as we will define the iterator types; libc++ + # uses a different macro to identify the debug + # level. + "_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH", + + # We are building the c++ runtime, don't pull in + # msvcprt. + "_CRTBLD", + + # Don't warn on the use of "deprecated" + # "insecure" functions which are standards + # specified. + "_CRT_SECURE_NO_WARNINGS", + + # Use the ISO conforming behaviour for conversion + # in printf, scanf. + "_CRT_STDIO_ISO_WIDE_SPECIFIERS", + ] + } + if (libcxx_enable_exceptions) { + if (current_os == "win") { + cflags_cc += [ "/EHsc" ] + } + } else { + if (current_os == "win") { + cflags_cc += [ + "/EHs-", + "/EHa-", + ] + } else { + cflags_cc += [ "-fno-exceptions" ] + } + defines += [ "-D_LIBCPP_NO_EXCEPTIONS" ] + } + if (!libcxx_enable_rtti) { + if (current_os == "win") { + cflags_cc += [ "/GR-" ] + } else { + cflags_cc += [ "-fno-rtti" ] + } + defines += [ "-D_LIBCPP_NO_RTTI" ] + } +} + +cxx_sources = [ + "algorithm.cpp", + "string.cpp", + "ios.cpp", + "condition_variable.cpp", + "hash.cpp", + "random.cpp", + "new.cpp", + "functional.cpp", + "exception.cpp", + "support/runtime/exception_msvc.ipp", + "support/runtime/exception_libcxxabi.ipp", + "support/runtime/exception_glibcxx.ipp", + "support/runtime/new_handler_fallback.ipp", + "support/runtime/exception_libcxxrt.ipp", + "support/runtime/exception_pointer_unimplemented.ipp", + "support/runtime/exception_pointer_cxxabi.ipp", + "support/runtime/exception_pointer_msvc.ipp", + "support/runtime/exception_fallback.ipp", + "support/runtime/exception_pointer_glibcxx.ipp", + "variant.cpp", + "shared_mutex.cpp", + "optional.cpp", + "strstream.cpp", + "include/apple_availability.h", + "include/refstring.h", + "include/config_elast.h", + "include/atomic_support.h", + "future.cpp", + "system_error.cpp", + "bind.cpp", + "iostream.cpp", + "stdexcept.cpp", + "valarray.cpp", + "chrono.cpp", + "typeinfo.cpp", + "locale.cpp", + "debug.cpp", + "charconv.cpp", + "utility.cpp", + "regex.cpp", + "mutex.cpp", + "any.cpp", + "thread.cpp", + "vector.cpp", + "memory.cpp", +] +if (target_os == "win") { + cxx_sources += [ + "support/win32/locale_win32.cpp", + "support/win32/support.cpp", + "support/win32/thread_win32.cpp", + ] +} +if (target_os == "solaris") { + cxx_sources += [ + # This comment prevents `gn format` from putting the file on the same line + # as `sources +=`, for sync_source_lists_from_cmake.py. + "support/solaris/xlocale.cpp", + ] +} +if (libcxx_enable_filesystem) { + cxx_sources += [ + "filesystem/directory_iterator.cpp", + "filesystem/filesystem_common.h", + "filesystem/operations.cpp", + ] + if (libcxx_use_compiler_rt) { + cxx_sources += [ + # This comment prevents `gn format` from putting the file on the same line + # as `sources +=`, for sync_source_lists_from_cmake.py. + "filesystem/int128_builtins.cpp", + ] + } +} + +if (libcxx_enable_shared) { + shared_library("cxx_shared") { + output_dir = runtimes_dir + output_name = "c++" + if (libcxx_enable_abi_linker_script) { + output_extension = "so.0" + } + if (target_os == "linux" || target_os == "mac") { + cflags = [ "-fPIC" ] + ldflags = [ "-nostdlib++" ] + libs = [ + "dl", + "pthread", + ] + } + sources = cxx_sources + deps = [ + "//compiler-rt/lib/builtins", + "//libcxxabi/src:cxxabi_shared", + "//libunwind/src:unwind_shared", + ] + configs += [ ":cxx_config" ] + configs -= [ + "//llvm/utils/gn/build:no_exceptions", + "//llvm/utils/gn/build:no_rtti", + ] + } + + symlink_or_copy("cxx_symlink") { + deps = [ + ":cxx_shared", + ] + source = "libc++.so.0" + output = "$runtimes_dir/libc++.so" + } + + if (libcxx_enable_abi_linker_script) { + action("cxx_linker_script") { + script = "//libcxx/utils/gen_link_script.py" + outputs = [ + "$runtimes_dir/libc++.so", + ] + args = [ + "--input", + "$runtimes_dir/libc++.so.0", + "--output", + "$runtimes_dir/libc++.so", + "c++abi", + "unwind", + ] + deps = [ + ":cxx_symlink", + ] + } + } +} + +if (libcxx_enable_static) { + static_library("cxx_static") { + output_dir = runtimes_dir + output_name = "c++" + complete_static_lib = true + configs -= [ "//llvm/utils/gn/build:thin_archive" ] + sources = cxx_sources + if (libcxx_hermetic_static_library) { + cflags = [ "-fvisibility=hidden" ] + cflags_cc = [ "-fvisibility-global-new-delete-hidden" ] + defines = [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ] + } + deps = [ + "//compiler-rt/lib/builtins", + "//libcxxabi/src:cxxabi_static", + "//libunwind/src:unwind_static", + ] + configs += [ ":cxx_config" ] + configs -= [ + "//llvm/utils/gn/build:no_exceptions", + "//llvm/utils/gn/build:no_rtti", + ] + } +} + +if (libcxx_enable_experimental) { + static_library("cxx_experimental") { + output_dir = runtimes_dir + output_name = "c++experimental" + cflags_cc = [ "-std=c++14" ] + sources = [ + "experimental/memory_resource.cpp", + ] + configs += [ ":cxx_config" ] + configs -= [ + "//llvm/utils/gn/build:no_exceptions", + "//llvm/utils/gn/build:no_rtti", + ] + } +} + +group("src") { + deps = [] + if (libcxx_enable_shared) { + if (libcxx_enable_abi_linker_script) { + deps += [ ":cxx_linker_script" ] + } else { + deps += [ ":cxx_shared" ] + } + } + if (libcxx_enable_static) { + deps += [ ":cxx_static" ] + } + if (libcxx_enable_experimental) { + deps += [ ":cxx_experimental" ] + } +}