diff --git a/libcxx/cmake/caches/MinGW.cmake b/libcxx/cmake/caches/MinGW.cmake new file mode 100644 --- /dev/null +++ b/libcxx/cmake/caches/MinGW.cmake @@ -0,0 +1,20 @@ +set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") +set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "") + +set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "") +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") + +set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") +set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") + +set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") +set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") +set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") + +set(LIBCXX_TARGET_INFO "libcxx.test.target_info.MingwLocalTI" CACHE STRING "") + +# Without these flags, 'long double' (which is 80 bit on x86 mingw, but +# 64 bit in MSVC) isn't handled correctly in printf. +set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO=1" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-D__USE_MINGW_ANSI_STDIO=1" CACHE STRING "") +set(LIBCXX_TEST_COMPILER_FLAGS "-D__USE_MINGW_ANSI_STDIO=1" CACHE STRING "") diff --git a/libcxx/docs/index.rst b/libcxx/docs/index.rst --- a/libcxx/docs/index.rst +++ b/libcxx/docs/index.rst @@ -116,7 +116,7 @@ macOS 10.9+ i386, x86_64, arm64 Building the shared library itself requires targetting macOS 10.11+ FreeBSD 10+ i386, x86_64, arm Linux i386, x86_64, arm, arm64 -Windows x86_64 +Windows x86_64 Both MSVC and MinGW style environments =============== ========================= ============================ Generally speaking, libc++ should work on any platform that provides a fairly complete diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -506,8 +506,8 @@ timeout_in_minutes: 120 # Tests on non-Unix platforms - - label: "Windows (DLL)" - command: "bash libcxx/utils/ci/run-buildbot windows-dll" + - label: "MSVC (DLL)" + command: "bash libcxx/utils/ci/run-buildbot msvc-dll" artifact_paths: - "**/test-results.xml" agents: @@ -518,8 +518,32 @@ limit: 2 timeout_in_minutes: 120 - - label: "Windows (Static)" - command: "bash libcxx/utils/ci/run-buildbot windows-static" + - label: "MSVC (Static)" + command: "bash libcxx/utils/ci/run-buildbot msvc-static" + artifact_paths: + - "**/test-results.xml" + agents: + queue: "windows" + retry: + automatic: + - exit_status: -1 # Agent was lost + limit: 2 + timeout_in_minutes: 120 + + - label: "MinGW (DLL)" + command: "bash libcxx/utils/ci/run-buildbot mingw-dll" + artifact_paths: + - "**/test-results.xml" + agents: + queue: "windows" + retry: + automatic: + - exit_status: -1 # Agent was lost + limit: 2 + timeout_in_minutes: 120 + + - label: "MinGW (Static)" + command: "bash libcxx/utils/ci/run-buildbot mingw-static" artifact_paths: - "**/test-results.xml" agents: diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -601,7 +601,7 @@ -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-shared.cfg.in" check-runtimes ;; -windows-dll) +msvc-dll) clean # TODO: Currently, building with the experimental library breaks running # tests (the test linking look for the c++experimental library with the @@ -613,12 +613,43 @@ echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx ;; -windows-static) +msvc-static) clean generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx ;; +mingw-dll) + clean + # Explicitly specify the compiler with a triple prefix. The CI + # environment has got two installations of Clang; the default one + # defaults to MSVC mode, while there's an installation of llvm-mingw + # further back in PATH. By calling the compiler with an explicit + # triple prefix, we use the one that is bundled with a mingw sysroot. + generate-cmake \ + -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \ + -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \ + -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" + echo "+++ Running the libc++ tests" + ${NINJA} -vC "${BUILD_DIR}" check-cxx +;; +mingw-static) + clean + generate-cmake \ + -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \ + -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \ + -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \ + -DLIBCXX_ENABLE_SHARED=OFF \ + -DLIBUNWIND_ENABLE_SHARED=OFF + # When building a static lib, the cxx build target doesn't have a + # dependency on libunwind. Build libunwind specifically first, so we + # link against that instead of the toolchain's shared libunwind + # (which isn't found when tests are run with a limited PATH). + echo "+++ Building a static libunwind" + ${NINJA} -vC "${BUILD_DIR}" unwind + echo "+++ Running the libc++ tests" + ${NINJA} -vC "${BUILD_DIR}" check-cxx +;; aix) export CC=ibm-clang export CXX=ibm-clang++_r