From da2af9172e5d4de06dc0a95db9e33b21f02a5b6d Mon Sep 17 00:00:00 2001 From: Chilledheart Date: Mon, 18 Dec 2023 18:35:11 +0800 Subject: [PATCH 1/2] mingw: add MINGW_MSVCRT100 option --- .github/workflows/compiler.yml | 3 --- .github/workflows/releases-mingw.yml | 2 +- third_party/abseil-cpp | 2 +- third_party/boringssl/src | 2 +- third_party/libc++/CMakeLists.txt | 25 ++++++++----------------- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/compiler.yml b/.github/workflows/compiler.yml index ee03c8978..245bfc6f7 100644 --- a/.github/workflows/compiler.yml +++ b/.github/workflows/compiler.yml @@ -239,9 +239,6 @@ jobs: set(CMAKE_CXX_FLAGS "--rtlib=compiler-rt -stdlib=libc++ -Wno-unused-command-line-argument") set(CMAKE_SHARED_LINKER_FLAGS "--rtlib=compiler-rt --unwindlib=libunwind") set(CMAKE_EXE_LINKER_FLAGS "--rtlib=compiler-rt --unwindlib=libunwind") - set(USE_COMPILER_RT TRUE) - set(USE_LIBUNWIND TRUE) - set(COMPILER_RT_PATH "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/lib/clang/16/lib/windows/libclang_rt.builtins-${{ matrix.arch }}.a") # cross compilers to use for C and C++ set(CMAKE_C_COMPILER "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/clang") diff --git a/.github/workflows/releases-mingw.yml b/.github/workflows/releases-mingw.yml index ce565628d..9ae75ac31 100644 --- a/.github/workflows/releases-mingw.yml +++ b/.github/workflows/releases-mingw.yml @@ -125,7 +125,7 @@ jobs: REM start to build with workaround mkdir build-mingw cd build-mingw - cmake -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_BENCHMARKS=on -DBUILD_TESTS=on -DGUI=on -DMINGW_WORKAROUND=on -DUSE_ICU=off .. ${{ env.CMAKE_OPTIONS }} -DCMAKE_C_COMPILER_TARGET=${{ matrix.arch }}-pc-windows-gnu -DCMAKE_CXX_COMPILER_TARGET=${{ matrix.arch }}-pc-windows-gnu -DCMAKE_ASM_COMPILER_TARGET=${{ matrix.arch }}-pc-windows-gnu + cmake -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_BENCHMARKS=on -DBUILD_TESTS=on -DGUI=on -DMINGW_WORKAROUND=on -DUSE_ICU=off .. ${{ env.CMAKE_OPTIONS }} -DCMAKE_C_COMPILER_TARGET=${{ matrix.arch }}-pc-windows-gnu -DCMAKE_CXX_COMPILER_TARGET=${{ matrix.arch }}-pc-windows-gnu -DCMAKE_ASM_COMPILER_TARGET=${{ matrix.arch }}-pc-windows-gnu -DMINGW_MSVCRT100=on ninja yass yass_benchmark yass_test - name: Packaging shell: bash diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp index 5e9f183d4..2d796f26f 160000 --- a/third_party/abseil-cpp +++ b/third_party/abseil-cpp @@ -1 +1 @@ -Subproject commit 5e9f183d4549c2f261fc3a5893c1e20d1ddf63f7 +Subproject commit 2d796f26ff7423484e9e27766f1dd7e032fb5f3d diff --git a/third_party/boringssl/src b/third_party/boringssl/src index 81547929e..d3546d0c9 160000 --- a/third_party/boringssl/src +++ b/third_party/boringssl/src @@ -1 +1 @@ -Subproject commit 81547929ed94f66cbfeee4c3ea594c8e63d6929b +Subproject commit d3546d0c90e5b008efd6bef15ce8d59e0a60bc5f diff --git a/third_party/libc++/CMakeLists.txt b/third_party/libc++/CMakeLists.txt index 20fa21c65..da6430df6 100644 --- a/third_party/libc++/CMakeLists.txt +++ b/third_party/libc++/CMakeLists.txt @@ -137,7 +137,7 @@ else() ${libcxx_PUBLIC_LIBRARIES} pthread c gcc_s m rt ) - elseif (COMPILER_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0 AND NOT (MINGW AND NOT OS_AARCH64)) + elseif (COMPILER_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0 AND NOT (MINGW AND MINGW_MSVCRT100)) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib++") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib++") else() @@ -170,22 +170,13 @@ else() gcc_s rt ) endif() - elseif (MINGW) - if (USE_LIBUNWIND AND USE_COMPILER_RT) - set(libcxx_PUBLIC_LIBRARIES - ${libcxx_PUBLIC_LIBRARIES} - mingw32 ${COMPILER_RT_PATH} unwind moldname mingwex msvcr100 - advapi32 shell32 user32 kernel32 - mingw32 ${COMPILER_RT_PATH} unwind moldname mingwex msvcr100 kernel32 - ) - else() - set(libcxx_PUBLIC_LIBRARIES - ${libcxx_PUBLIC_LIBRARIES} - mingw32 gcc_eh gcc moldname mingwex msvcr100 - advapi32 shell32 user32 kernel32 - mingw32 gcc_eh gcc moldname mingwex msvcr100 kernel32 - ) - endif() + elseif (MINGW AND MINGW_MSVCRT100) + set(libcxx_PUBLIC_LIBRARIES + ${libcxx_PUBLIC_LIBRARIES} + mingw32 gcc_eh gcc moldname mingwex msvcr100 + advapi32 shell32 user32 kernel32 + mingw32 gcc_eh gcc moldname mingwex msvcr100 kernel32 + ) endif() endif() endif() From b74da123645777a9ed31a2bc065697c72769134f Mon Sep 17 00:00:00 2001 From: Chilledheart Date: Mon, 18 Dec 2023 18:47:00 +0800 Subject: [PATCH 2/2] gh action: use ucrt for mingw bots --- .github/workflows/compiler.yml | 36 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/.github/workflows/compiler.yml b/.github/workflows/compiler.yml index 245bfc6f7..536fa47d9 100644 --- a/.github/workflows/compiler.yml +++ b/.github/workflows/compiler.yml @@ -151,7 +151,7 @@ jobs: with: path: | llvm-mingw-*.tar.xz - key: ${{ runner.os }}-mingw64-llvm-20230614-and-ucrt + key: ${{ runner.os }}-mingw64-llvm-20230614-ucrt - name: Cache mingw64 curl id: curl-cache uses: actions/cache@v3 @@ -186,7 +186,6 @@ jobs: - name: "Download dependency: llvm-mingw" if: ${{ steps.mingw-cache.outputs.cache-hit != 'true' }} run: | - curl -L -O https://github.com/mstorsjo/llvm-mingw/releases/download/20230614/llvm-mingw-20230614-msvcrt-ubuntu-20.04-x86_64.tar.xz curl -L -O https://github.com/mstorsjo/llvm-mingw/releases/download/20230614/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64.tar.xz - name: "Download dependency: curl" if: ${{ steps.curl-cache.outputs.cache-hit != 'true' }} @@ -199,17 +198,10 @@ jobs: curl -L -O https://curl.se/windows/dl-8.4.0_7/curl-8.4.0_7-win32-mingw.zip 7z x curl-8.4.0_7-win32-mingw.zip -aoa rm -vf curl*.zip - - name: Specify mingw variant - run: | - if [ "${{ matrix.arch }}" = "i686" ] || [ "${{ matrix.arch }}" = "x86_64" ]; then - echo "VARIANT=msvcrt" >> $GITHUB_ENV - else - echo "VARIANT=ucrt" >> $GITHUB_ENV - fi - name: Populate llvm-mingw run: | - sudo tar -C /opt -xvf llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64.tar.xz - sudo ln -sf libclang_rt.builtins-i386.a /opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/lib/clang/16/lib/windows/libclang_rt.builtins-i686.a + sudo tar -C /opt -xvf llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64.tar.xz + sudo ln -sf libclang_rt.builtins-i386.a /opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/lib/clang/16/lib/windows/libclang_rt.builtins-i686.a - name: Populate depedencies run: | sudo apt-get update -qq @@ -241,21 +233,21 @@ jobs: set(CMAKE_EXE_LINKER_FLAGS "--rtlib=compiler-rt --unwindlib=libunwind") # cross compilers to use for C and C++ - set(CMAKE_C_COMPILER "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/clang") - set(CMAKE_CXX_COMPILER "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/clang++") - set(CMAKE_LINKER "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/ld.lld") - set(CMAKE_AR "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/llvm-ar") - set(CMAKE_CXX_COMPILER_AR "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/llvm-ar") - set(CMAKE_RANLIB "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/llvm-ranlib") - set(CMAKE_CXX_COMPILER_RANLIB "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/llvm-ranlib") + set(CMAKE_C_COMPILER "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/clang") + set(CMAKE_CXX_COMPILER "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/clang++") + set(CMAKE_LINKER "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/ld.lld") + set(CMAKE_AR "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/llvm-ar") + set(CMAKE_CXX_COMPILER_AR "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/llvm-ar") + set(CMAKE_RANLIB "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/llvm-ranlib") + set(CMAKE_CXX_COMPILER_RANLIB "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/llvm-ranlib") # disabled because it is missing from binary - # set(CMAKE_RC_COMPILER "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/llvm-rc") - set(CMAKE_RC_COMPILER "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/bin/\${GNU_TARGET}-windres") + # set(CMAKE_RC_COMPILER "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/llvm-rc") + set(CMAKE_RC_COMPILER "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/bin/\${GNU_TARGET}-windres") - set(CMAKE_SYSROOT "/opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/\${GNU_TARGET}" CACHE STRING "") + set(CMAKE_SYSROOT "/opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/\${GNU_TARGET}" CACHE STRING "") # target environment on the build host system - set(CMAKE_FIND_ROOT_PATH /opt/llvm-mingw-20230614-${{ env.VARIANT }}-ubuntu-20.04-x86_64/\${GNU_TARGET}) + set(CMAKE_FIND_ROOT_PATH /opt/llvm-mingw-20230614-ucrt-ubuntu-20.04-x86_64/\${GNU_TARGET}) # modify default behavior of FIND_XXX() commands set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)