From d339ee2759f6d18231f359368e9cde176dc5ceb7 Mon Sep 17 00:00:00 2001 From: aurora0x27 Date: Wed, 28 May 2025 19:12:23 +0800 Subject: [PATCH 1/2] Use homebrew llvm@20 instead of apple clang * Use homebrew xmake * fix * Install python3.13 to avoid compile python * Use force homebrew python * Install system package python setuptools * Install python-setuptools by homebrew * Use lld as linker * Use llvm-20 libtool --- .github/workflows/macos.yml | 27 +++++++++++++++++++++++---- xmake.lua | 3 ++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 6bf500f..d27031e 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -22,17 +22,36 @@ jobs: cancel-in-progress: true steps: + - name: Setup llvm + run: | + brew install llvm@20 + + - name: Install lld + run: | + brew install lld@20 + + - name: Setup python + run: | + # avoid compile python + brew install python@3.13 + brew install python-setuptools + - name: Checkout repository uses: actions/checkout@v4 - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: '2.9.9' - actions-cache-folder: '.xmake-cache' + run: | + brew install xmake + + # - name: Setup xmake + # uses: xmake-io/github-action-setup-xmake@v1 + # with: + # xmake-version: '2.9.9' + # actions-cache-folder: '.xmake-cache' - name: Package run: | + export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH" xmake config --yes --verbose --toolchain=clang --mode=${{ matrix.build_type }} --policies=build.optimization.lto:${{ matrix.lto }} - name: Upload artifacts diff --git a/xmake.lua b/xmake.lua index c88a33b..f39ca18 100644 --- a/xmake.lua +++ b/xmake.lua @@ -92,7 +92,7 @@ package("llvm") table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DLLVM_ENABLE_LTO=" .. (package:config("lto") and "ON" or "OFF")) if package:config("lto") then - if package:is_plat("linux") then + if package:is_plat("linux") or package:is_plat("macosx") then table.insert(configs, "-DLLVM_USE_LINKER=lld") end end @@ -111,6 +111,7 @@ package("llvm") if package:is_plat("macosx") then table.insert(configs, "-DLLVM_TARGETS_TO_BUILD=AArch64") table.insert(configs, "-DCMAKE_OSX_ARCHITECTURES=arm64") + table.insert(configs, "-DCMAKE_LIBTOOL=/opt/homebrew/opt/llvm@20/bin/llvm-libtool-darwin") else table.insert(configs, "-DLLVM_TARGETS_TO_BUILD=X86") end From 6830d7cfc3139ecc2edafc86d6d6009e89df7ff9 Mon Sep 17 00:00:00 2001 From: aurora0x27 Date: Thu, 29 May 2025 11:58:38 +0800 Subject: [PATCH 2/2] Change style --- xmake.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake.lua b/xmake.lua index f39ca18..9c853e0 100644 --- a/xmake.lua +++ b/xmake.lua @@ -92,7 +92,7 @@ package("llvm") table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DLLVM_ENABLE_LTO=" .. (package:config("lto") and "ON" or "OFF")) if package:config("lto") then - if package:is_plat("linux") or package:is_plat("macosx") then + if package:is_plat("linux", "macosx") then table.insert(configs, "-DLLVM_USE_LINKER=lld") end end @@ -193,7 +193,7 @@ package("llvm") local archive_dirs if package:is_plat("windows") then archive_dirs = "*" - elseif package:is_plat("linux") or package:is_plat("macosx") then + elseif package:is_plat("linux", "macosx") then -- workaround for tar archive_dirs = {} for _, dir in ipairs(os.dirs(path.join(opt.curdir, "*"))) do