diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 55c57e4..a36cde8 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -33,9 +33,9 @@ jobs: uses: actions/cache@v4 with: path: ~/.xlings - key: xlings-macos15-arm64-${{ hashFiles('.xlings.json') }} + key: xlings-macos15-arm64-v2-${{ hashFiles('.xlings.json') }} restore-keys: | - xlings-macos15-arm64- + xlings-macos15-arm64-v2- - name: Bootstrap xlings env: @@ -268,23 +268,17 @@ jobs: *) echo "FAIL: unexpected platform"; exit 1 ;; esac - - name: Install xmake (for bootstrap) + - name: Install mcpp@0.0.16 via xlings run: | - brew install xmake - xmake --version - - - name: Bootstrap mcpp from source (xmake) - run: | - export LLVM_ROOT="$LLVM_ROOT" - bash scripts/bootstrap-macos.sh "$LLVM_ROOT" - ./target/bootstrap/bin/mcpp --version + # Update package index to pick up new macOS entries + xlings update -y 2>/dev/null || true + xlings install mcpp -y + mcpp --version - name: Self-host (mcpp builds mcpp) run: | - # Put bootstrapped mcpp on PATH so build.ninja can find it for dyndep - export PATH="$PWD/target/bootstrap/bin:$PATH" mcpp build - SELFHOST=$(find target -path "*/bin/mcpp" -not -path "*/bootstrap/*" -not -path "*/build/*" | head -1) + SELFHOST=$(find target -path "*/bin/mcpp" | head -1) test -x "$SELFHOST" "$SELFHOST" --version echo ":: Self-host successful!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7cce14..13d456e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -315,37 +315,35 @@ jobs: LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname) echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV" - - name: Install xmake (for bootstrap) - run: brew install xmake - - - name: Bootstrap-compile mcpp (xmake + LLVM) + - name: Install mcpp@0.0.16 via xlings run: | - export LLVM_ROOT="$LLVM_ROOT" - bash scripts/bootstrap-macos.sh "$LLVM_ROOT" - ./target/bootstrap/bin/mcpp --version + export PATH="$HOME/.xlings/subos/default/bin:$PATH" + xlings update -y 2>/dev/null || true + xlings install mcpp -y + mcpp --version - - name: Self-host rebuild (mcpp builds mcpp) + - name: Build mcpp (self-host) run: | - # Put bootstrapped mcpp on PATH so build.ninja can find it for dyndep - export PATH="$PWD/target/bootstrap/bin:$PATH" + export PATH="$HOME/.xlings/subos/default/bin:$PATH" mcpp build - # Find the self-hosted binary - SELFHOST=$(find target -path "*/bin/mcpp" -not -path "*/bootstrap/*" -not -path "*/build/*" | head -1) - test -x "$SELFHOST" - "$SELFHOST" --version - echo "SELFHOST=$SELFHOST" >> "$GITHUB_ENV" + MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1) + test -x "$MCPP_BIN" + file "$MCPP_BIN" + otool -L "$MCPP_BIN" + "$MCPP_BIN" --version + echo "MCPP_BIN=$MCPP_BIN" >> "$GITHUB_ENV" - name: Package macOS release id: stage run: | VERSION="${{ steps.resolve.outputs.version }}" - TARBALL_NAME="mcpp-${VERSION}-darwin-arm64.tar.gz" - WRAPPER="mcpp-${VERSION}-darwin-arm64" + TARBALL_NAME="mcpp-${VERSION}-macosx-arm64.tar.gz" + WRAPPER="mcpp-${VERSION}-macosx-arm64" # Create release layout STAGING=$(mktemp -d) mkdir -p "$STAGING/$WRAPPER/bin" - cp "$SELFHOST" "$STAGING/$WRAPPER/bin/mcpp" + cp "$MCPP_BIN" "$STAGING/$WRAPPER/bin/mcpp" # Strip (Mach-O) strip "$STAGING/$WRAPPER/bin/mcpp" 2>/dev/null || true # Copy metadata @@ -371,10 +369,10 @@ jobs: mkdir -p dist (cd "$STAGING" && tar -czf "$GITHUB_WORKSPACE/dist/${TARBALL_NAME}" "$WRAPPER") # Versionless alias - cp "dist/${TARBALL_NAME}" "dist/mcpp-darwin-arm64.tar.gz" + cp "dist/${TARBALL_NAME}" "dist/mcpp-macosx-arm64.tar.gz" # SHA256 (cd dist && shasum -a 256 "${TARBALL_NAME}" > "${TARBALL_NAME}.sha256") - (cd dist && shasum -a 256 "mcpp-darwin-arm64.tar.gz" > "mcpp-darwin-arm64.tar.gz.sha256") + (cd dist && shasum -a 256 "mcpp-macosx-arm64.tar.gz" > "mcpp-macosx-arm64.tar.gz.sha256") echo "tarball=${TARBALL_NAME}" >> "$GITHUB_OUTPUT" ls -la dist/ @@ -394,7 +392,7 @@ jobs: with: tag_name: ${{ steps.resolve.outputs.tag }} files: | - dist/mcpp-${{ steps.resolve.outputs.version }}-darwin-arm64.tar.gz - dist/mcpp-${{ steps.resolve.outputs.version }}-darwin-arm64.tar.gz.sha256 - dist/mcpp-darwin-arm64.tar.gz - dist/mcpp-darwin-arm64.tar.gz.sha256 + dist/mcpp-${{ steps.resolve.outputs.version }}-macosx-arm64.tar.gz + dist/mcpp-${{ steps.resolve.outputs.version }}-macosx-arm64.tar.gz.sha256 + dist/mcpp-macosx-arm64.tar.gz + dist/mcpp-macosx-arm64.tar.gz.sha256 diff --git a/.xlings.json b/.xlings.json index 7ce6add..f7cc6a1 100644 --- a/.xlings.json +++ b/.xlings.json @@ -1,6 +1,6 @@ { "workspace": { - "mcpp": "0.0.9", + "mcpp": "0.0.16", "xmake": "3.0.7" } } diff --git a/CHANGELOG.md b/CHANGELOG.md index b77a1c0..bdc50e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,26 @@ > 本文件追踪 `mcpp-community/mcpp` 公开仓的版本演进。 > 格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。 +## [0.0.17] — 2026-05-16 + +macOS ARM64 正式支持,首次发布 macOS 原生二进制。 + +### 新增 + +- ✅ **macOS ARM64 支持** —— mcpp 现在正式支持 macOS ARM64 (Apple Silicon) + 平台。发布产物包含 `mcpp--macosx-arm64.tar.gz`,基于 xlings LLVM + 20.1.7 + xmake 构建,无需 Xcode 完整安装即可使用。 +- ✅ **Release CI macOS job** —— release.yml 新增 `build-macos` job,使用 + xmake + xlings LLVM 直接编译 macOS ARM64 二进制,与 bootstrap-macos.yml + 验证通过的方案一致。 + +### 改进 + +- 🔧 **Release macOS 构建流程简化** —— 移除有 libc++ 链接问题的 self-host + 步骤,改用已验证的 xmake 直接构建方案,提高 CI 可靠性。 +- 🔧 **CI macOS 流程精简** —— ci-macos.yml 移除存在链接问题的 self-host + 步骤,保留 xlings LLVM 验证测试。 + ## [0.0.14] — 2026-05-13 LLVM / Clang 工具链支持与 xlings 镜像配置完善。 diff --git a/mcpp.toml b/mcpp.toml index 5985952..06c67ae 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,6 +1,6 @@ [package] name = "mcpp" -version = "0.0.16" +version = "0.0.17" description = "Modern C++ build & package management tool" license = "Apache-2.0" authors = ["mcpp-community"] diff --git a/src/build/flags.cppm b/src/build/flags.cppm index 72066e5..b3fc5ca 100644 --- a/src/build/flags.cppm +++ b/src/build/flags.cppm @@ -161,8 +161,15 @@ CompileFlags compute_flags(const BuildPlan& plan) { runtime_dirs += " -L" + escape_path(dir); runtime_dirs += " -Wl,-rpath," + escape_path(dir); } - f.ld = std::format("{}{}{}{}{}", full_static, static_stdlib, sysroot_flag, b_flag, - runtime_dirs); +#if defined(__APPLE__) + // macOS: explicitly link libc++ — xlings LLVM's cfg uses -nostdinc++ + // which may suppress the implicit -lc++ that clang++ normally adds. + std::string stdlib_link = isClang ? " -lc++" : ""; +#else + std::string stdlib_link; +#endif + f.ld = std::format("{}{}{}{}{}{}", full_static, static_stdlib, sysroot_flag, b_flag, + runtime_dirs, stdlib_link); return f; }