diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 065a658..b77f6cb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -2,7 +2,7 @@ name: linux on: pull_request: - branches: [ main ] + branches: [main] jobs: build: @@ -12,10 +12,10 @@ jobs: include: - build_type: debug lto: "n" - - build_type: release + - build_type: releasedbg lto: "n" - - build_type: release - lto: "y" + # - build_type: releasedbg + # lto: "y" concurrency: group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-linux-${{ matrix.build_type }}-${{ matrix.lto }} @@ -37,8 +37,26 @@ jobs: - name: Setup xmake uses: xmake-io/github-action-setup-xmake@v1 with: - xmake-version: '2.9.9' - actions-cache-folder: '.xmake-cache' + xmake-version: "2.9.9" + actions-cache-folder: ".xmake-cache" + + - name: Increase Swap Space + run: | + echo "===== Initial Status =====" + sudo swapon --show + free -h + + echo "===== Creating Swap File =====" + sudo swapoff -a + sudo fallocate -l 16G /mnt/swapfile + sudo chmod 600 /mnt/swapfile + sudo mkswap /mnt/swapfile + sudo swapon /mnt/swapfile + + echo "===== Final Status =====" + sudo swapon --show + free -h + df -h - name: Package run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index d27031e..99ea8b8 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -2,7 +2,7 @@ name: macos on: pull_request: - branches: [ main ] + branches: [main] jobs: build: @@ -12,10 +12,10 @@ jobs: include: - build_type: debug lto: "n" - - build_type: release + - build_type: releasedbg lto: "n" - - build_type: release - lto: "y" + # - build_type: releasedbg + # lto: "y" concurrency: group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-macos-${{ matrix.build_type }}-${{ matrix.lto }} @@ -24,11 +24,7 @@ jobs: steps: - name: Setup llvm run: | - brew install llvm@20 - - - name: Install lld - run: | - brew install lld@20 + brew install llvm@20 lld@20 - name: Setup python run: | @@ -43,14 +39,9 @@ jobs: 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 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) 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 }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e95d0cc..b9ff876 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -2,7 +2,7 @@ name: windows on: pull_request: - branches: [ main ] + branches: [main] jobs: build: @@ -10,12 +10,12 @@ jobs: strategy: matrix: include: - - build_type: release + - build_type: releasedbg runtimes: MD lto: "n" - - build_type: release - runtimes: MT - lto: "y" + # - build_type: releasedbg + # runtimes: MT + # lto: "y" concurrency: group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-windows-${{ matrix.build_type }}-${{ matrix.lto }} @@ -28,12 +28,12 @@ jobs: - name: Setup xmake uses: xmake-io/github-action-setup-xmake@v1 with: - xmake-version: '2.9.9' - actions-cache-folder: '.xmake-cache' + xmake-version: "2.9.9" + actions-cache-folder: ".xmake-cache" - name: Package run: | - xmake config --yes --verbose --runtimes=${{ matrix.runtimes }} --policies=build.optimization.lto:${{ matrix.lto }} + xmake config --yes --verbose --mode=${{ matrix.build_type }} --runtimes=${{ matrix.runtimes }} --policies=build.optimization.lto:${{ matrix.lto }} - name: Upload artifacts uses: actions/upload-artifact@v4 diff --git a/xmake.lua b/xmake.lua index 9c853e0..1d72afe 100644 --- a/xmake.lua +++ b/xmake.lua @@ -3,6 +3,7 @@ set_policy("compatibility.version", "3.0") add_requires("llvm", { system = false, configs = { + mode = get_config("mode"), debug = is_mode("debug"), shared = is_mode("debug") and not is_plat("windows"), }, @@ -14,21 +15,20 @@ local sparse_checkout_list = { "clang", "clang-tools-extra", } --- Enable asan -if is_mode("debug") then - table.insert(sparse_checkout_list, "runtimes") - table.insert(sparse_checkout_list, "compiler-rt") -end + +-- TODO: If we need compiler-rt builtin-headers, then we need to enable them. +-- if is_mode("debug") then +-- table.insert(sparse_checkout_list, "runtimes") +-- table.insert(sparse_checkout_list, "compiler-rt") +-- end package("llvm") - set_urls("https://github.com/llvm/llvm-project/releases/download/llvmorg-$(version)/llvm-project-$(version).src.tar.xz", - "https://github.com/llvm/llvm-project.git", {includes = sparse_checkout_list}) + add_urls("https://github.com/llvm/llvm-project.git", {alias = "git", includes = sparse_checkout_list}) - add_versions("20.1.5", "a069565cd1c6aee48ee0f36de300635b5781f355d7b3c96a28062d50d575fa3e") + add_versions("git:21.1.4", "llvmorg-21.1.4") + add_versions("git:20.1.5", "llvmorg-20.1.5") - if is_plat("windows") then - add_configs("debug", {description = "Enable debug symbols.", default = false, type = "boolean", readonly = true}) - end + add_configs("mode", {description = "Build type", default = "releasedbg", type = "string", values = {"debug", "release", "releasedbg"}}) if is_plat("windows", "mingw") then add_syslinks("version", "ntdll") @@ -75,6 +75,7 @@ package("llvm") "-DLLVM_INCLUDE_BENCHMARKS=OFF", -- "-DCLANG_BUILD_TOOLS=OFF", + -- "-DLLVM_INCLUDE_TOOLS=OFF", "-DLLVM_BUILD_TOOLS=OFF", "-DLLVM_BUILD_UTILS=OFF", "-DCLANG_ENABLE_CLANGD=OFF", @@ -86,34 +87,41 @@ package("llvm") "-DLLVM_LINK_LLVM_DYLIB=OFF", "-DLLVM_ENABLE_RTTI=OFF", - -- "-DLLVM_ENABLE_PROJECTS=clang", + "-DLLVM_PARALLEL_LINK_JOBS=1", + + -- Build job and link job together will oom + "-DCMAKE_JOB_POOL_LINK=console", + + "-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra", + + -- Only build native target + "-DLLVM_TARGETS_TO_BUILD=Native" } - table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + + local build_type = { + ["debug"] = "Debug", + ["release"] = "Release", + ["releasedbg"] = "RelWithDebInfo", + } + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (build_type[package:config("mode")])) 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", "macosx") then - table.insert(configs, "-DLLVM_USE_LINKER=lld") - end + + if package:config("mode") == "debug" then + table.insert(configs, "-DLLVM_USE_SANITIZER=Address") end + if package:is_plat("windows") then table.insert(configs, "-DCMAKE_C_COMPILER=clang-cl") table.insert(configs, "-DCMAKE_CXX_COMPILER=clang-cl") - end - if package:is_debug() then - table.insert(configs, "-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra") - table.insert(configs, "-DLLVM_ENABLE_RUNTIMES=compiler-rt") - table.insert(configs, "-DLLVM_USE_SANITIZER=Address") - else - table.insert(configs, "-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra") - end - - if package:is_plat("macosx") then - table.insert(configs, "-DLLVM_TARGETS_TO_BUILD=AArch64") + elseif package:is_plat("linux") then + table.insert(configs, "-DLLVM_USE_LINKER=lld") + -- table.insert(configs, "-DLLVM_USE_SPLIT_DWARF=ON") + elseif package:is_plat("macosx") then 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") + table.insert(configs, "-DLLVM_USE_LINKER=lld") + table.insert(configs, "-DLLVM_ENABLE_LIBCXX=ON") end local opt = {} @@ -176,7 +184,7 @@ package("llvm") package:arch(), package:plat(), abi, - package:is_debug() and "debug" or "release", + package:config("mode"), }, "-") if package:config("lto") then