From 8ee28e293809b67177f71da1ecf89bad0c62004a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 22 Mar 2023 23:29:01 +0200 Subject: [PATCH] build-llvm: Enable the custom defaults for Clang when building natively on MSYS2 Normally our releases are cross-built from Linux, but we also support building the toolchain in MSYS2. Enable the custom defaults when building the toolchain in MSYS2 too. --- build-llvm.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/build-llvm.sh b/build-llvm.sh index df0cbe3..f4d3162 100755 --- a/build-llvm.sh +++ b/build-llvm.sh @@ -122,6 +122,17 @@ fi [ -z "$CHECKOUT_ONLY" ] || exit 0 +case $(uname) in +MINGW*) + TARGET_WINDOWS=1 + ;; +*) + if [ -n "$HOST" ]; then + TARGET_WINDOWS=1 + fi + ;; +esac + if command -v ninja >/dev/null; then CMAKE_GENERATOR="Ninja" NINJA=1 @@ -174,13 +185,6 @@ if [ -n "$HOST" ]; then CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY" CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY" - # Custom, llvm-mingw specific defaults. We normally set these in - # the frontend wrappers, but this makes sure they are enabled by - # default if that wrapper is bypassed as well. - CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_RTLIB=compiler-rt" - CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_UNWINDLIB=libunwind" - CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_CXX_STDLIB=libc++" - CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_LINKER=lld" BUILDDIR=$BUILDDIR-$HOST if [ -n "$WITH_PYTHON" ]; then @@ -210,6 +214,16 @@ elif [ -n "$STAGE2" ]; then CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=lld" fi +if [ -n "$TARGET_WINDOWS" ]; then + # Custom, llvm-mingw specific defaults. We normally set these in + # the frontend wrappers, but this makes sure they are enabled by + # default if that wrapper is bypassed as well. + CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_RTLIB=compiler-rt" + CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_UNWINDLIB=libunwind" + CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_CXX_STDLIB=libc++" + CMAKEFLAGS="$CMAKEFLAGS -DCLANG_DEFAULT_LINKER=lld" +fi + if [ -n "$LTO" ]; then CMAKEFLAGS="$CMAKEFLAGS -DLLVM_ENABLE_LTO=$LTO" fi