Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/evidence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,10 @@ jobs:
mkdir -p "$det"
first_root="$(bazel info "${flags[@]}" execution_root | tr -d '\r')"
second_root="$(bazel "--output_base=$base" info "${flags[@]}" execution_root | tr -d '\r')"
bazel cquery --noshow_progress --output=files "${patterns[@]}" "${flags[@]}" | tr -d '\r' > "$det/first.txt"
bazel "--output_base=$base" cquery --noshow_progress --output=files "${patterns[@]}" "${flags[@]}" | tr -d '\r' > "$det/relocated.txt"
# cquery takes one expression. evidence_inputs.rs joins the scope with
# single spaces and only allows // or @rules_dx_ patterns, so a union is safe.
bazel cquery --noshow_progress --output=files "${DX_SCOPE// / + }" "${flags[@]}" | tr -d '\r' > "$det/first.txt"
bazel "--output_base=$base" cquery --noshow_progress --output=files "${DX_SCOPE// / + }" "${flags[@]}" | tr -d '\r' > "$det/relocated.txt"
sort -u "$det/first.txt" "$det/relocated.txt" > "$det/files.txt"
while read -r f; do
[ -d "$first_root/$f" ] && continue
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ single_version_override(
"//patches/rules_rust:pipelined_rmeta_path.patch",
"//patches/rules_rust:crate_universe_root_lookup.patch",
"//patches/rules_rust:exec_cc_toolchain_env.patch",
"//patches/rules_rust:msvc_pdb_output.patch",
],
version = "0.75.0",
)
Expand Down
1 change: 1 addition & 0 deletions cli/adopt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ dx_rust_crate(
"//patches/rules_rust:pipelined_rmeta_path.patch",
"//patches/rules_rust:crate_universe_root_lookup.patch",
"//patches/rules_rust:exec_cc_toolchain_env.patch",
"//patches/rules_rust:msvc_pdb_output.patch",
"//patches/llvm:libunwind_copy.patch",
"//patches/llvm:clang_cl_crt_default_lib.patch",
"//patches/windows_support:host_tools.patch",
Expand Down
6 changes: 5 additions & 1 deletion cli/adopt/src/overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ pub const OVERRIDES: &[Override] = &[
file: "exec_cc_toolchain_env.patch",
content: include_str!("../../../patches/rules_rust/exec_cc_toolchain_env.patch"),
},
OverridePatch {
file: "msvc_pdb_output.patch",
content: include_str!("../../../patches/rules_rust/msvc_pdb_output.patch"),
},
],
},
Override {
Expand Down Expand Up @@ -946,7 +950,7 @@ mod tests {
"\nsingle_version_override(\n module_name = \"aspect_rules_ts\",\n patch_strip = 1,\n patches = [\"//third_party/rules_dx:aspect_rules_ts.typecheck_root_dir.patch\"],\n version = \"3.10.1\",\n)\n"
));
assert!(rendered.contains(
" patches = [\n \"//third_party/rules_dx:rules_rust.clippy_metadata_inputs.patch\",\n \"//third_party/rules_dx:rules_rust.pipelined_rmeta_path.patch\",\n \"//third_party/rules_dx:rules_rust.crate_universe_root_lookup.patch\",\n \"//third_party/rules_dx:rules_rust.exec_cc_toolchain_env.patch\",\n ],\n"
" patches = [\n \"//third_party/rules_dx:rules_rust.clippy_metadata_inputs.patch\",\n \"//third_party/rules_dx:rules_rust.pipelined_rmeta_path.patch\",\n \"//third_party/rules_dx:rules_rust.crate_universe_root_lookup.patch\",\n \"//third_party/rules_dx:rules_rust.exec_cc_toolchain_env.patch\",\n \"//third_party/rules_dx:rules_rust.msvc_pdb_output.patch\",\n ],\n"
));
assert!(rendered.contains(
r#"
Expand Down
1 change: 1 addition & 0 deletions families/android/third_party/rules_dx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports_files([
"rules_rust.clippy_metadata_inputs.patch",
"rules_rust.crate_universe_root_lookup.patch",
"rules_rust.exec_cc_toolchain_env.patch",
"rules_rust.msvc_pdb_output.patch",
"rules_rust.pipelined_rmeta_path.patch",
"windows_support.host_tools.patch",
"windows_support.hostarm64_packages.patch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ single_version_override(
"//third_party/rules_dx:rules_rust.pipelined_rmeta_path.patch",
"//third_party/rules_dx:rules_rust.crate_universe_root_lookup.patch",
"//third_party/rules_dx:rules_rust.exec_cc_toolchain_env.patch",
"//third_party/rules_dx:rules_rust.msvc_pdb_output.patch",
],
version = "0.75.0",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -2048,7 +2048,9 @@
pdb_file = None
dsym_folder = None
if crate_info.type in ("cdylib", "bin") and not experimental_use_cc_common_link:
- if toolchain.target_abi == "msvc" and compilation_mode.strip_level == "none":
+ # rustc ignores -Cstrip on MSVC and always links with /DEBUG, so the PDB is written
+ # whatever the strip level (rust-lang/rust#115120).
+ if toolchain.target_abi == "msvc":
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"]:
1 change: 1 addition & 0 deletions families/apple/third_party/rules_dx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports_files([
"rules_rust.clippy_metadata_inputs.patch",
"rules_rust.crate_universe_root_lookup.patch",
"rules_rust.exec_cc_toolchain_env.patch",
"rules_rust.msvc_pdb_output.patch",
"rules_rust.pipelined_rmeta_path.patch",
"windows_support.host_tools.patch",
"windows_support.hostarm64_packages.patch",
Expand Down
1 change: 1 addition & 0 deletions families/apple/third_party/rules_dx/rules_dx.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ single_version_override(
"//third_party/rules_dx:rules_rust.pipelined_rmeta_path.patch",
"//third_party/rules_dx:rules_rust.crate_universe_root_lookup.patch",
"//third_party/rules_dx:rules_rust.exec_cc_toolchain_env.patch",
"//third_party/rules_dx:rules_rust.msvc_pdb_output.patch",
],
version = "0.75.0",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -2048,7 +2048,9 @@
pdb_file = None
dsym_folder = None
if crate_info.type in ("cdylib", "bin") and not experimental_use_cc_common_link:
- if toolchain.target_abi == "msvc" and compilation_mode.strip_level == "none":
+ # rustc ignores -Cstrip on MSVC and always links with /DEBUG, so the PDB is written
+ # whatever the strip level (rust-lang/rust#115120).
+ if toolchain.target_abi == "msvc":
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"]:
1 change: 1 addition & 0 deletions families/beam/third_party/rules_dx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ exports_files([
"rules_rust.clippy_metadata_inputs.patch",
"rules_rust.crate_universe_root_lookup.patch",
"rules_rust.exec_cc_toolchain_env.patch",
"rules_rust.msvc_pdb_output.patch",
"rules_rust.pipelined_rmeta_path.patch",
"windows_support.host_tools.patch",
"windows_support.hostarm64_packages.patch",
Expand Down
1 change: 1 addition & 0 deletions families/beam/third_party/rules_dx/rules_dx.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ single_version_override(
"//third_party/rules_dx:rules_rust.pipelined_rmeta_path.patch",
"//third_party/rules_dx:rules_rust.crate_universe_root_lookup.patch",
"//third_party/rules_dx:rules_rust.exec_cc_toolchain_env.patch",
"//third_party/rules_dx:rules_rust.msvc_pdb_output.patch",
],
version = "0.75.0",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -2048,7 +2048,9 @@
pdb_file = None
dsym_folder = None
if crate_info.type in ("cdylib", "bin") and not experimental_use_cc_common_link:
- if toolchain.target_abi == "msvc" and compilation_mode.strip_level == "none":
+ # rustc ignores -Cstrip on MSVC and always links with /DEBUG, so the PDB is written
+ # whatever the strip level (rust-lang/rust#115120).
+ if toolchain.target_abi == "msvc":
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"]:
1 change: 1 addition & 0 deletions families/dotnet/third_party/rules_dx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports_files([
"rules_rust.clippy_metadata_inputs.patch",
"rules_rust.crate_universe_root_lookup.patch",
"rules_rust.exec_cc_toolchain_env.patch",
"rules_rust.msvc_pdb_output.patch",
"rules_rust.pipelined_rmeta_path.patch",
"windows_support.host_tools.patch",
"windows_support.hostarm64_packages.patch",
Expand Down
1 change: 1 addition & 0 deletions families/dotnet/third_party/rules_dx/rules_dx.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ single_version_override(
"//third_party/rules_dx:rules_rust.pipelined_rmeta_path.patch",
"//third_party/rules_dx:rules_rust.crate_universe_root_lookup.patch",
"//third_party/rules_dx:rules_rust.exec_cc_toolchain_env.patch",
"//third_party/rules_dx:rules_rust.msvc_pdb_output.patch",
],
version = "0.75.0",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -2048,7 +2048,9 @@
pdb_file = None
dsym_folder = None
if crate_info.type in ("cdylib", "bin") and not experimental_use_cc_common_link:
- if toolchain.target_abi == "msvc" and compilation_mode.strip_level == "none":
+ # rustc ignores -Cstrip on MSVC and always links with /DEBUG, so the PDB is written
+ # whatever the strip level (rust-lang/rust#115120).
+ if toolchain.target_abi == "msvc":
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"]:
1 change: 1 addition & 0 deletions families/jvm/third_party/rules_dx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ exports_files([
"rules_rust.clippy_metadata_inputs.patch",
"rules_rust.crate_universe_root_lookup.patch",
"rules_rust.exec_cc_toolchain_env.patch",
"rules_rust.msvc_pdb_output.patch",
"rules_rust.pipelined_rmeta_path.patch",
"windows_support.host_tools.patch",
"windows_support.hostarm64_packages.patch",
Expand Down
1 change: 1 addition & 0 deletions families/jvm/third_party/rules_dx/rules_dx.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ single_version_override(
"//third_party/rules_dx:rules_rust.pipelined_rmeta_path.patch",
"//third_party/rules_dx:rules_rust.crate_universe_root_lookup.patch",
"//third_party/rules_dx:rules_rust.exec_cc_toolchain_env.patch",
"//third_party/rules_dx:rules_rust.msvc_pdb_output.patch",
],
version = "0.75.0",
)
Expand Down
13 changes: 13 additions & 0 deletions families/jvm/third_party/rules_dx/rules_rust.msvc_pdb_output.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -2048,7 +2048,9 @@
pdb_file = None
dsym_folder = None
if crate_info.type in ("cdylib", "bin") and not experimental_use_cc_common_link:
- if toolchain.target_abi == "msvc" and compilation_mode.strip_level == "none":
+ # rustc ignores -Cstrip on MSVC and always links with /DEBUG, so the PDB is written
+ # whatever the strip level (rust-lang/rust#115120).
+ if toolchain.target_abi == "msvc":
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"]:
2 changes: 1 addition & 1 deletion patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ files but leaves the `include()` out and says so on stderr. Without a

| Module | Version | Patches | Why |
| --- | --- | --- | --- |
| `rules_rust` | 0.75.0 | `clippy_metadata_inputs.patch`, `pipelined_rmeta_path.patch`, `crate_universe_root_lookup.patch`, `exec_cc_toolchain_env.patch` | Rust on Windows (MSVC stdlib link flags, bazelbuild/rules_rust#4376); clippy reads dependency `.rmeta`; the full rustc action writes its own `.rmeta` so it does not hit the read-only one from the metadata action (bazelbuild/rules_rust#3383, #3662; drop when a rules_rust release has it); `crate_universe` looks up the root `MODULE.bazel` only in the root module, so a consumer without a root `BUILD.bazel` can use `dx_crates` (#6144); build scripts get `HOST_CC`/`HOST_CXX`/`HOST_AR`/`HOST_CFLAGS`/`HOST_CXXFLAGS` from the exec cc toolchain and `TARGET_*` from the target one |
| `rules_rust` | 0.75.0 | `clippy_metadata_inputs.patch`, `pipelined_rmeta_path.patch`, `crate_universe_root_lookup.patch`, `exec_cc_toolchain_env.patch`, `msvc_pdb_output.patch` | Rust on Windows (MSVC stdlib link flags, bazelbuild/rules_rust#4376); clippy reads dependency `.rmeta`; the full rustc action writes its own `.rmeta` so it does not hit the read-only one from the metadata action (bazelbuild/rules_rust#3383, #3662; drop when a rules_rust release has it); `crate_universe` looks up the root `MODULE.bazel` only in the root module, so a consumer without a root `BUILD.bazel` can use `dx_crates` (#6144); build scripts get `HOST_CC`/`HOST_CXX`/`HOST_AR`/`HOST_CFLAGS`/`HOST_CXXFLAGS` from the exec cc toolchain and `TARGET_*` from the target one; MSVC `bin` and `cdylib` crates always declare their `.pdb`, since rustc writes it whatever the strip level (rust-lang/rust#115120) |
| `rules_android` | 0.8.0 | `bundle_keystore_properties.patch` | App Bundles with key rotation: write the oldest-signer properties file instead of reading the removed `_bundle_keystore_properties` attribute (#3739) |
| `rules_cuda` | 0.4.0-beta1 | `msvc_dlink_crt.patch`, `redist_cccl_key.patch` | `nvcc -dlink` on Windows gets the same `/MD` or `/MT` as the compile action, so rdc links do not mix LIBCMT with the dynamic CRT (#4704); CUDA 13.3+ redist manifests key CCCL as `cccl` instead of `cuda_cccl`; the helper accepts both (bazel-contrib/rules_cuda#523, merged; drop on the next release, #8365) |
| `protobuf` | 36.2 | `no_crate_universe.patch` | Drops protobuf's own `crate_universe` use so it does not clash with `dx_crates` |
Expand Down
1 change: 1 addition & 0 deletions patches/rules_rust/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports_files([
"clippy_metadata_inputs.patch",
"crate_universe_root_lookup.patch",
"exec_cc_toolchain_env.patch",
"msvc_pdb_output.patch",
"pipelined_rmeta_path.patch",
])

Expand Down
13 changes: 13 additions & 0 deletions patches/rules_rust/msvc_pdb_output.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -2048,7 +2048,9 @@
pdb_file = None
dsym_folder = None
if crate_info.type in ("cdylib", "bin") and not experimental_use_cc_common_link:
- if toolchain.target_abi == "msvc" and compilation_mode.strip_level == "none":
+ # rustc ignores -Cstrip on MSVC and always links with /DEBUG, so the PDB is written
+ # whatever the strip level (rust-lang/rust#115120).
+ if toolchain.target_abi == "msvc":
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"]:
3 changes: 2 additions & 1 deletion rust/rules/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ _CL_EXE = Label("//cc/toolchains:msvc_selected")
MSVC_LINK_FLAGS = ["-Clink-arg=kernel32.lib", "-Clink-arg=ntdll.lib"]
_MSVC_OPT = Label("//rust/rules:msvc_opt")

# rustc always passes /DEBUG; /Brepro makes the PDB GUID a content hash (#8409, #8410).
# rustc always passes /DEBUG and msvc_pdb_output.patch declares the PDB as an output;
# /Brepro makes the PDB GUID a content hash (#8409, #8410).
MSVC_OPT_LINK_FLAGS = ["-Clink-arg=/Brepro"] + REPRODUCIBLE_PDB_LINK_FLAGS
_NO_STATIC_CPP_RUNTIMES = "-static_link_cpp_runtimes"
_EXTRA_RUSTC_FLAG = str(Label("@rules_rust//rust/settings:extra_rustc_flag"))
Expand Down
Loading