|
| 1 | +name: ci-macos-ios |
| 2 | + |
| 3 | +# The iOS rows, measured on the only machine that can answer for them. |
| 4 | +# |
| 5 | +# iOS needs an ecosystem compiler and a LOCATED SDK: `xim:llvm` emits arm64 |
| 6 | +# Mach-O for an iOS deployment target, and only the machine's Xcode can supply |
| 7 | +# the iPhoneOS / iPhoneSimulator headers and stub libraries, which are not |
| 8 | +# redistributable. The simulator runtime is the same category. So every claim |
| 9 | +# about these three rows is a claim about a macOS runner, and this job is where |
| 10 | +# they are made. |
| 11 | +# |
| 12 | +# Kept out of ci-macos.yml deliberately: that job asserts mcpp's default quiet |
| 13 | +# output shape and tacking a differently-shaped leg onto it has broken that |
| 14 | +# assertion before. |
| 15 | + |
| 16 | +on: |
| 17 | + push: |
| 18 | + branches: [ main ] |
| 19 | + pull_request: |
| 20 | + branches: [ main ] |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: ci-macos-ios-${{ github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + ios-host-surface: |
| 29 | + name: iOS - what this runner actually provides |
| 30 | + runs-on: macos-15 |
| 31 | + timeout-minutes: 30 |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + - uses: ./.github/actions/setup-macos-llvm |
| 35 | + |
| 36 | + # THE PREMISE, STATED AND THEN MEASURED. The design record schedules the |
| 37 | + # iOS rows on one assumption: that a GitHub macOS runner ships both an |
| 38 | + # iOS SDK and a bootable simulator. If it ships the SDK but no simulator, |
| 39 | + # the device row is still verifiable here and the two simulator rows |
| 40 | + # become a local-only claim -- which changes the tier they can reach and |
| 41 | + # nothing else. This step is the difference between those two worlds. |
| 42 | + - name: "Host surface: the two located SDKs and the simulator runtime" |
| 43 | + run: | |
| 44 | + set -x |
| 45 | + xcode-select -p |
| 46 | + xcrun --sdk iphoneos --show-sdk-path |
| 47 | + xcrun --sdk iphoneos --show-sdk-version |
| 48 | + xcrun --sdk iphonesimulator --show-sdk-path |
| 49 | + xcrun --sdk iphonesimulator --show-sdk-version |
| 50 | + set +x |
| 51 | + echo "--- runtimes ---" |
| 52 | + xcrun simctl list runtimes |
| 53 | + echo "--- devices available ---" |
| 54 | + xcrun simctl list devices available |
| 55 | +
|
| 56 | + # WHETHER A BARE MACH-O CAN BE RUN AT ALL, which decides how much the |
| 57 | + # runner program has to do. `simctl launch` needs an installed .app |
| 58 | + # bundle; `simctl spawn` takes an executable. If spawn works, the |
| 59 | + # `simctl-run` program is a boot-and-spawn wrapper; if it does not, it |
| 60 | + # has to synthesise a bundle, sign it and install it. Measuring this is |
| 61 | + # cheaper than designing for the harder case. |
| 62 | + - name: "Device: is one bootable, and does spawn take a bare executable" |
| 63 | + run: | |
| 64 | + set -uo pipefail |
| 65 | + UDID=$(xcrun simctl list devices available \ |
| 66 | + | grep -A50 -- '-- iOS' \ |
| 67 | + | grep -m1 -oE '[0-9A-F]{8}-[0-9A-F-]{27}' || true) |
| 68 | + echo "udid=[$UDID]" |
| 69 | + if [ -z "$UDID" ]; then |
| 70 | + echo "NO-IOS-SIMULATOR-DEVICE" |
| 71 | + exit 0 |
| 72 | + fi |
| 73 | + xcrun simctl boot "$UDID" || true |
| 74 | + xcrun simctl bootstatus "$UDID" -b || true |
| 75 | + cat > /tmp/hello.cpp << 'CPP' |
| 76 | + #include <cstdio> |
| 77 | + int main() { std::puts("1-2-3"); return 0; } |
| 78 | + CPP |
| 79 | + SDK=$(xcrun --sdk iphonesimulator --show-sdk-path) |
| 80 | + "$LLVM_ROOT/bin/clang++" -std=c++23 \ |
| 81 | + -target arm64-apple-ios18.0-simulator \ |
| 82 | + -isysroot "$SDK" -o /tmp/hello /tmp/hello.cpp |
| 83 | + file /tmp/hello |
| 84 | + otool -l /tmp/hello | grep -A5 LC_BUILD_VERSION || true |
| 85 | + echo "--- simctl spawn on a bare Mach-O ---" |
| 86 | + if xcrun simctl spawn "$UDID" /tmp/hello; then |
| 87 | + echo "SPAWN-OK" |
| 88 | + else |
| 89 | + echo "SPAWN-FAILED exit=$?" |
| 90 | + fi |
| 91 | +
|
| 92 | + # THE DEVICE ROW'S ARTEFACT. Nothing runs it here -- that needs a |
| 93 | + # signature the developer owns -- so the claim is about the ARTEFACT: |
| 94 | + # arm64 Mach-O naming the iOS platform in LC_BUILD_VERSION. An artefact |
| 95 | + # that says MACOS there is the failure this leg exists to catch, and it |
| 96 | + # is invisible to a build that merely succeeds. |
| 97 | + - name: "Device: the artefact names the iOS platform" |
| 98 | + run: | |
| 99 | + set -euo pipefail |
| 100 | + cat > /tmp/dev.cpp << 'CPP' |
| 101 | + #include <cstdio> |
| 102 | + int main() { std::puts("1-2-3"); return 0; } |
| 103 | + CPP |
| 104 | + SDK=$(xcrun --sdk iphoneos --show-sdk-path) |
| 105 | + "$LLVM_ROOT/bin/clang++" -std=c++23 -target arm64-apple-ios18.0 \ |
| 106 | + -isysroot "$SDK" -o /tmp/dev /tmp/dev.cpp |
| 107 | + file /tmp/dev |
| 108 | + otool -l /tmp/dev | grep -A5 LC_BUILD_VERSION |
| 109 | +
|
| 110 | + # THE C++ RUNTIME QUESTION, WHICH IS THE ONE THAT CAN SINK THIS. macOS |
| 111 | + # links the PAYLOAD's static libc++ so that mcpp's deployment floor is |
| 112 | + # real. That archive is built for macOS, and ld64 refuses an object built |
| 113 | + # for one platform in a link for another -- so iOS may have to take |
| 114 | + # libc++ from the SDK instead. Both are tried here, because "which one |
| 115 | + # works" is the fact the flag builder needs and neither answer can be |
| 116 | + # reasoned out from a Linux desk. |
| 117 | + - name: "C++ runtime: SDK libc++ versus the payload static archive" |
| 118 | + run: | |
| 119 | + set -x |
| 120 | + SDK=$(xcrun --sdk iphoneos --show-sdk-path) |
| 121 | + cat > /tmp/cxx.cpp << 'CPP' |
| 122 | + #include <string> |
| 123 | + #include <cstdio> |
| 124 | + int main() { std::string s = "1-2-3"; std::puts(s.c_str()); return 0; } |
| 125 | + CPP |
| 126 | + echo "--- (a) SDK libc++, dynamic ---" |
| 127 | + if "$LLVM_ROOT/bin/clang++" -std=c++23 -target arm64-apple-ios18.0 \ |
| 128 | + -isysroot "$SDK" -o /tmp/cxx-sdk /tmp/cxx.cpp; then |
| 129 | + otool -L /tmp/cxx-sdk |
| 130 | + echo "SDK-LIBCXX-OK" |
| 131 | + else |
| 132 | + echo "SDK-LIBCXX-FAILED" |
| 133 | + fi |
| 134 | + echo "--- (b) payload static libc++ ---" |
| 135 | + if "$LLVM_ROOT/bin/clang++" -std=c++23 -target arm64-apple-ios18.0 \ |
| 136 | + -isysroot "$SDK" -nostdlib++ \ |
| 137 | + "$LLVM_ROOT/lib/libc++.a" "$LLVM_ROOT/lib/libc++abi.a" \ |
| 138 | + -o /tmp/cxx-static /tmp/cxx.cpp; then |
| 139 | + echo "PAYLOAD-STATIC-OK" |
| 140 | + else |
| 141 | + echo "PAYLOAD-STATIC-FAILED" |
| 142 | + fi |
| 143 | + set +x |
| 144 | +
|
| 145 | + # `import std` FOR iOS, which is mcpp's default and therefore the real |
| 146 | + # bar. The module is precompiled from the PAYLOAD's libc++ headers |
| 147 | + # against the LOCATED SDK's C library -- the same split macOS already |
| 148 | + # uses, with a second SDK. If this cannot be made to work the iOS rows |
| 149 | + # are a non-module tier and the documentation has to say so. |
| 150 | + - name: "import std: precompile against the located SDK" |
| 151 | + run: | |
| 152 | + set -x |
| 153 | + SDK=$(xcrun --sdk iphoneos --show-sdk-path) |
| 154 | + STD_CPPM=$(find "$LLVM_ROOT" -name 'std.cppm' | head -1) |
| 155 | + echo "std.cppm=$STD_CPPM" |
| 156 | + MODDIR=$(dirname "$STD_CPPM") |
| 157 | + if "$LLVM_ROOT/bin/clang++" -std=c++23 -target arm64-apple-ios18.0 \ |
| 158 | + -isysroot "$SDK" -Wno-reserved-module-identifier \ |
| 159 | + -Xclang -emit-reduced-module-interface \ |
| 160 | + --precompile -o /tmp/std.pcm "$STD_CPPM" -I"$MODDIR"; then |
| 161 | + echo "PRECOMPILE-OK" |
| 162 | + else |
| 163 | + echo "PRECOMPILE-FAILED" |
| 164 | + fi |
| 165 | + cat > /tmp/mod.cpp << 'CPP' |
| 166 | + import std; |
| 167 | + int main() { std::println("1-2-3"); return 0; } |
| 168 | + CPP |
| 169 | + if "$LLVM_ROOT/bin/clang++" -std=c++23 -target arm64-apple-ios18.0 \ |
| 170 | + -isysroot "$SDK" -fmodule-file=std=/tmp/std.pcm \ |
| 171 | + -o /tmp/mod /tmp/mod.cpp /tmp/std.pcm; then |
| 172 | + echo "MODULE-LINK-OK" |
| 173 | + else |
| 174 | + echo "MODULE-LINK-FAILED" |
| 175 | + fi |
| 176 | + file /tmp/mod || true |
| 177 | + set +x |
0 commit comments