Index: compiler-rt/CMakeLists.txt =================================================================== --- compiler-rt/CMakeLists.txt +++ compiler-rt/CMakeLists.txt @@ -457,7 +457,7 @@ append_list_if(MINGW -fms-extensions SANITIZER_COMMON_CFLAGS) # Set common link flags. -append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS) +append_list_if(C_SUPPORTS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS) append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS) if (COMPILER_RT_USE_BUILTINS_LIBRARY) Index: compiler-rt/cmake/config-ix.cmake =================================================================== --- compiler-rt/cmake/config-ix.cmake +++ compiler-rt/cmake/config-ix.cmake @@ -23,8 +23,8 @@ endif() endif() -check_c_compiler_flag(-nodefaultlibs COMPILER_RT_HAS_NODEFAULTLIBS_FLAG) -if (COMPILER_RT_HAS_NODEFAULTLIBS_FLAG) +check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG) +if (C_SUPPORTS_NODEFAULTLIBS_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") if (COMPILER_RT_HAS_LIBC) list(APPEND CMAKE_REQUIRED_LIBRARIES c) Index: libcxx/CMakeLists.txt =================================================================== --- libcxx/CMakeLists.txt +++ libcxx/CMakeLists.txt @@ -344,8 +344,12 @@ option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" ${LIBCXX_CONFIGURE_IDE_DEFAULT}) +set(LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT OFF) +if (WIN32) + set(LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT ON) +endif() option(LIBCXX_HERMETIC_STATIC_LIBRARY - "Do not export any symbols from the static library." OFF) + "Do not export any symbols from the static library." ${LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT}) #=============================================================================== # Check option configurations @@ -593,7 +597,7 @@ target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) endif() - if (LIBCXX_HAS_COMMENT_LIB_PRAGMA) + if (C_SUPPORTS_COMMENT_LIB_PRAGMA) if (LIBCXX_HAS_PTHREAD_LIB) target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB) endif() @@ -774,7 +778,7 @@ # Unfortunately this cannot be used universally because for example g++ supports # only -nodefaultlibs in which case all libraries will be removed and # all libraries but c++ have to be added in manually. - if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG) + if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++") else() target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs") @@ -782,7 +786,7 @@ target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") endif() - if (LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER) + if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER) # If we're linking directly against the libunwind that we're building # in the same invocation, don't try to link in the toolchain's # default libunwind (which may be missing still). @@ -934,7 +938,10 @@ # By default libc++ on Windows expects to use a shared library, which requires # the headers to use DLL import/export semantics. However when building a # static library only we modify the headers to disable DLL import/export. -if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) +if (MINGW) # AND NOT LIBCXX_ENABLE_DLLIMPORT ? + message(STATUS "Generating custom __config that skips dllimport") + config_define(ON _LIBCPP_DISABLE_DLLIMPORT) +elseif (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) message(STATUS "Generating custom __config for non-DLL Windows build") config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) endif() Index: libcxx/cmake/Modules/HandleLibCXXABI.cmake =================================================================== --- libcxx/cmake/Modules/HandleLibCXXABI.cmake +++ libcxx/cmake/Modules/HandleLibCXXABI.cmake @@ -102,8 +102,16 @@ set(shared c++abi) set(static c++abi) else() - set(shared cxxabi_shared) - set(static cxxabi_static) + if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) + set(shared cxxabi_shared_objects) + else() + set(shared cxxabi_shared) + endif() + if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY) + set(static cxxabi_static_objects) + else() + set(static cxxabi_static) + endif() endif() setup_abi_lib( Index: libcxx/cmake/Modules/HandleLibcxxFlags.cmake =================================================================== --- libcxx/cmake/Modules/HandleLibcxxFlags.cmake +++ libcxx/cmake/Modules/HandleLibcxxFlags.cmake @@ -42,7 +42,7 @@ macro(check_flag_supported flag) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") endmacro() macro(append_flags DEST) @@ -63,8 +63,8 @@ macro(append_flags_if_supported DEST) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") - append_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag}) endforeach() endmacro() @@ -127,8 +127,8 @@ macro(add_target_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") - add_target_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -154,8 +154,8 @@ macro(add_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") - add_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -179,8 +179,8 @@ macro(add_compile_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") - add_compile_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -204,8 +204,8 @@ macro(add_link_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") - add_link_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -234,8 +234,8 @@ function(target_add_link_flags_if_supported target visibility) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") - if (LIBCXX_SUPPORTS_${flagname}_FLAG) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + if (CXX_SUPPORTS_${flagname}_FLAG) target_link_libraries(${target} ${visibility} ${flag}) endif() endforeach() @@ -246,8 +246,8 @@ function(target_add_compile_flags_if_supported target visibility) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") - if (LIBCXX_SUPPORTS_${flagname}_FLAG) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + if (CXX_SUPPORTS_${flagname}_FLAG) target_compile_options(${target} ${visibility} ${flag}) endif() endforeach() Index: libcxx/cmake/config-ix.cmake =================================================================== --- libcxx/cmake/config-ix.cmake +++ libcxx/cmake/config-ix.cmake @@ -12,8 +12,8 @@ # libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly # built libunwind isn't installed yet). For those cases, it'd be good to # link with --uwnindlib=none. Check if that option works. -llvm_check_compiler_linker_flag(C "--unwindlib=none" LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG) -if (LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG) +llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) +if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none") endif() @@ -46,17 +46,17 @@ # required for the link to go through. We remove sanitizers from the # configuration checks to avoid spurious link errors. -check_c_compiler_flag(-nostdlib++ LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG) -if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG) +check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") else() - check_c_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) - if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) + check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (C_SUPPORTS_NODEFAULTLIBS_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") endif() endif() -if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) if (LIBCXX_HAS_C_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () @@ -98,7 +98,7 @@ check_c_source_compiles(" #pragma comment(lib, \"c\") int main() { return 0; } -" LIBCXX_HAS_COMMENT_LIB_PRAGMA) +" C_SUPPORTS_COMMENT_LIB_PRAGMA) cmake_pop_check_state() endif() Index: libcxx/include/__config =================================================================== --- libcxx/include/__config +++ libcxx/include/__config @@ -530,7 +530,7 @@ # define _LIBCPP_CRT_FUNC #endif -#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(_LIBCPP_DISABLE_DLLIMPORT) && !defined(_LIBCPP_BUILDING_LIBRARY)) # define _LIBCPP_DLL_VIS # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS Index: libcxx/include/__config_site.in =================================================================== --- libcxx/include/__config_site.in +++ libcxx/include/__config_site.in @@ -22,6 +22,7 @@ #cmakedefine _LIBCPP_HAS_THREAD_API_WIN32 #cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#cmakedefine _LIBCPP_DISABLE_DLLIMPORT #cmakedefine _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS #cmakedefine _LIBCPP_NO_VCRUNTIME #cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@ Index: libcxx/src/CMakeLists.txt =================================================================== --- libcxx/src/CMakeLists.txt +++ libcxx/src/CMakeLists.txt @@ -231,8 +231,8 @@ if (LIBCXXABI_USE_LLVM_UNWINDER) if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) target_link_libraries(cxx_shared PUBLIC unwind_shared) - elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) - # libunwind is already included in libc++abi + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared_objects OR HAVE_LIBUNWIND)) + target_link_libraries(cxx_shared PUBLIC unwind_shared_objects) else() target_link_libraries(cxx_shared PUBLIC unwind) endif() @@ -240,11 +240,7 @@ # Link against libc++abi if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) - if (APPLE) - target_link_libraries(cxx_shared PRIVATE "-Wl,-force_load" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}") - else() - target_link_libraries(cxx_shared PRIVATE "-Wl,--whole-archive,-Bstatic" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" "-Wl,-Bdynamic,--no-whole-archive") - endif() + target_link_libraries(cxx_shared PRIVATE "${LIBCXX_CXX_SHARED_ABI_LIBRARY}") else() target_link_libraries(cxx_shared PUBLIC "${LIBCXX_CXX_SHARED_ABI_LIBRARY}") endif() @@ -317,41 +313,54 @@ append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) endif() target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS}) - target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) + target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=) + endif() + + # Link against LLVM libunwind + if (LIBCXXABI_USE_LLVM_UNWINDER) + if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) + target_link_libraries(cxx_static PUBLIC unwind_shared) + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static_objects OR HAVE_LIBUNWIND)) + target_link_libraries(cxx_static PUBLIC unwind_static_objects) + else() + target_link_libraries(cxx_static PUBLIC unwind) + endif() endif() list(APPEND LIBCXX_BUILD_TARGETS "cxx_static") # Attempt to merge the libc++.a archive and the ABI library archive into one. if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY) - set(MERGE_ARCHIVES_SEARCH_PATHS "") - if (LIBCXX_CXX_ABI_LIBRARY_PATH) - set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") - endif() if (TARGET "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" OR HAVE_LIBCXXABI) - set(MERGE_ARCHIVES_ABI_TARGET "$") + target_link_libraries(cxx_static PRIVATE "${LIBCXX_CXX_STATIC_ABI_LIBRARY}") else() set(MERGE_ARCHIVES_ABI_TARGET "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_STATIC_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}") if (LIBCXX_CXX_ABI_LIBRARY_PATH) set(MERGE_ARCHIVES_ABI_TARGET "${LIBCXX_CXX_ABI_LIBRARY_PATH}/${MERGE_ARCHIVES_ABI_TARGET}") endif () + + set(MERGE_ARCHIVES_SEARCH_PATHS "") + if (LIBCXX_CXX_ABI_LIBRARY_PATH) + set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") + endif() + + if (APPLE) + set(MERGE_ARCHIVES_LIBTOOL "--use-libtool" "--libtool" "${CMAKE_LIBTOOL}") + endif() + add_custom_command(TARGET cxx_static POST_BUILD + COMMAND + ${Python3_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/merge_archives.py + ARGS + -o $ + --ar "${CMAKE_AR}" + ${MERGE_ARCHIVES_LIBTOOL} + "$" + "${MERGE_ARCHIVES_ABI_TARGET}" + "${MERGE_ARCHIVES_SEARCH_PATHS}" + WORKING_DIRECTORY ${LIBCXX_BUILD_DIR} + DEPENDS ${MERGE_ARCHIVES_ABI_TARGET} + ) endif() - if (APPLE) - set(MERGE_ARCHIVES_LIBTOOL "--use-libtool" "--libtool" "${CMAKE_LIBTOOL}") - endif() - add_custom_command(TARGET cxx_static POST_BUILD - COMMAND - ${Python3_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/merge_archives.py - ARGS - -o $ - --ar "${CMAKE_AR}" - ${MERGE_ARCHIVES_LIBTOOL} - "$" - "${MERGE_ARCHIVES_ABI_TARGET}" - "${MERGE_ARCHIVES_SEARCH_PATHS}" - WORKING_DIRECTORY ${LIBCXX_BUILD_DIR} - DEPENDS ${MERGE_ARCHIVES_ABI_TARGET} - ) endif() endif() Index: libcxx/test/support/test_macros.h =================================================================== --- libcxx/test/support/test_macros.h +++ libcxx/test/support/test_macros.h @@ -306,8 +306,7 @@ #define TEST_NOT_WIN32(...) __VA_ARGS__ #endif -#if (defined(_WIN32) && !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)) || \ - defined(__MVS__) || defined(_AIX) +#if defined(TEST_WINDOWS_DLL) ||defined(__MVS__) || defined(_AIX) // Macros for waiving cases when we can't count allocations done within // the library implementation. // @@ -325,8 +324,7 @@ #define TEST_SUPPORTS_LIBRARY_INTERNAL_ALLOCATIONS 1 #endif -#if (defined(_WIN32) && !defined(_MSC_VER) && \ - !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)) || \ +#if (defined(TEST_WINDOWS_DLL) && !defined(_MSC_VER)) || \ defined(__MVS__) // Normally, a replaced e.g. 'operator new' ends up used if the user code // does a call to e.g. 'operator new[]'; it's enough to replace the base Index: libcxx/utils/ci/buildkite-pipeline.yml =================================================================== --- libcxx/utils/ci/buildkite-pipeline.yml +++ libcxx/utils/ci/buildkite-pipeline.yml @@ -18,541 +18,6 @@ # steps: - # - # Light pre-commit tests for things like formatting or when people forget - # to update generated files. - # - - label: "Format" - command: "libcxx/utils/ci/run-buildbot check-format" - artifact_paths: - - "**/clang-format.patch" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - soft_fail: - - exit_status: 1 - timeout_in_minutes: 120 - - - label: "Generated output" - command: "libcxx/utils/ci/run-buildbot check-generated-output" - artifact_paths: - - "**/generated_output.patch" - - "**/generated_output.status" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Documentation" - command: "libcxx/utils/ci/run-buildbot documentation" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # - # General testing with the default configuration, under all the supported - # Standard modes, with Clang and GCC. This catches most issues upfront. - # The goal of this step is to catch most issues while being very fast. - # - - wait - - - label: "C++2b" - command: "libcxx/utils/ci/run-buildbot generic-cxx2b" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "C++11" - command: "libcxx/utils/ci/run-buildbot generic-cxx11" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "C++03" - command: "libcxx/utils/ci/run-buildbot generic-cxx03" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Modular build" - command: "libcxx/utils/ci/run-buildbot generic-modules" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "GCC 11 / C++latest" - command: "libcxx/utils/ci/run-buildbot generic-gcc" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # - # All other supported configurations of libc++. - # - - wait - - - label: "C++20" - command: "libcxx/utils/ci/run-buildbot generic-cxx20" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "C++17" - command: "libcxx/utils/ci/run-buildbot generic-cxx17" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "C++14" - command: "libcxx/utils/ci/run-buildbot generic-cxx14" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Tests with the supported compilers. - - label: "GCC 11 / C++11" - command: "libcxx/utils/ci/run-buildbot generic-gcc-cxx11" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Clang 13" - command: "libcxx/utils/ci/run-buildbot generic-clang-13" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Clang 14" - command: "libcxx/utils/ci/run-buildbot generic-clang-14" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Tests with the sanitizers. - - group: "Sanitizers" - steps: - - label: "ASAN" - command: "libcxx/utils/ci/run-buildbot generic-asan" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "TSAN" - command: "libcxx/utils/ci/run-buildbot generic-tsan" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "UBSAN" - command: "libcxx/utils/ci/run-buildbot generic-ubsan" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "MSAN" - command: "libcxx/utils/ci/run-buildbot generic-msan" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Tests with the various supported ways to build libc++. - - label: "Bootstrapping build" - command: "libcxx/utils/ci/run-buildbot bootstrapping-build" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - group: "Legacy" - steps: - - label: "Legacy Lit configuration" - command: "libcxx/utils/ci/run-buildbot legacy-test-config" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Legacy LLVM_ENABLE_PROJECTS build" - command: "libcxx/utils/ci/run-buildbot legacy-project-build" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Tests with various build configurations. - - - label: "Static libraries" - command: "libcxx/utils/ci/run-buildbot generic-static" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Assertions enabled" - command: "libcxx/utils/ci/run-buildbot generic-assertions" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Debug iterators" - command: "libcxx/utils/ci/run-buildbot generic-debug-iterators" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "With LLVM's libunwind" - command: "libcxx/utils/ci/run-buildbot generic-with_llvm_unwinder" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - group: "Parts disabled" - steps: - - label: "No threads" - command: "libcxx/utils/ci/run-buildbot generic-singlethreaded" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No debug mode" - command: "libcxx/utils/ci/run-buildbot generic-no-debug" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No filesystem" - command: "libcxx/utils/ci/run-buildbot generic-no-filesystem" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No random device" - command: "libcxx/utils/ci/run-buildbot generic-no-random_device" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No locale" - command: "libcxx/utils/ci/run-buildbot generic-no-localization" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No Unicode" - command: "libcxx/utils/ci/run-buildbot generic-no-unicode" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No wide characters" - command: "libcxx/utils/ci/run-buildbot generic-no-wide-characters" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No experimental features" - command: "libcxx/utils/ci/run-buildbot generic-no-experimental" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "No exceptions" - command: "libcxx/utils/ci/run-buildbot generic-noexceptions" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Unstable ABI" - command: "libcxx/utils/ci/run-buildbot generic-abi-unstable" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Other non-testing CI jobs - - label: "Benchmarks" - command: "libcxx/utils/ci/run-buildbot benchmarks" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "linux" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Tests on non-Unix platforms - - group: ":windows: Windows" - steps: - label: "Clang-cl (DLL)" command: "bash libcxx/utils/ci/run-buildbot clang-cl-dll" artifact_paths: @@ -604,217 +69,3 @@ - exit_status: -1 # Agent was lost limit: 2 timeout_in_minutes: 120 - - - group: ":apple: Apple" - steps: - - label: "MacOS x86_64" - command: "libcxx/utils/ci/run-buildbot generic-cxx20" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "macos" - arch: "x86_64" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "MacOS arm64" - command: "libcxx/utils/ci/run-buildbot generic-cxx20" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "macos" - arch: "arm64" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Build with the configuration we use to generate libc++.dylib on Apple platforms - - label: "Apple system" - command: "libcxx/utils/ci/run-buildbot apple-system" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "macos" - arch: "arm64" # This can technically run on any architecture, but we have more resources on arm64 so we pin this job to arm64 - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - # Test back-deployment to older Apple platforms - - label: "Apple back-deployment macosx10.9" - command: "libcxx/utils/ci/run-buildbot apple-system-backdeployment-10.9" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "macos" - arch: "x86_64" # We need to use x86_64 for back-deployment CI, since the old dylibs were compiled for x86_64 - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Apple back-deployment macosx10.15" - command: "libcxx/utils/ci/run-buildbot apple-system-backdeployment-10.15" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "macos" - arch: "x86_64" # We need to use x86_64 for back-deployment CI, since the old dylibs were compiled for x86_64 - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Apple back-deployment macosx11.0 arm64" - command: "libcxx/utils/ci/run-buildbot apple-system-backdeployment-11.0" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - os: "macos" - arch: "arm64" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - group: "ARM" - steps: - - label: "AArch64" - command: "libcxx/utils/ci/run-buildbot aarch64" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "aarch64" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "AArch64 -fno-exceptions" - command: "libcxx/utils/ci/run-buildbot aarch64-noexceptions" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "aarch64" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Armv8" - command: "libcxx/utils/ci/run-buildbot armv8" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Armv8 -fno-exceptions" - command: "libcxx/utils/ci/run-buildbot armv8-noexceptions" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Armv7" - command: "libcxx/utils/ci/run-buildbot armv7" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" # Compiling for v7, running on v8 hardware - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "Armv7 -fno-exceptions" - command: "libcxx/utils/ci/run-buildbot armv7-noexceptions" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" # Compiling for v7, running on v8 hardware - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - group: "AIX" - steps: - - label: "AIX (32-bit)" - command: "libcxx/utils/ci/run-buildbot aix" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - env: - OBJECT_MODE: "32" - agents: - queue: libcxx-builders - os: aix - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 - - - label: "AIX (64-bit)" - command: "libcxx/utils/ci/run-buildbot aix" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - env: - OBJECT_MODE: "64" - agents: - queue: libcxx-builders - os: aix - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - timeout_in_minutes: 120 Index: libcxx/utils/ci/run-buildbot =================================================================== --- libcxx/utils/ci/run-buildbot +++ libcxx/utils/ci/run-buildbot @@ -145,6 +145,14 @@ ${NINJA} -vC "${BUILD_DIR}" check-cxx-benchmarks } +function check-static-dllexports() { + echo "+++ Inspecting the built library" + if llvm-readobj --coff-directives "$1" | grep -i "export:" > /dev/null; then + echo "Static library $1 in ${BUILDER} configuration contains dllexport directives" + exit 1 + fi +} + # Print the version of a few tools to aid diagnostics in some cases ${CMAKE} --version ${NINJA} --version @@ -547,12 +555,14 @@ generate-cmake-libcxx-win -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx + check-static-dllexports "${BUILD_DIR}/lib/libc++.lib" ;; clang-cl-static) clean generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx + check-static-dllexports "${BUILD_DIR}/lib/libc++.lib" ;; mingw-dll) clean @@ -567,6 +577,8 @@ -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx + check-static-dllexports "${BUILD_DIR}/lib/libc++.a" + check-static-dllexports "${BUILD_DIR}/lib/libunwind.a" ;; mingw-static) clean @@ -578,6 +590,8 @@ -DLIBUNWIND_ENABLE_SHARED=OFF echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx + check-static-dllexports "${BUILD_DIR}/lib/libc++.a" + check-static-dllexports "${BUILD_DIR}/lib/libunwind.a" ;; aix) export CC=ibm-clang Index: libcxx/utils/libcxx/test/features.py =================================================================== --- libcxx/utils/libcxx/test/features.py +++ libcxx/utils/libcxx/test/features.py @@ -210,7 +210,31 @@ DEFAULT_FEATURES += [ Feature(name='darwin', when=lambda cfg: '__APPLE__' in compilerMacros(cfg)), Feature(name='windows', when=lambda cfg: '_WIN32' in compilerMacros(cfg)), - Feature(name='windows-dll', when=lambda cfg: '_WIN32' in compilerMacros(cfg) and not '_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS' in compilerMacros(cfg)), + Feature(name='windows-dll', when=lambda cfg: '_WIN32' in compilerMacros(cfg) and programSucceeds(cfg, """ + #include + #include + void *ptr; + int main(int, char**) { + ptr = &std::cout; + if (GetModuleHandle("libc++.dll") || GetModuleHandle("c++.dll")) + return 0; + return 1; + } + """), actions=[AddCompileFlag('-DTEST_WINDOWS_DLL')]), +# #include +# #include +# #include +# int main(int, char**) { +# void *ptr = &std::cout; +# void *exe = GetModuleHandle(NULL); +# PIMAGE_DOS_HEADER dosheader = (PIMAGE_DOS_HEADER)exe; +# PIMAGE_NT_HEADERS ntheader = (PIMAGE_NT_HEADERS)((BYTE *)dosheader + dosheader->e_lfanew); +# PIMAGE_OPTIONAL_HEADER peheader = &ntheader->OptionalHeader; +# void *exeend = (BYTE*)exe + peheader->SizeOfImage; +# if (ptr >= exe && ptr <= exeend) +# return 1; +# return 0; +# } Feature(name='linux', when=lambda cfg: '__linux__' in compilerMacros(cfg)), Feature(name='netbsd', when=lambda cfg: '__NetBSD__' in compilerMacros(cfg)), Feature(name='freebsd', when=lambda cfg: '__FreeBSD__' in compilerMacros(cfg)) Index: libcxxabi/CMakeLists.txt =================================================================== --- libcxxabi/CMakeLists.txt +++ libcxxabi/CMakeLists.txt @@ -189,8 +189,12 @@ endif() endif() +set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF) +if (WIN32) + set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT ON) +endif() option(LIBCXXABI_HERMETIC_STATIC_LIBRARY - "Do not export any symbols from the static library." OFF) + "Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT}) set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING "The path to the Lit testing configuration to use when running the tests. @@ -276,7 +280,7 @@ # Configure compiler. Must happen after setting the target flags. include(config-ix) -if (LIBCXXABI_HAS_NOSTDINCXX_FLAG) +if (CXX_SUPPORTS_NOSTDINCXX_FLAG) list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++) # cmake 3.14 and above remove system include paths that are explicitly # passed on the command line. We build with -nostdinc++ and explicitly add @@ -300,25 +304,6 @@ # it is being built as part of libcxx. add_definitions(-D_LIBCPP_BUILDING_LIBRARY) -# Disable DLL annotations on Windows for static builds. -if (WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED) - # If LIBCXX_ENABLE_SHARED isn't set (by the user on the cmake command - # line or via a cache file), use its expected default value (enabled). - if ((LIBCXX_ENABLE_SHARED OR NOT DEFINED LIBCXX_ENABLE_SHARED) AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY) - # Building libcxxabi statically, but intending for it to be statically - # linked into a shared libcxx; keep dllexport enabled within libcxxabi, - # as the symbols will need to be exported from libcxx. - else() - # Regular static build; disable dllexports. - add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) - if (NOT LIBCXXABI_HERMETIC_STATIC_LIBRARY) - # TODO: Enable this warning message as soon as we're sure this is the solution. - # message(WARNING "Implicitly disabling dllexport on Win32 is not supported anymore. Please build with " - # "LIBCXXABI_HERMETIC_STATIC_LIBRARY=ON instead. This will become an error in LLVM 16.") - endif() - endif() -endif() - add_compile_flags_if_supported(-Werror=return-type) # Get warning flags @@ -497,7 +482,7 @@ add_definitions(-DLIBCXXABI_BAREMETAL) endif() -if (LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) +if (C_SUPPORTS_COMMENT_LIB_PRAGMA) if (LIBCXXABI_HAS_PTHREAD_LIB) add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB) endif() Index: libcxxabi/cmake/Modules/HandleLibcxxabiFlags.cmake =================================================================== --- libcxxabi/cmake/Modules/HandleLibcxxabiFlags.cmake +++ libcxxabi/cmake/Modules/HandleLibcxxabiFlags.cmake @@ -41,7 +41,7 @@ macro(check_flag_supported flag) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG") + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") endmacro() macro(append_flags DEST) @@ -62,8 +62,8 @@ macro(append_flags_if_supported DEST) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG") - append_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${DEST} ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag}) endforeach() endmacro() @@ -129,8 +129,8 @@ macro(add_target_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG") - add_target_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -156,8 +156,8 @@ macro(add_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG") - add_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -181,8 +181,8 @@ macro(add_compile_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG") - add_compile_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -191,8 +191,8 @@ macro(add_c_compile_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_c_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG") - add_compile_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag}) + check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG") + add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -216,8 +216,8 @@ macro(add_link_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG") - add_link_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() Index: libcxxabi/cmake/config-ix.cmake =================================================================== --- libcxxabi/cmake/config-ix.cmake +++ libcxxabi/cmake/config-ix.cmake @@ -23,17 +23,17 @@ # required for the link to go through. We remove sanitizers from the # configuration checks to avoid spurious link errors. -check_c_compiler_flag(-nostdlib++ LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG) -if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG) +check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") else() - check_c_compiler_flag(-nodefaultlibs LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG) - if (LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG) + check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG) + if (C_SUPPORTS_NODEFAULTLIBS_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") endif() endif() -if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) if (LIBCXXABI_HAS_C_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () @@ -78,12 +78,12 @@ check_c_source_compiles(" #pragma comment(lib, \"c\") int main() { return 0; } -" LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) +" C_SUPPORTS_COMMENT_LIB_PRAGMA) cmake_pop_check_state() endif() # Check compiler flags -check_cxx_compiler_flag(-nostdinc++ LIBCXXABI_HAS_NOSTDINCXX_FLAG) +check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG) # Check libraries if(FUCHSIA) Index: libcxxabi/src/CMakeLists.txt =================================================================== --- libcxxabi/src/CMakeLists.txt +++ libcxxabi/src/CMakeLists.txt @@ -88,15 +88,16 @@ # FIXME: Is it correct to prefer the static version of libunwind? if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_shared) - elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) - list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_static) + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared_objects OR HAVE_LIBUNWIND)) + list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_shared_objects) else() list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind) endif() - if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) - list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_shared) - elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) - # We handle this by directly merging libunwind objects into libc++abi. + + if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) + list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_static) + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static_objects OR HAVE_LIBUNWIND)) + list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_static_objects) else() list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind) endif() @@ -116,7 +117,7 @@ endif () # Setup flags. -if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) add_link_flags_if_supported(-nostdlib++) else() add_link_flags_if_supported(-nodefaultlibs) @@ -175,25 +176,33 @@ endif() # Build the shared library. -if (LIBCXXABI_ENABLE_SHARED) - add_library(cxxabi_shared SHARED ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) - target_link_libraries(cxxabi_shared PRIVATE cxx-headers ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) - target_link_libraries(cxxabi_shared PUBLIC cxxabi-headers) - if (TARGET pstl::ParallelSTL) - target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL) - endif() - set_target_properties(cxxabi_shared +if (TRUE) + add_library(cxxabi_shared_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) + target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers) + set_target_properties(cxxabi_shared_objects PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD 20 CXX_STANDARD_REQUIRED OFF COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}" + DEFINE_SYMBOL "" + ) +endif() + +if (LIBCXXABI_ENABLE_SHARED) + add_library(cxxabi_shared SHARED $) + set_target_properties(cxxabi_shared + PROPERTIES LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" OUTPUT_NAME "c++abi" SOVERSION "1" VERSION "${LIBCXXABI_LIBRARY_VERSION}" - DEFINE_SYMBOL "" ) + target_link_libraries(cxxabi_shared PRIVATE ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + if (TARGET pstl::ParallelSTL) + target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL) + endif() list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_shared") if (LIBCXXABI_INSTALL_SHARED_LIBRARY) @@ -232,20 +241,15 @@ # Build the static library. if (LIBCXXABI_ENABLE_STATIC) - add_library(cxxabi_static STATIC ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) - target_link_libraries(cxxabi_static PRIVATE cxx-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) - target_link_libraries(cxxabi_static PUBLIC cxxabi-headers) - if (TARGET pstl::ParallelSTL) - target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL) - endif() - set_target_properties(cxxabi_static + add_library(cxxabi_static_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) + target_link_libraries(cxxabi_static_objects PRIVATE cxx-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_static_objects PUBLIC cxxabi-headers) + set_target_properties(cxxabi_static_objects PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD 20 CXX_STANDARD_REQUIRED OFF COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}" - LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" - OUTPUT_NAME "c++abi" ) if(LIBCXXABI_HERMETIC_STATIC_LIBRARY) @@ -256,36 +260,28 @@ if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) append_flags_if_supported(CXXABI_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) endif() - target_compile_options(cxxabi_static PRIVATE ${CXXABI_STATIC_LIBRARY_FLAGS}) - target_compile_definitions(cxxabi_static + target_compile_options(cxxabi_static_objects PRIVATE ${CXXABI_STATIC_LIBRARY_FLAGS}) + target_compile_definitions(cxxabi_static_objects PRIVATE _LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS - _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) + _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=) + endif() + + add_library(cxxabi_static STATIC $) + set_target_properties(cxxabi_static + PROPERTIES + LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" + OUTPUT_NAME "c++abi" + ) + target_link_libraries(cxxabi_static PRIVATE ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + if (TARGET pstl::ParallelSTL) + target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL) endif() list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_static") if (LIBCXXABI_INSTALL_STATIC_LIBRARY) list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_static") endif() - - if (APPLE) - set(MERGE_ARCHIVES_LIBTOOL "--use-libtool" "--libtool" "${CMAKE_LIBTOOL}") - endif() - - # Merge the libc++abi.a and libunwind.a into one. - if(LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) - add_custom_command(TARGET cxxabi_static POST_BUILD - COMMAND ${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/merge_archives.py - ARGS - -o "$" - --ar "${CMAKE_AR}" - ${MERGE_ARCHIVES_LIBTOOL} - "$" - "$" - WORKING_DIRECTORY ${LIBCXXABI_BUILD_DIR} - DEPENDS unwind_static - ) - endif() endif() # Add a meta-target for both libraries. Index: libunwind/CMakeLists.txt =================================================================== --- libunwind/CMakeLists.txt +++ libunwind/CMakeLists.txt @@ -129,8 +129,13 @@ message(FATAL_ERROR "libunwind CET support is not available for MSVC!") endif() +if (WIN32) + set(LIBUNWIND_DEFAULT_HIDE_SYMBOLS TRUE) +else() + set(LIBUNWIND_DEFAULT_HIDE_SYMBOLS FALSE) +endif() option(LIBUNWIND_HIDE_SYMBOLS - "Do not export any symbols from the static library." OFF) + "Do not export any symbols from the static library." ${LIBUNWIND_DEFAULT_HIDE_SYMBOLS}) #=============================================================================== # Configure System @@ -276,7 +281,7 @@ add_compile_flags_if_supported(-funwind-tables) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE}) -if (LIBUNWIND_USES_ARM_EHABI AND NOT LIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG) +if (LIBUNWIND_USES_ARM_EHABI AND NOT CXX_SUPPORTS_FUNWIND_TABLES_FLAG) message(SEND_ERROR "The -funwind-tables flag must be supported " "because this target uses ARM Exception Handling ABI") endif() @@ -285,7 +290,7 @@ add_cxx_compile_flags_if_supported(-fno-rtti) # Ensure that we don't depend on C++ standard library. -if (LIBUNWIND_HAS_NOSTDINCXX_FLAG) +if (CXX_SUPPORTS_NOSTDINCXX_FLAG) list(APPEND LIBUNWIND_COMPILE_FLAGS -nostdinc++) # Remove -stdlib flags to prevent them from causing an unused flag warning. string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") @@ -349,12 +354,7 @@ add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() -# Disable DLL annotations on Windows for static builds. -if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED) - add_definitions(-D_LIBUNWIND_HIDE_SYMBOLS) -endif() - -if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) +if (C_SUPPORTS_COMMENT_LIB_PRAGMA) if (LIBUNWIND_HAS_DL_LIB) add_definitions(-D_LIBUNWIND_LINK_DL_LIB) endif() Index: libunwind/cmake/Modules/HandleLibunwindFlags.cmake =================================================================== --- libunwind/cmake/Modules/HandleLibunwindFlags.cmake +++ libunwind/cmake/Modules/HandleLibunwindFlags.cmake @@ -42,7 +42,7 @@ macro(check_flag_supported flag) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") endmacro() macro(append_flags DEST) @@ -63,8 +63,8 @@ macro(append_flags_if_supported DEST) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") - append_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${DEST} ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag}) endforeach() endmacro() @@ -130,8 +130,8 @@ macro(add_target_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") - add_target_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -157,8 +157,8 @@ macro(add_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") - add_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -182,8 +182,8 @@ macro(add_compile_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") - add_compile_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -207,8 +207,8 @@ macro(add_c_compile_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_c_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") - add_c_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag}) + check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG") + add_c_flags_if(C_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -232,8 +232,8 @@ macro(add_cxx_compile_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") - add_cxx_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_cxx_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() @@ -257,8 +257,8 @@ macro(add_link_flags_if_supported) foreach(flag ${ARGN}) mangle_name("${flag}" flagname) - check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG") - add_link_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag}) + check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") + add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) endforeach() endmacro() Index: libunwind/cmake/config-ix.cmake =================================================================== --- libunwind/cmake/config-ix.cmake +++ libunwind/cmake/config-ix.cmake @@ -9,8 +9,8 @@ # The compiler driver may be implicitly trying to link against libunwind, which # might not work if libunwind doesn't exist yet. Try to check if # --unwindlib=none is supported, and use that if possible. -llvm_check_compiler_linker_flag(C "--unwindlib=none" LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG) -if (LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG) +llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) +if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none") endif() @@ -34,17 +34,17 @@ # required for the link to go through. We remove sanitizers from the # configuration checks to avoid spurious link errors. -llvm_check_compiler_linker_flag(C "-nostdlib++" LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) -if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) +llvm_check_compiler_linker_flag(C "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") else() llvm_check_compiler_linker_flag(C "-nodefaultlibs" LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) - if (LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) + if (C_SUPPORTS_NODEFAULTLIBS_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") endif() endif() -if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG OR LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG) if (LIBUNWIND_HAS_C_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () @@ -89,12 +89,12 @@ check_c_source_compiles(" #pragma comment(lib, \"c\") int main() { return 0; } -" LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) +" C_SUPPORTS_COMMENT_LIB_PRAGMA) cmake_pop_check_state() endif() # Check compiler flags -check_cxx_compiler_flag(-nostdinc++ LIBUNWIND_HAS_NOSTDINCXX_FLAG) +check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG) # Check symbols check_symbol_exists(__arm__ "" LIBUNWIND_TARGET_ARM) Index: libunwind/src/CMakeLists.txt =================================================================== --- libunwind/src/CMakeLists.txt +++ libunwind/src/CMakeLists.txt @@ -83,8 +83,8 @@ endif() # Setup flags. -add_link_flags_if(LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG --unwindlib=none) -if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) +add_link_flags_if(CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG --unwindlib=none) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) add_link_flags_if_supported(-nostdlib++) else() add_link_flags_if_supported(-nodefaultlibs) @@ -94,8 +94,8 @@ add_library_flags_if(MINGW "${MINGW_LIBRARIES}") if (LIBUNWIND_ENABLE_SHARED AND - NOT (LIBUNWIND_SUPPORTS_FNO_EXCEPTIONS_FLAG AND - LIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG)) + NOT (CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG AND + CXX_SUPPORTS_FUNWIND_TABLES_FLAG)) message(FATAL_ERROR "Compiler doesn't support generation of unwind tables if exception " "support is disabled. Building libunwind DSO with runtime dependency " @@ -127,26 +127,31 @@ # Build the shared library. if (LIBUNWIND_ENABLE_SHARED) - add_library(unwind_shared SHARED ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) + add_library(unwind_shared_objects OBJECT ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) if(CMAKE_C_COMPILER_ID STREQUAL MSVC) - target_compile_options(unwind_shared PRIVATE /GR-) + target_compile_options(unwind_shared_objects PRIVATE /GR-) else() - target_compile_options(unwind_shared PRIVATE -fno-rtti) + target_compile_options(unwind_shared_objects PRIVATE -fno-rtti) endif() - target_link_libraries(unwind_shared PRIVATE ${LIBUNWIND_LIBRARIES} - PRIVATE unwind-headers) - set_target_properties(unwind_shared + target_link_libraries(unwind_shared_objects PRIVATE unwind-headers ${LIBUNWIND_LIBRARIES}) + set_target_properties(unwind_shared_objects PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}" - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" LINKER_LANGUAGE C + ) + + add_library(unwind_shared SHARED $) + set_target_properties(unwind_shared + PROPERTIES + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" OUTPUT_NAME "unwind" VERSION "1.0" SOVERSION "1" ) + list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared") if (LIBUNWIND_INSTALL_SHARED_LIBRARY) list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared") @@ -155,32 +160,36 @@ # Build the static library. if (LIBUNWIND_ENABLE_STATIC) - add_library(unwind_static STATIC ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) + add_library(unwind_static_objects OBJECT ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) if(CMAKE_C_COMPILER_ID STREQUAL MSVC) - target_compile_options(unwind_static PRIVATE /GR-) + target_compile_options(unwind_static_objects PRIVATE /GR-) else() - target_compile_options(unwind_static PRIVATE -fno-rtti) + target_compile_options(unwind_static_objects PRIVATE -fno-rtti) endif() - target_link_libraries(unwind_static PRIVATE ${LIBUNWIND_LIBRARIES} - PRIVATE unwind-headers) - set_target_properties(unwind_static + target_link_libraries(unwind_static_objects PRIVATE unwind-headers ${LIBUNWIND_LIBRARIES}) + set_target_properties(unwind_static_objects PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}" - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" LINKER_LANGUAGE C - OUTPUT_NAME "unwind" ) if(LIBUNWIND_HIDE_SYMBOLS) append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility=hidden) append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) - target_compile_options(unwind_static PRIVATE ${UNWIND_STATIC_LIBRARY_FLAGS}) - target_compile_definitions(unwind_static PRIVATE _LIBUNWIND_HIDE_SYMBOLS) + target_compile_options(unwind_static_objects PRIVATE ${UNWIND_STATIC_LIBRARY_FLAGS}) + target_compile_definitions(unwind_static_objects PRIVATE _LIBUNWIND_HIDE_SYMBOLS) endif() + add_library(unwind_static STATIC $) + set_target_properties(unwind_static + PROPERTIES + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" + OUTPUT_NAME "unwind" + ) + list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static") if (LIBUNWIND_INSTALL_STATIC_LIBRARY) list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static") Index: runtimes/CMakeLists.txt =================================================================== --- runtimes/CMakeLists.txt +++ runtimes/CMakeLists.txt @@ -110,12 +110,12 @@ # Check for -nostdlib++ first; if there's no C++ standard library yet, # all check_cxx_compiler_flag commands will fail until we add -nostdlib++ # (or -nodefaultlibs). -llvm_check_compiler_linker_flag(C "-nostdlib++" LLVM_RUNTIMES_SUPPORT_NOSTDLIBXX_FLAG) -if (LLVM_RUNTIMES_SUPPORT_NOSTDLIBXX_FLAG) +llvm_check_compiler_linker_flag(C "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") endif() -check_cxx_compiler_flag(-nostdinc++ LLVM_RUNTIMES_SUPPORT_NOSTDINCXX_FLAG) -if (LLVM_RUNTIMES_SUPPORT_NOSTDINCXX_FLAG) +check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG) +if (CXX_SUPPORTS_NOSTDINCXX_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++") endif()