Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,79 @@ jobs:
if-no-files-found: ignore
retention-days: 7

# ---------------------------------------------------------------------------
# x86_64 WITHOUT AN SDK (0.23.4): a release build of a program above this
# package, linked on Linux for x86_64-macos-musl through openkal-platform's
# hosted arrangement (the stub of libSystem supplied, no SDK on the link), and
# run on an Intel Mac. Clang lowers a zeroing `memset' to `__bzero' on that
# architecture, which the stub did not list (undefined symbol: __bzero).
x86_64-no-sdk-link:
name: x86_64, linked with no SDK
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with: { path: openkal-macos }
- name: Install xlings and mcpp
run: |
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s "$XLINGS_VERSION"
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
- name: mcpp
run: |
for attempt in 1 2 3 4 5; do
xlings update > /dev/null 2>&1 || true
xlings install "mcpp@$MCPP_VERSION" -y -g && break
[ "$attempt" = 5 ] && { echo "::error::mcpp could not be installed"; exit 1; }
sleep 60
done
mcpp self config --mirror GLOBAL
- name: A release build, this package as the kernel-abi layer
run: |
set -euo pipefail
mkdir -p probe/src
cat > probe/mcpp.toml <<'TOML'
[package]
name = "zeroing"
version = "0.1.0"
[targets.zeroing]
kind = "bin"
main = "src/main.c"
[target.x86_64-macos-musl]
platform = "openkal-platform@0.28.0"
[target.x86_64-macos-musl.layers]
kernel-abi = { path = "../openkal-macos" }
TOML
cat > probe/src/main.c <<'C'
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char b[256];
memset(b, 0, sizeof b);
snprintf(b, sizeof b, "zeroed, %d argument(s)", argc - 1);
puts(b);
return 0;
}
C
cd probe
mcpp build --release --target x86_64-macos-musl 2>&1 | tee build.log
grep -q 'openkal-macos@0.23.4' build.log || { echo "::error::the working tree was not the kernel-abi layer"; exit 1; }
mkdir -p ../out && cp "$(find target -name zeroing -type f | head -1)" ../out/
- uses: actions/upload-artifact@v4
with: { name: zeroing-x86_64, path: out/ }

x86_64-no-sdk-run:
name: x86_64, run on an Intel Mac
needs: x86_64-no-sdk-link
runs-on: macos-15-intel
timeout-minutes: 15
steps:
- uses: actions/download-artifact@v4
with: { name: zeroing-x86_64, path: out }
- name: Run
run: |
chmod +x out/zeroing
test "$(out/zeroing one two)" = "zeroed, 2 argument(s)"

# ---------------------------------------------------------------------------
# EVERY JOB'S RUNS AS ONE REPORT (`mtest ci report`, the workflow run's group).
report:
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ written on the kernel's own calls.
openkal = "0.25.0"

[target.'cfg(os = "macos")'.dependencies]
openkal-macos = "0.23.3"
openkal-macos = "0.23.4"
```

Its purpose is as much to test the specification as to be used. A specification
Expand Down Expand Up @@ -183,6 +183,16 @@ same image parses as fast on Linux arm64. Since 0.17.1 it is the same kernel ide
this system's library keeps for each thread (`pthread_threadid_np`, a name no C
library in this ecosystem defines).

## What 0.23.4 corrects

**The stub of `libSystem` lists `__bzero` for x86_64.** Clang lowers a zeroing
`memset` to `__bzero` on this system's x86_64, and this package's objects carry
such stores in a release build. A link with no SDK --- the cross link that the
stub serves --- therefore stopped at `undefined symbol: __bzero`, so a release
build for `x86_64-macos-musl` failed for every program. The stub now lists the
name for x86_64, and the program binds it to the system's library when it runs.
CI links such a program on Linux and runs it on an Intel Mac.

## What 0.23.3 corrects

**The stub of `libSystem` is supplied only when the link has no SDK.** A build
Expand Down
2 changes: 1 addition & 1 deletion mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-macos"
version = "0.23.3"
version = "0.23.4"
description = "An implementation of openkal for macOS, written on the kernel's own calls. Its purpose is as much to test the specification as to be used."
license = "Apache-2.0"

Expand Down
10 changes: 10 additions & 0 deletions port/libSystem.tbd
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ current-version: 1351.0.0
# stops with `undefined symbol: dyld_stub_binder, referenced by lazy binding'.
# The first measurement was made with one version, and one version is not
# evidence about a format.
#
# `___bzero' (0.23.4), for x86_64 only, is of the same kind: no source here
# names it. Clang lowers a zeroing `memset' to it on this system's x86_64
# (Darwin's library call for the operation), and this package's own objects
# carry such stores (src/process.cpp, src/fs.cpp in a release build). A link
# with no SDK therefore stopped at `undefined symbol: __bzero'. AArch64 has no
# such lowering. Measured by linking a release build of a program above
# openkal for x86_64-macos-musl on Linux; its one new import is this name.
exports:
- targets: [ arm64-macos, x86_64-macos ]
symbols: [ __dyld_atfork_parent, __dyld_atfork_prepare, __dyld_fork_child,
Expand All @@ -80,4 +88,6 @@ exports:
__pthread_self, dyld_stub_binder,
_mach_task_self_, _mach_vm_protect, _sandbox_init_with_parameters,
__NSGetArgc, __NSGetArgv, __NSGetEnviron ]
- targets: [ x86_64-macos ]
symbols: [ ___bzero ]
...
Loading