mirror of
https://github.com/openai/codex.git
synced 2026-10-19 16:17:49 +00:00
Use rust-lld for Bazel Windows MSVC Rust links (#40438)
## What changed - Configure x86_64 Windows MSVC `rules_rs` toolchains to use the bundled `rust-lld` linker. - Make `rules_rust` select the configured direct linker for that target unless the toolchain explicitly prefers the C compiler driver. GitOrigin-RevId: 941a1ca42b931cbb9e1c2d68300b8a82a5250be8
This commit is contained in:
@@ -9,6 +9,7 @@ exports_files([
|
||||
"rules_rust_windows_process_wrapper_skip_temp_outputs.patch",
|
||||
"rules_cc_rusty_v8_custom_libcxx.patch",
|
||||
"rules_rs_build_script_deps_annotation.patch",
|
||||
"rules_rs_windows_msvc_linker.patch",
|
||||
"rusty_v8_prebuilt_out_dir.patch",
|
||||
"ring_windows_msvc_include_dirs.patch",
|
||||
"v8_bazel_rules.patch",
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# What: use Rust's bundled direct linker for Windows x86_64 MSVC toolchains.
|
||||
# Scope: standard and bootstrap rules_rs Rust toolchains targeting x86_64 MSVC.
|
||||
|
||||
diff --git a/rs/toolchains/declare_rustc_toolchains.bzl b/rs/toolchains/declare_rustc_toolchains.bzl
|
||||
--- a/rs/toolchains/declare_rustc_toolchains.bzl
|
||||
+++ b/rs/toolchains/declare_rustc_toolchains.bzl
|
||||
@@ -88,6 +88,7 @@ def declare_rustc_toolchains(
|
||||
llvm_cov = "@llvm//tools:llvm-cov",
|
||||
llvm_profdata = "@llvm//tools:llvm-profdata",
|
||||
linker = select({
|
||||
+ "@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": "{}rust-lld".format(rustc_repo_label),
|
||||
"@platforms//cpu:wasm32": "{}rust-lld".format(rustc_repo_label),
|
||||
"@platforms//cpu:wasm64": "{}rust-lld".format(rustc_repo_label),
|
||||
"//conditions:default": None,
|
||||
@@ -1,5 +1,18 @@
|
||||
--- a/rust/private/rustc.bzl
|
||||
+++ b/rust/private/rustc.bzl
|
||||
@@ -438,4 +438,11 @@
|
||||
use_bpf_linker = toolchain.target_arch in ("bpfeb", "bpfel") and toolchain.linker
|
||||
- if not ld or toolchain.linker_preference == "rust" or use_bpf_linker:
|
||||
+ use_windows_msvc_linker = (
|
||||
+ toolchain.target_arch == "x86_64" and
|
||||
+ toolchain.target_os == "windows" and
|
||||
+ toolchain.target_abi == "msvc" and
|
||||
+ toolchain.linker != None and
|
||||
+ toolchain.linker_preference != "cc"
|
||||
+ )
|
||||
+ if not ld or toolchain.linker_preference == "rust" or use_bpf_linker or use_windows_msvc_linker:
|
||||
ld = toolchain.linker.path
|
||||
ld_is_direct_driver = toolchain.linker_type == "direct"
|
||||
@@ -468,11 +468,25 @@
|
||||
filtered_args.append(version)
|
||||
# Keep library search path flags
|
||||
|
||||
Reference in New Issue
Block a user