Skip to content
Draft
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
17 changes: 11 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,9 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.2.16"
version = "1.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f"
dependencies = [
"jobserver",
"libc",
Expand Down Expand Up @@ -1325,6 +1325,12 @@ dependencies = [
"windows-sys 0.59.0",
]

[[package]]
name = "find-msvc-tools"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e178e4fba8a2726903f6ba98a6d221e76f9c12c650d5dc0e6afdc50677b49650"

[[package]]
name = "flate2"
version = "1.1.2"
Expand Down Expand Up @@ -3523,7 +3529,7 @@ dependencies = [
"ar_archive_writer",
"bitflags",
"bstr",
"cc",
"find-msvc-tools",
"itertools",
"libc",
"object 0.37.3",
Expand Down Expand Up @@ -4725,7 +4731,7 @@ dependencies = [
name = "rustc_windows_rc"
version = "0.0.0"
dependencies = [
"cc",
"find-msvc-tools",
]

[[package]]
Expand Down Expand Up @@ -5427,8 +5433,7 @@ version = "0.1.0"
[[package]]
name = "tikv-jemalloc-sys"
version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d"
source = "git+https://github.com/dpaoliello/jemallocator.git?branch=temp#329682034ae0b8f7cca4514146b211d7dc694c9c"
dependencies = [
"cc",
"libc",
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ codegen-units = 1

# If you want to use a crate with local modifications, you can set a path or git dependency here.
# For git dependencies, also add your source to ALLOWED_SOURCES in src/tools/tidy/src/extdeps.rs.
#[patch.crates-io]

[patch.crates-io]
tikv-jemalloc-sys = { git = 'https://github.com/dpaoliello/jemallocator.git', branch = 'temp' }
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ edition = "2024"
ar_archive_writer = "0.5"
bitflags = "2.4.1"
bstr = "1.11.3"
# `cc` updates often break things, so we pin it here. Cargo enforces "max 1 semver-compat version
# per crate", so if you change this, you need to also change it in `rustc_llvm` and `rustc_windows_rc`.
cc = "=1.2.16"
find-msvc-tools = "0.1.0"
itertools = "0.12"
pathdiff = "0.2.0"
regex = "1.4"
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
use std::process::{Output, Stdio};
use std::{env, fmt, fs, io, mem, str};

use cc::windows_registry;
use find_msvc_tools;
use itertools::Itertools;
use regex::Regex;
use rustc_arena::TypedArena;
Expand Down Expand Up @@ -877,9 +877,9 @@ fn link_natively(
// All Microsoft `link.exe` linking ror codes are
// four digit numbers in the range 1000 to 9999 inclusive
if is_msvc_link_exe && (code < 1000 || code > 9999) {
let is_vs_installed = windows_registry::find_vs_version().is_ok();
let is_vs_installed = find_msvc_tools::find_vs_version().is_ok();
let has_linker =
windows_registry::find_tool(&sess.target.arch, "link.exe").is_some();
find_msvc_tools::find_tool(&sess.target.arch, "link.exe").is_some();

sess.dcx().emit_note(errors::LinkExeUnexpectedError);

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::{env, io, iter, mem, str};

use cc::windows_registry;
use find_msvc_tools;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_metadata::{
find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library,
Expand Down Expand Up @@ -53,7 +53,7 @@ pub(crate) fn get_linker<'a>(
self_contained: bool,
target_cpu: &'a str,
) -> Box<dyn Linker + 'a> {
let msvc_tool = windows_registry::find_tool(&sess.target.arch, "link.exe");
let msvc_tool = find_msvc_tools::find_tool(&sess.target.arch, "link.exe");

// If our linker looks like a batch script on Windows then to execute this
// we'll need to spawn `cmd` explicitly. This is primarily done to handle
Expand Down Expand Up @@ -117,7 +117,6 @@ pub(crate) fn get_linker<'a>(
if sess.target.is_like_msvc
&& let Some(ref tool) = msvc_tool
{
cmd.args(tool.args());
Copy link
Contributor

@lambdageek lambdageek Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this ok? It looked to me like cc::windows_registry::find_tool can have extra arguments here, while find_msvc_tools::find_tool cannot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old windows_registry::find_tool never set any args, which is why find_msvc_tools dropped it
https://github.com/rust-lang/cc-rs/blob/3c1325b09a78827fb2beb3ea9e8f1e3f84876b64/src/windows/find_tools.rs#L359-L371

for (k, v) in tool.env() {
if k == "PATH" {
new_path.extend(env::split_paths(v));
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ libc = "0.2.73"

[build-dependencies]
# tidy-alphabetical-start
# `cc` updates often break things, so we pin it here. Cargo enforces "max 1 semver-compat version
# per crate", so if you change this, you need to also change it in `rustc_codegen_ssa` and `rustc_windows_rc`.
cc = "=1.2.16"
# `cc` updates often break things, so we pin it here.
cc = "=1.2.33"
# tidy-alphabetical-end

[features]
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_windows_rc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ edition = "2024"

[dependencies]
#tidy-alphabetical-start
# `cc` updates often break things, so we pin it here. Cargo enforces "max 1 semver-compat version
# per crate", so if you change this, you need to also change it in `rustc_llvm` and `rustc_codegen_ssa`.
cc = "=1.2.16"
find-msvc-tools = "0.1.0"
#tidy-alphabetical-end
8 changes: 3 additions & 5 deletions compiler/rustc_windows_rc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
//! to set the product and file version information in the Windows resource file.
use std::{env, ffi, fs, path, process};

use cc::windows_registry;

/// The template for the Windows resource file.
const RESOURCE_TEMPLATE: &str = include_str!("../rustc.rc.in");

Expand Down Expand Up @@ -141,11 +139,11 @@ fn find_resource_compiler(arch_or_target: &str) -> Option<path::PathBuf> {
/// Find a Windows SDK tool for the given architecture or target triple.
/// Returns `None` if the tool could not be found.
fn find_windows_sdk_tool(arch_or_target: &str, tool_name: &str) -> Option<path::PathBuf> {
// windows_registry::find_tool can only find MSVC tools, not Windows SDK tools, but
// find_msvc_tools can only find MSVC tools, not Windows SDK tools, but
// cc does include the Windows SDK tools in the PATH environment of MSVC tools.

let msvc_linker = windows_registry::find_tool(arch_or_target, "link.exe")?;
let path = &msvc_linker.env().iter().find(|(k, _)| k == "PATH")?.1;
let msvc_linker = find_msvc_tools::find_tool(arch_or_target, "link.exe")?;
let path = &msvc_linker.env().into_iter().find(|(k, _)| k == "PATH")?.1;
find_tool_in_path(tool_name, path)
}

Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"expect-test",
"fallible-iterator", // dependency of `thorin`
"fastrand",
"find-msvc-tools",
"flate2",
"fluent-bundle",
"fluent-langneg",
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/extdeps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ALLOWED_SOURCES: &[&str] = &[
r#""registry+https://github.com/rust-lang/crates.io-index""#,
// This is `rust_team_data` used by `site` in src/tools/rustc-perf,
r#""git+https://github.com/rust-lang/team#a5260e76d3aa894c64c56e6ddc8545b9a98043ec""#,
r#""git+https://github.com/dpaoliello/jemallocator.git?branch=temp#329682034ae0b8f7cca4514146b211d7dc694c9c""#,
];

/// Checks for external package sources. `root` is the path to the directory that contains the
Expand Down
Loading