Skip to content

Commit a4ec7a3

Browse files
committed
ci: 补一条宿主平台轴(macos-14, windows-2022)
这些目标全是交叉目标,宿主因此是独立于目标的一个轴:编译器、目标 C 库 和模拟器都是 mcpp 按**它自己运行所在的宿主**解析的载荷。只在 Linux 上 构建过的包,是一个要求消费者用 Linux 的包,而源码里没有任何一处这么说。 ⚠️ 没有加工具链轴,这是实测而非假设:裸机 triple 的目标行钉死了编译器, 命令行覆盖也顶不掉——`--toolchain gcc@16.1.0` 编 `riscv64-none-elf` 照样解析到 llvm@22.1.8。摆一条编译器族的矩阵会让每一行跑同一个编译器, 报出它并不具备的覆盖。工具链轴属于选择真实存在的地方,也就是 openkal。 只构建,不运行:行为由上面那个作业在模拟器里断言一次。从三个系统启动 同一个镜像,断言的是模拟器的可移植性而不是本包的。
1 parent 93163ea commit a4ec7a3

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,71 @@ jobs:
5151
mcpp run 2>&1 | tee run.log
5252
grep -q "hello from openkal over SBI" run.log
5353
grep -q "heap ok" run.log
54+
55+
# ---------------------------------------------------------------------------
56+
# The cross-compilation is performed FROM three systems, not only from Linux.
57+
#
58+
# Every target in this repository is a cross target, which makes the host a
59+
# separate axis from the target: the compiler, the target C library and the
60+
# emulator are payloads mcpp resolves for whichever system it is running on.
61+
# A package that has only ever been built from Linux is a package whose
62+
# consumers must use Linux, and nothing in these sources says so.
63+
#
64+
# ⚠️ A TOOLCHAIN AXIS IS ABSENT HERE, AND THAT IS MEASURED RATHER THAN
65+
# ASSUMED. The row for a bare-metal triple names its compiler, and the
66+
# command-line override does not displace it: `--toolchain gcc@16.1.0` on a
67+
# `riscv64-none-elf` build resolves llvm@22.1.8 regardless. A matrix over
68+
# compiler families would therefore run the same compiler on every row and
69+
# report coverage it does not have. The toolchain axis belongs where the
70+
# choice is real — openkal, whose declarations are compiled by three families
71+
# on three systems.
72+
#
73+
# ⚠️ BUILD ONLY, AND DELIBERATELY. Behaviour is asserted once, above, under an
74+
# emulator. Booting the same image from three systems would be a statement
75+
# about the emulator rather than about this package, and "the image does what
76+
# the README says" does not become more true for having been observed from
77+
# macOS.
78+
portability:
79+
name: cross-builds from ${{ matrix.os }}
80+
runs-on: ${{ matrix.os }}
81+
timeout-minutes: 45
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
os: [macos-14, windows-2022]
86+
defaults:
87+
run:
88+
shell: bash
89+
env:
90+
MCPP_VERSION: 2026.8.20.2
91+
XLINGS_VERSION: v2026.8.17.2
92+
XLINGS_NON_INTERACTIVE: '1'
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- name: Install xlings (Unix)
97+
if: runner.os != 'Windows'
98+
run: |
99+
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh \
100+
| bash -s "$XLINGS_VERSION"
101+
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
102+
103+
- name: Install xlings (Windows)
104+
if: runner.os == 'Windows'
105+
shell: pwsh
106+
run: |
107+
irm https://d2learn.org/xlings-install.ps1.txt | iex
108+
# The installer amends the user's environment; no later step in this
109+
# job reads it back, so the directory is named here.
110+
"$env:USERPROFILE\.xlings\subos\current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
111+
112+
- name: Install mcpp
113+
run: |
114+
xlings update
115+
xlings install "mcpp@$MCPP_VERSION" -y -g
116+
mcpp --version
117+
mcpp self config --mirror GLOBAL
118+
119+
- name: The backend cross-builds
120+
run: |
121+
mcpp build --target riscv64-none-elf

0 commit comments

Comments
 (0)