使用musl替换glibc,并在输出内移除调试符号以减小产物大小

This commit is contained in:
TheWhiteDog9487
2026-05-24 09:48:06 +08:00
parent a3e3816eb7
commit 5a7444aebf
+23 -16
View File
@@ -11,27 +11,34 @@ jobs:
build: build:
runs-on: ubuntu-latest 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: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- name: 安装GCC对ARM交叉编译工具链 - name: 下载 musl 工具链
uses: lmq8267/dl-musl@main
with:
TARGET: ${{ matrix.target }}
STATIC: true
- name: 编译
run: | run: |
sudo apt update if [ "${{ matrix.target }}" = "x86_64-linux-musl" ]; then
sudo apt install g++-aarch64-linux-gnu "$CXX" -o "${{ matrix.artifact }}" -std=c++23 -s language.cpp
else
- name: 编译源代码 "$CXX" -o "${{ matrix.artifact }}" -std=c++23 -s language.cpp
run: | fi
g++ -o language --static -std=c++20 language.cpp
aarch64-linux-gnu-g++ -o language_arm --static -std=c++20 language.cpp
# 静态链接,避免运行时才发现缺少so动态链接库
- uses: actions/upload-artifact@v5 - uses: actions/upload-artifact@v5
with: with:
name: language_arm name: ${{ matrix.artifact }}
path: language_arm path: ${{ matrix.artifact }}
- uses: actions/upload-artifact@v5
with:
name: language
path: language
push: push:
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest