SERVER-125758: Fix missing sysroot warning on macos cross compilation (#52906)

GitOrigin-RevId: dfcd7b9ba79da74ff44f51c3f16d079a5e65c435
This commit is contained in:
Andrew Bradshaw 2026-04-29 16:39:31 -07:00 committed by MongoDB Bot
parent 3598e6212f
commit 82f2e078d6
3 changed files with 53 additions and 1 deletions

View File

@ -342,6 +342,7 @@ single_version_override(
"//bazel/rules_rust:ppc64le_platform.patch",
"//bazel/rules_rust:ppc64le_crates.patch",
"//bazel/rules_rust:ppc64le_cargo_bazel_url.patch",
"//bazel/rules_rust:cargo_build_script_pwd_flags.patch",
],
version = "0.69.0",
)

2
MODULE.bazel.lock generated
View File

@ -2002,7 +2002,7 @@
},
"@@rules_rust~//crate_universe/private:internal_extensions.bzl%cu_nr": {
"general": {
"bzlTransitiveDigest": "L9rxpG84287VYpuRM8hACDZ7jT04aXbaoJAQWk6Gf+Q=",
"bzlTransitiveDigest": "FQ/5h7l7rXUA0H+5hi0FxVFsYGuS9xzfQf72tPmbCOE=",
"usagesDigest": "jdsFFevZIrOcSfuuZxyovS/wXbhPLIa/eBqyNOiTP98=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},

View File

@ -0,0 +1,51 @@
--- cargo/private/cargo_build_script.bzl
+++ cargo/private/cargo_build_script.bzl
@@ -214,6 +214,39 @@
return res
+def _pwd_flags_isysroot(args):
+ """Prefix execroot-relative paths of -isysroot arguments with ${pwd}.
+
+ Args:
+ args (list): List of tool arguments.
+
+ Returns:
+ list: The modified argument list.
+ """
+ res = []
+ fix_next_arg = False
+ for arg in args:
+ if fix_next_arg and not paths.is_absolute(arg):
+ res.append("${{pwd}}/{}".format(arg))
+ else:
+ res.append(arg)
+
+ fix_next_arg = arg == "-isysroot"
+
+ return res
+
+def _pwd_flags_framework(args):
+ """Prefix execroot-relative paths of -F<path> arguments with ${pwd}."""
+ res = []
+ for arg in args:
+ if arg.startswith("-F") and len(arg) > 2:
+ path = arg[2:]
+ if not paths.is_absolute(path):
+ res.append("-F${{pwd}}/{}".format(path))
+ continue
+ res.append(arg)
+ return res
+
def _pwd_flags_fsanitize_ignorelist(args):
"""Prefix execroot-relative paths of known arguments with ${pwd}.
@@ -233,7 +266,7 @@
return res
def _pwd_flags(args):
- return _pwd_flags_fsanitize_ignorelist(_pwd_flags_isystem(_pwd_flags_bindir(_pwd_flags_sysroot(args))))
+ return _pwd_flags_framework(_pwd_flags_isysroot(_pwd_flags_fsanitize_ignorelist(_pwd_flags_isystem(_pwd_flags_bindir(_pwd_flags_sysroot(args))))))
def _feature_enabled(ctx, feature_name, default = False):
"""Check if a feature is enabled.