diff --git a/MODULE.bazel b/MODULE.bazel index 53cf0f87b48..9ac0eef67b2 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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", ) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index e9c7d37cf26..06b9c109ab3 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -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": {}, diff --git a/bazel/rules_rust/cargo_build_script_pwd_flags.patch b/bazel/rules_rust/cargo_build_script_pwd_flags.patch new file mode 100644 index 00000000000..b7ec29e8415 --- /dev/null +++ b/bazel/rules_rust/cargo_build_script_pwd_flags.patch @@ -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 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.