[bazel] Upgrade some rulesets in preparation for enabling windows (#11109)

This commit is contained in:
zbarsky-openai
2026-02-08 13:40:32 -08:00
committed by GitHub
parent 409ec76fbc
commit 44a1355133
11 changed files with 244 additions and 299 deletions
-34
View File
@@ -1,34 +0,0 @@
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
index a28ad50b7..af627fe50 100644
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -2361,19 +2361,19 @@ def _get_make_link_flag_funcs(target_os, target_abi, use_direct_link_driver):
- callable: The function for producing link args.
- callable: The function for formatting link library names.
"""
+
+ get_lib_name = get_lib_name_default
+
if target_os == "windows":
- make_link_flags_windows_msvc = _make_link_flags_windows_msvc_direct if use_direct_link_driver else _make_link_flags_windows_msvc_indirect
- make_link_flags_windows_gnu = _make_link_flags_windows_gnu_direct if use_direct_link_driver else _make_link_flags_windows_gnu_indirect
- make_link_flags = make_link_flags_windows_msvc if target_abi == "msvc" else make_link_flags_windows_gnu
- get_lib_name = get_lib_name_for_windows
+ if target_abi == "msvc":
+ make_link_flags = _make_link_flags_windows_msvc_direct if use_direct_link_driver else _make_link_flags_windows_msvc_indirect
+ get_lib_name = get_lib_name_for_windows
+ else:
+ make_link_flags = _make_link_flags_windows_gnu_direct if use_direct_link_driver else _make_link_flags_windows_gnu_indirect
elif target_os.startswith(("mac", "darwin", "ios")):
- make_link_flags_darwin = _make_link_flags_darwin_direct if use_direct_link_driver else _make_link_flags_darwin_indirect
- make_link_flags = make_link_flags_darwin
- get_lib_name = get_lib_name_default
+ make_link_flags = _make_link_flags_darwin_direct if use_direct_link_driver else _make_link_flags_darwin_indirect
else:
- make_link_flags_default = _make_link_flags_default_direct if use_direct_link_driver else _make_link_flags_default_indirect
- make_link_flags = make_link_flags_default
- get_lib_name = get_lib_name_default
+ make_link_flags = _make_link_flags_default_direct if use_direct_link_driver else _make_link_flags_default_indirect
return (make_link_flags, get_lib_name)
-27
View File
@@ -1,27 +0,0 @@
diff -uNr rust/platform/triple_mappings.bzl rust/platform/triple_mappings.bzl
--- a/rust/platform/triple_mappings.bzl
+++ b/rust/platform/triple_mappings.bzl
@@ -1,6 +1,7 @@
"""Helpers for constructing supported Rust platform triples"""
load("//rust/platform:triple.bzl", "triple")
+load("@@toolchains_llvm_bootstrapped+//constraints/libc:libc_versions.bzl", "DEFAULT_LIBC")
def _support(*, std = False, host_tools = False):
"""Identify the type of support an associated platform triple has.
@@ -334,10 +335,11 @@
all_abi_constraints = []
- # add constraints for MUSL static compilation and linking
- # to separate the MUSL from the non-MUSL toolchain on x86_64
- # if abi == "musl" and system == "linux" and arch == "x86_64":
- # all_abi_constraints.append("//rust/platform/constraints:musl_on")
+ if system == "linux":
+ if abi == "musl":
+ all_abi_constraints.append("@@toolchains_llvm_bootstrapped+//constraints/libc:musl")
+ elif abi.startswith("gnu"):
+ all_abi_constraints.append("@@toolchains_llvm_bootstrapped+//constraints/libc:{}".format(DEFAULT_LIBC))
# add constraints for iOS + watchOS simulator and device triples
if system in ["ios", "watchos"]:
-58
View File
@@ -1,58 +0,0 @@
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
index af627fe50..d1c5142cb 100644
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -560,9 +560,12 @@ def _symlink_for_ambiguous_lib(actions, toolchain, crate_info, lib):
# Take the absolute value of hash() since it could be negative.
path_hash = abs(hash(lib.path))
- lib_name = get_lib_name_for_windows(lib) if toolchain.target_os.startswith("windows") else get_lib_name_default(lib)
-
- if toolchain.target_os.startswith("windows"):
+ if toolchain.target_os.startswith("windows") and toolchain.target_abi == "msvc":
+ lib_name = get_lib_name_for_windows(lib)
+ else:
+ lib_name = get_lib_name_default(lib)
+
+ if toolchain.target_os.startswith("windows") and toolchain.target_abi == "msvc":
prefix = ""
extension = ".lib"
elif lib_name.endswith(".pic"):
@@ -1495,7 +1498,7 @@ def rustc_compile_action(
pdb_file = None
dsym_folder = None
if crate_info.type in ("cdylib", "bin") and not experimental_use_cc_common_link:
- if toolchain.target_os == "windows" and compilation_mode.strip_level == "none":
+ if toolchain.target_os == "windows" and toolchain.target_abi == "msvc" and compilation_mode.strip_level == "none":
pdb_file = ctx.actions.declare_file(crate_info.output.basename[:-len(crate_info.output.extension)] + "pdb", sibling = crate_info.output)
action_outputs.append(pdb_file)
elif toolchain.target_os in ["macos", "darwin"]:
@@ -1626,7 +1629,7 @@ def rustc_compile_action(
additional_linker_outputs = []
- if crate_info.type in ("cdylib", "bin") and cc_common.is_enabled(feature_configuration = feature_configuration, feature_name = "generate_pdb_file"):
+ if crate_info.type in ("cdylib", "bin") and toolchain.target_abi == "msvc" and cc_common.is_enabled(feature_configuration = feature_configuration, feature_name = "generate_pdb_file"):
pdb_file = ctx.actions.declare_file(crate_info.output.basename[:-len(crate_info.output.extension)] + "pdb", sibling = crate_info.output)
additional_linker_outputs.append(pdb_file)
@@ -2248,8 +2251,8 @@ def _portable_link_flags(lib, use_pic, ambiguous_libs, get_lib_name, for_windows
]
else:
return [
- "-lstatic=%s" % get_lib_name(artifact),
- "-Clink-arg=-l{}".format(artifact.basename),
+ "-lstatic=%s" % get_lib_name(artifact),
+ "-Clink-arg=-l{}".format(get_lib_name(artifact)),
]
else:
return [
@@ -2281,7 +2284,8 @@ def _make_link_flags_windows(make_link_flags_args, flavor_msvc, use_direct_drive
("-Clink-arg=%s--no-whole-archive" % prefix),
])
elif include_link_flags:
- ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs, get_lib_name_for_windows, for_windows = True, flavor_msvc = flavor_msvc))
+ get_name_fn = get_lib_name_for_windows if flavor_msvc else get_lib_name_default
+ ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs, get_name_fn, for_windows = True, flavor_msvc = flavor_msvc))
_add_user_link_flags(ret, linker_input)
return ret
@@ -0,0 +1,12 @@
diff --git a/extensions/osx.bzl b/extensions/osx.bzl
index 1e25dc0..8f3e2f9 100644
--- a/extensions/osx.bzl
+++ b/extensions/osx.bzl
@@ -41,6 +41,7 @@ def _osx_extension_impl(mctx):
for framework in frameworks:
includes.append("System/Library/Frameworks/%s.framework/*" % framework)
+ includes.append("System/Library/PrivateFrameworks/%s.framework/*" % framework)
# The following directories are unused, deprecated, or private headers.
# These components: