From 5a7444aebffd4c9cb2b568443a823cec18f6c5b1 Mon Sep 17 00:00:00 2001 From: TheWhiteDog9487 Date: Sun, 24 May 2026 09:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8musl=E6=9B=BF=E6=8D=A2glibc?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=9C=A8=E8=BE=93=E5=87=BA=E5=86=85=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E8=B0=83=E8=AF=95=E7=AC=A6=E5=8F=B7=E4=BB=A5=E5=87=8F?= =?UTF-8?q?=E5=B0=8F=E4=BA=A7=E7=89=A9=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 39 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c76b3c6..eb4e00d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,27 +11,34 @@ jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-linux-musl + artifact: language + - target: aarch64-linux-musl + artifact: language_arm steps: - uses: actions/checkout@v6 - - name: 安装GCC对ARM交叉编译工具链 + - name: 下载 musl 工具链 + uses: lmq8267/dl-musl@main + with: + TARGET: ${{ matrix.target }} + STATIC: true + + - name: 编译 run: | - sudo apt update - sudo apt install g++-aarch64-linux-gnu - - - name: 编译源代码 - run: | - g++ -o language --static -std=c++20 language.cpp - aarch64-linux-gnu-g++ -o language_arm --static -std=c++20 language.cpp - # 静态链接,避免运行时才发现缺少so动态链接库 + if [ "${{ matrix.target }}" = "x86_64-linux-musl" ]; then + "$CXX" -o "${{ matrix.artifact }}" -std=c++23 -s language.cpp + else + "$CXX" -o "${{ matrix.artifact }}" -std=c++23 -s language.cpp + fi - uses: actions/upload-artifact@v5 - with: - name: language_arm - path: language_arm - - uses: actions/upload-artifact@v5 - with: - name: language - path: language + with: + name: ${{ matrix.artifact }} + path: ${{ matrix.artifact }} push: needs: build runs-on: ubuntu-latest