45 lines
1.8 KiB
Plaintext
45 lines
1.8 KiB
Plaintext
# Copyright (c) 2026 The Brave Authors. All rights reserved.
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
# You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
# Hermetic host toolchain for cargo invocations (see `build_crate.gni` and
|
|
# `rust_to_wasm.gni`). On macOS, point cargo's host build scripts and linker at
|
|
# the hermetic Clang/SDK instead of letting cc-rs discover the system Xcode via
|
|
# `xcrun`. `rust_host_inputs` and `rust_host_response_file_contents` are empty on
|
|
# every other host, so callers can append them unconditionally.
|
|
|
|
rust_host_inputs = []
|
|
rust_host_response_file_contents = []
|
|
|
|
if (host_os == "mac" && current_toolchain == host_toolchain) {
|
|
import("//build/config/clang/clang.gni")
|
|
import("//build/config/mac/mac_sdk.gni")
|
|
|
|
_clang_bin = rebase_path("$clang_base_path/bin")
|
|
|
|
assert(host_cpu == "arm64" || host_cpu == "x64")
|
|
if (host_cpu == "arm64") {
|
|
_rust_host_triple = "AARCH64_APPLE_DARWIN"
|
|
} else {
|
|
_rust_host_triple = "X86_64_APPLE_DARWIN"
|
|
}
|
|
|
|
rust_host_inputs += [ "//brave/build/rust/rust_host_linker.py" ]
|
|
rust_host_response_file_contents += [
|
|
"AR=$_clang_bin/llvm-ar",
|
|
|
|
# Route the host link through a wrapper that drives clang with the hermetic
|
|
# `ld64.lld`. This is `_LINKER` rather than a rustflag deliberately: when
|
|
# cargo cross-compiles (e.g. `rust_to_wasm`), only `_LINKER` reaches the host
|
|
# build scripts without leaking into the target link. See the wrapper's
|
|
# module docstring for the full rationale.
|
|
"CARGO_TARGET_${_rust_host_triple}_LINKER=" +
|
|
rebase_path("//brave/build/rust/rust_host_linker.py"),
|
|
"CC=$_clang_bin/clang",
|
|
"CXX=$_clang_bin/clang++",
|
|
"MACOSX_DEPLOYMENT_TARGET=$mac_deployment_target",
|
|
"SDKROOT=" + rebase_path(mac_sdk_path),
|
|
]
|
|
}
|