From c9f63e280e08dc8093b902ee23569e3b7cb11956 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Wed, 29 Jul 2026 19:31:22 +0800 Subject: [PATCH] boring-sys: add tvOS target support 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 #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 --- .github/workflows/ci.yml | 14 ++++++++++++++ boring-sys/build/main.rs | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cf906e79..97bc67a68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,8 @@ jobs: - aarch64-ios - aarch64-ios-sim - x86_64-ios + - aarch64-tvos + - aarch64-tvos-sim - i686-linux - arm-linux - aarch64-linux @@ -159,6 +161,18 @@ jobs: check_only: true custom_env: IPHONEOS_DEPLOYMENT_TARGET: 17.5 + - thing: aarch64-tvos + target: aarch64-apple-tvos + os: macos-latest + check_only: true + custom_env: + TVOS_DEPLOYMENT_TARGET: 17.5 + - thing: aarch64-tvos-sim + target: aarch64-apple-tvos-sim + os: macos-latest + check_only: true + custom_env: + TVOS_DEPLOYMENT_TARGET: 17.5 - thing: i686-linux target: i686-unknown-linux-gnu rust: stable diff --git a/boring-sys/build/main.rs b/boring-sys/build/main.rs index 07d0f1c1f..9e97b764e 100644 --- a/boring-sys/build/main.rs +++ b/boring-sys/build/main.rs @@ -17,7 +17,7 @@ fn should_use_cmake_cross_compilation(config: &Config) -> bool { return false; } match config.target_os.as_str() { - "macos" | "ios" => { + "macos" | "ios" | "tvos" => { // Cross-compiling for Apple platforms on macOS is supported using the normal Xcode // tools, along with the settings from `cmake_params_apple`. !config.host.ends_with("-darwin") @@ -69,6 +69,31 @@ const CMAKE_PARAMS_APPLE: &[(&str, &[(&str, &str)])] = &[ ("CMAKE_MACOSX_BUNDLE", "OFF"), ], ), + // tvOS + ( + "aarch64-apple-tvos", + &[ + ("CMAKE_OSX_ARCHITECTURES", "arm64"), + ("CMAKE_OSX_SYSROOT", "appletvos"), + ("CMAKE_MACOSX_BUNDLE", "OFF"), + ], + ), + ( + "aarch64-apple-tvos-sim", + &[ + ("CMAKE_OSX_ARCHITECTURES", "arm64"), + ("CMAKE_OSX_SYSROOT", "appletvsimulator"), + ("CMAKE_MACOSX_BUNDLE", "OFF"), + ], + ), + ( + "x86_64-apple-tvos", + &[ + ("CMAKE_OSX_ARCHITECTURES", "x86_64"), + ("CMAKE_OSX_SYSROOT", "appletvsimulator"), + ("CMAKE_MACOSX_BUNDLE", "OFF"), + ], + ), // macOS ( "aarch64-apple-darwin", @@ -308,6 +333,15 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config { boringssl_cmake.cflag(&cflag); } + "tvos" => { + // Unlike the `ios` arm above, no bitcode flag: bitcode was deprecated in + // Xcode 14 and the tvOS targets postdate it, so the SDK never wants it. + for (name, value) in cmake_params_apple(config) { + eprintln!("tvos arch={} add {}={}", config.target_arch, name, value); + boringssl_cmake.define(name, value); + } + } + "windows" if config.host.contains("windows") => { // BoringSSL's CMakeLists.txt isn't set up for cross-compiling using Visual Studio. // Disable assembly support so that it at least builds. @@ -391,7 +425,7 @@ fn get_extra_clang_args_for_bindgen(config: &Config) -> Vec { // Add platform-specific parameters. match &*config.target_os { - "ios" | "macos" => { + "ios" | "macos" | "tvos" => { // When cross-compiling for Apple targets, tell bindgen to use SDK sysroot, // and *don't* use system headers of the host macOS. let sdk = get_apple_sdk_name(config); @@ -589,7 +623,7 @@ fn get_cpp_runtime_lib(config: &Config) -> Option { } match &*config.target_os { - "macos" | "ios" | "freebsd" | "openbsd" | "android" => Some("c++".into()), + "macos" | "ios" | "tvos" | "freebsd" | "openbsd" | "android" => Some("c++".into()), _ if config.unix || config.target_env == "gnu" => Some("stdc++".into()), // TODO(rmehra): figure out how to do this for windows _ => None,