mirror of
https://github.com/openai/codex.git
synced 2026-05-03 10:56:37 +00:00
Configure the large Rust test targets with Bazel's native shard_count while keeping rules_rust's stable test-name hash bucket assignment. This depends on hermeticbuild/rules_rs#94, which pins the rules_rust stable sharding stack, and keeps the original test labels so BuildBuddy can render Bazel's native sharded test UI. Co-authored-by: Codex <noreply@openai.com>
99 lines
4.4 KiB
Diff
99 lines
4.4 KiB
Diff
# What: keep Windows direct-linker arguments in forms link.exe/lld-link accept.
|
|
# Scope: Windows direct-driver link arg filtering and runtime library handling.
|
|
|
|
--- a/rust/private/rustc.bzl
|
|
+++ b/rust/private/rustc.bzl
|
|
@@ -501,11 +501,24 @@
|
|
filtered_args.append(version)
|
|
# Keep library search path flags
|
|
|
|
+ elif processed_arg == "-L" and i + 1 < len(link_args):
|
|
+ if ld_is_direct_driver and toolchain.target_os == "windows":
|
|
+ skip_next = True
|
|
+ continue
|
|
+ filtered_args.extend([processed_arg, link_args[i + 1]])
|
|
+ skip_next = True
|
|
+
|
|
elif processed_arg.startswith("-L"):
|
|
+ if ld_is_direct_driver and toolchain.target_os == "windows":
|
|
+ continue
|
|
filtered_args.append(processed_arg)
|
|
# Keep sysroot flags (as single or two-part arguments)
|
|
|
|
elif processed_arg == "--sysroot" or processed_arg.startswith("--sysroot="):
|
|
+ if ld_is_direct_driver and toolchain.target_os == "windows":
|
|
+ if processed_arg == "--sysroot" and i + 1 < len(link_args):
|
|
+ skip_next = True
|
|
+ continue
|
|
filtered_args.append(processed_arg)
|
|
if processed_arg == "--sysroot" and i + 1 < len(link_args):
|
|
# Two-part argument, keep the next arg too
|
|
@@ -2266,8 +2279,10 @@
|
|
use_pic,
|
|
ambiguous_libs,
|
|
get_lib_name,
|
|
+ for_windows = False,
|
|
for_darwin = False,
|
|
- flavor_msvc = False):
|
|
+ flavor_msvc = False,
|
|
+ use_direct_driver = False):
|
|
"""_summary_
|
|
|
|
Args:
|
|
@@ -2275,8 +2290,10 @@
|
|
use_pic (_type_): _description_
|
|
ambiguous_libs (_type_): _description_
|
|
get_lib_name (_type_): _description_
|
|
+ for_windows (bool, optional): _description_. Defaults to False.
|
|
for_darwin (bool, optional): _description_. Defaults to False.
|
|
flavor_msvc (bool, optional): _description_. Defaults to False.
|
|
+ use_direct_driver (bool, optional): _description_. Defaults to False.
|
|
|
|
Returns:
|
|
_type_: _description_
|
|
@@ -2320,6 +2337,11 @@
|
|
):
|
|
return [] if for_darwin else ["-lstatic=%s" % get_lib_name(artifact)]
|
|
|
|
+ if for_windows and use_direct_driver and not artifact.basename.endswith(".lib"):
|
|
+ return [
|
|
+ "-Clink-arg={}".format(artifact.path),
|
|
+ ]
|
|
+
|
|
if flavor_msvc:
|
|
return [
|
|
"-lstatic=%s" % get_lib_name(artifact),
|
|
@@ -2356,7 +2378,7 @@
|
|
])
|
|
elif include_link_flags:
|
|
get_lib_name = get_lib_name_for_windows if flavor_msvc else get_lib_name_default
|
|
- ret.extend(portable_link_flags(lib, use_pic, ambiguous_libs, get_lib_name, flavor_msvc = flavor_msvc))
|
|
+ ret.extend(portable_link_flags(lib, use_pic, ambiguous_libs, get_lib_name, for_windows = True, flavor_msvc = flavor_msvc, use_direct_driver = use_direct_driver))
|
|
|
|
# Windows toolchains can inherit POSIX defaults like -pthread from C deps,
|
|
# which fails to link with the MinGW/LLD toolchain. Drop them here.
|
|
@@ -2532,14 +2554,21 @@
|
|
else:
|
|
# For all other crate types we want to link C++ runtime library statically
|
|
# (for example libstdc++.a or libc++.a).
|
|
+ runtime_libs = cc_toolchain.static_runtime_lib(feature_configuration = feature_configuration)
|
|
+ if toolchain.target_os == "windows" and use_direct_link_driver:
|
|
+ runtime_libs = depset([
|
|
+ runtime_lib
|
|
+ for runtime_lib in runtime_libs.to_list()
|
|
+ if runtime_lib.basename.endswith(".lib")
|
|
+ ])
|
|
args.add_all(
|
|
- cc_toolchain.static_runtime_lib(feature_configuration = feature_configuration),
|
|
+ runtime_libs,
|
|
map_each = _get_dirname,
|
|
format_each = "-Lnative=%s",
|
|
)
|
|
if include_link_flags:
|
|
args.add_all(
|
|
- cc_toolchain.static_runtime_lib(feature_configuration = feature_configuration),
|
|
+ runtime_libs,
|
|
map_each = get_lib_name,
|
|
format_each = "-lstatic=%s",
|
|
)
|