From ee6caf31cfe171c49a5df4771bc038c265bde324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 5 Jan 2022 13:33:33 +0200 Subject: [PATCH] Allow building a redistributable package for macOS This includes building universal binaries (for arm64 and x86_64) and targeting an older minimum deployment target. (Before 1919720fdd348ca568b235bf3f1357c198eccd15 in llvm-project, Jan 2022, building lldb's debugserver failed, if building for macOS for multiple architectures, or for an architecture other than the current host.) --- build-lldb-mi.sh | 5 +++++ build-llvm.sh | 5 +++++ build-mingw-w64-tools.sh | 6 ++++++ install-wrappers.sh | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/build-lldb-mi.sh b/build-lldb-mi.sh index 3bc592b..df51651 100755 --- a/build-lldb-mi.sh +++ b/build-lldb-mi.sh @@ -103,6 +103,11 @@ if [ -n "$HOST" ]; then CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY" fi +if [ -n "$MACOS_REDIST" ]; then + CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" + CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9" +fi + cd lldb-mi [ -z "$CLEAN" ] || rm -rf $BUILDDIR diff --git a/build-llvm.sh b/build-llvm.sh index b49961c..4bfcf37 100755 --- a/build-llvm.sh +++ b/build-llvm.sh @@ -194,6 +194,11 @@ if [ -n "$LTO" ]; then CMAKEFLAGS="$CMAKEFLAGS -DLLVM_ENABLE_LTO=$LTO" fi +if [ -n "$MACOS_REDIST" ]; then + CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" + CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9" +fi + TOOLCHAIN_ONLY=ON if [ -n "$FULL_LLVM" ]; then TOOLCHAIN_ONLY=OFF diff --git a/build-mingw-w64-tools.sh b/build-mingw-w64-tools.sh index 577f20c..03d776a 100755 --- a/build-mingw-w64-tools.sh +++ b/build-mingw-w64-tools.sh @@ -72,6 +72,12 @@ else ;; esac fi +if [ -n "$MACOS_REDIST" ]; then + if [ -z "$CFLAGS" ]; then + export CFLAGS="-g -O2" + fi + export CFLAGS="$CFLAGS -arch arm64 -arch x86_64 -mmacosx-version-min=10.9" +fi if [ -n "$SKIP_INCLUDE_TRIPLET_PREFIX" ]; then INCLUDEDIR="$PREFIX/include" else diff --git a/install-wrappers.sh b/install-wrappers.sh index 9165d19..6907155 100755 --- a/install-wrappers.sh +++ b/install-wrappers.sh @@ -54,6 +54,10 @@ if [ -n "$HOST" ]; then EXEEXT=.exe fi +if [ -n "$MACOS_REDIST" ]; then + WRAPPER_FLAGS="$WRAPPER_FLAGS -arch arm64 -arch x86_64 -mmacosx-version-min=10.9" +fi + if [ -n "$EXEEXT" ]; then CLANG_MAJOR=$(basename $(echo $PREFIX/lib/clang/* | awk '{print $NF}') | cut -f 1 -d .) WRAPPER_FLAGS="$WRAPPER_FLAGS -municode -DCLANG=\"clang-$CLANG_MAJOR\""