boring-sys: add tvOS target support - #519
Open
gengjiawen wants to merge 1 commit into
Open
Conversation
Building boring-sys for `aarch64-apple-tvos` / `aarch64-apple-tvos-sim` currently fails. `target_os = "tvos"` is unhandled at five places in the build script, and the failures are silent rather than loud: - `should_use_cmake_cross_compilation` falls through to `_ => true`, so a macOS -> tvOS build takes the generic cross-compilation path instead of the Xcode path added in cloudflare#187. - `CMAKE_PARAMS_APPLE` has no tvOS triples, so `cmake_params_apple` returns `&[]`. - The `target_os` match in `get_boringssl_cmake_config` has no `tvos` arm and ends in `_ => {}`, so with the empty params above no `CMAKE_OSX_SYSROOT` is ever set and CMake builds BoringSSL for the host macOS instead of the tvOS SDK. - `get_extra_clang_args_for_bindgen` has no `tvos` arm, so bindgen reads host macOS headers instead of the tvOS SDK sysroot. - `get_cpp_runtime_lib` misses `tvos`, which then matches `_ if config.unix` and links `stdc++` rather than `c++`. Add tvOS to each. `CMAKE_MACOSX_BUNDLE=OFF` matches the existing iOS entries and is required -- with the default `ON`, CMake's install step for BoringSSL's `bssl` host tool fails. No bitcode cflag for tvOS: bitcode was deprecated in Xcode 14 and the tvOS SDK never wants it, so the new arm is a plain `cmake_params_apple` loop like the `macos` one rather than being folded into the `ios` arm. `x86_64-apple-tvos` is included in the table for completeness even though it is a tier 3 target that needs `-Z build-std`; the mapping costs nothing and is what such a build would need. `arm64e-apple-tvos` is omitted, matching the table's existing treatment of arm64e. Cover both tvOS targets in the `test` job matrix alongside the existing iOS entries. That job builds with `--tests`, so the linker runs and verifies the cross-compilation -- which is what catches the `stdc++` / `c++` mistake above. `x86_64-apple-tvos` is left out because `rustup target add` has no prebuilt std for it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
aarch64-apple-tvos/aarch64-apple-tvos-simsupport toboring-sys, and covers both in CI.Why it doesn't build today
Five places in
boring-sys/build/main.rshandlemacos/iosbut fall through ontvos:should_use_cmake_cross_compilation—tvosisn't in the Apple arm, so it returnstrueeven on a darwin host. That forcesCMAKE_CROSSCOMPILING=true+CMAKE_{C,CXX,ASM}_COMPILER_TARGET, which conflicts with the Xcode-SDK path the other Apple targets take.CMAKE_PARAMS_APPLE— no tvOS rows, so noCMAKE_OSX_SYSROOT/CMAKE_OSX_ARCHITECTURES, andCMAKE_MACOSX_BUNDLEstays at its defaultON. BoringSSL'sbsslhost tool then fails at CMake install time.get_boringssl_cmake_config— no"tvos"arm, so none of the above gets applied even once the table has rows.get_extra_clang_args_for_bindgen—tvosmisses the-isysroottheios/macosarm supplies, so bindgen can't findTargetConditionals.h.get_cpp_runtime_lib— falls through to the_ => Some("stdc++")default. Apple platforms have nolibstdc++; this is a link failure, and it's the one that only shows up if you actually run the linker.Each of the five is a one-line-ish addition of
"tvos"alongside the existing Apple arms.The one deliberate asymmetry with the
iosarm: no bitcode flag. Bitcode was deprecated in Xcode 14 and the tvOS Rust targets postdate that, so the SDK never wants it.CI
Two rows added to the existing
testjob matrix, next to the iOS ones, samecheck_only: trueshape:That job's
check_onlypath runscargo build -vv --target ... --testsrather thancargo check— per its own comment, so the linker verifies the cross-compile. That matters here: item (5) above is a link error, socargo checkwould have passed while the target stayed broken.x86_64-apple-tvosgets aCMAKE_PARAMS_APPLErow too, but is not in CI. It's a Tier 3 target with no prebuilt std —rustup target add x86_64-apple-tvosfails outright — so it's only reachable via-Z build-stdon nightly. The row is there so that path works; gating CI on it would need a nightly +build-stdjob.Verification
Green on both new matrix rows: https://github.com/gengjiawen/boring/actions/runs/30448778000
-vvmakes the build-script stderr visible, so the new code path is directly observable in theTest (aarch64-tvos)log rather than merely inferred:and the resulting cmake invocation picks up the real tvOS SDK and version-min:
(
-DCMAKE_SYSTEM_NAME=tvOSalso appears in that line; that one comes from thecmakecrate's own target detection, not from this change.CMAKE_CROSSCOMPILINGis correctly absent, which is item (1) working.)Motivation
tvOS 17 made
NEPacketTunnelProvideravailable, so Rust network stacks that were iOS-only can now target Apple TV.boring-sysis the first thing that breaks when you try.