Skip to content

Assorted run-make-support maintenance #143683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 10, 2025
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
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3214,7 +3214,7 @@ dependencies = [

[[package]]
name = "run_make_support"
version = "0.2.0"
version = "0.0.0"
dependencies = [
"bstr",
"build_helper",
Expand Down
83 changes: 0 additions & 83 deletions src/tools/run-make-support/CHANGELOG.md

This file was deleted.

21 changes: 15 additions & 6 deletions src/tools/run-make-support/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
[package]
name = "run_make_support"
version = "0.2.0"
edition = "2021"
version = "0.0.0"
edition = "2024"

[dependencies]

# These dependencies are either used to implement part of support library
# functionality, or re-exported to test recipe programs via the support library,
# or both.

# tidy-alphabetical-start
bstr = "1.12"
gimli = "0.32"
libc = "0.2"
object = "0.37"
regex = "1.11"
serde_json = "1.0"
similar = "2.7"
wasmparser = { version = "0.219", default-features = false, features = ["std"] }
regex = "1.11"
gimli = "0.32"
# tidy-alphabetical-end

# Shared with bootstrap and compiletest
build_helper = { path = "../../build_helper" }
serde_json = "1.0"
libc = "0.2"

[lib]
crate-type = ["lib", "dylib"]
6 changes: 3 additions & 3 deletions src/tools/run-make-support/src/artifact_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
//! libraries which are target-dependent.

use crate::target;
use crate::targets::is_msvc;
use crate::targets::is_windows_msvc;

/// Construct the static library name based on the target.
#[track_caller]
#[must_use]
pub fn static_lib_name(name: &str) -> String {
assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace");

if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
if is_windows_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
}

/// Construct the dynamic library name based on the target.
Expand Down Expand Up @@ -45,7 +45,7 @@ pub fn dynamic_lib_extension() -> &'static str {
#[track_caller]
#[must_use]
pub fn msvc_import_dynamic_lib_name(name: &str) -> String {
assert!(is_msvc(), "this function is exclusive to MSVC");
assert!(is_windows_msvc(), "this function is exclusive to MSVC");
assert!(!name.contains(char::is_whitespace), "import library name cannot contain whitespace");

format!("{name}.dll.lib")
Expand Down
23 changes: 12 additions & 11 deletions src/tools/run-make-support/src/external_deps/c_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::artifact_names::{dynamic_lib_name, static_lib_name};
use crate::external_deps::c_cxx_compiler::{cc, cxx};
use crate::external_deps::llvm::llvm_ar;
use crate::path_helpers::path;
use crate::targets::{is_darwin, is_msvc, is_windows};
use crate::targets::{is_darwin, is_windows, is_windows_msvc};

// FIXME(Oneirical): These native build functions should take a Path-based generic.

Expand All @@ -24,20 +24,20 @@ pub fn build_native_static_lib_optimized(lib_name: &str) -> PathBuf {

#[track_caller]
fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf {
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
let src = format!("{lib_name}.c");
let lib_path = static_lib_name(lib_name);

let mut cc = cc();
if !is_msvc() {
if !is_windows_msvc() {
cc.arg("-v");
}
if optimzed {
cc.optimize();
}
cc.arg("-c").out_exe(&obj_file).input(src).optimize().run();

let obj_file = if is_msvc() {
let obj_file = if is_windows_msvc() {
PathBuf::from(format!("{lib_name}.obj"))
} else {
PathBuf::from(format!("{lib_name}.o"))
Expand All @@ -50,16 +50,17 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf {
/// [`std::env::consts::DLL_PREFIX`] and [`std::env::consts::DLL_EXTENSION`].
#[track_caller]
pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
let src = format!("{lib_name}.c");
let lib_path = dynamic_lib_name(lib_name);
if is_msvc() {
if is_windows_msvc() {
cc().arg("-c").out_exe(&obj_file).input(src).run();
} else {
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
};
let obj_file = if is_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") };
if is_msvc() {
let obj_file =
if is_windows_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") };
if is_windows_msvc() {
let out_arg = format!("-out:{lib_path}");
cc().input(&obj_file).args(&["-link", "-dll", &out_arg]).run();
} else if is_darwin() {
Expand All @@ -79,15 +80,15 @@ pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
/// Built from a C++ file.
#[track_caller]
pub fn build_native_static_lib_cxx(lib_name: &str) -> PathBuf {
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
let src = format!("{lib_name}.cpp");
let lib_path = static_lib_name(lib_name);
if is_msvc() {
if is_windows_msvc() {
cxx().arg("-EHs").arg("-c").out_exe(&obj_file).input(src).run();
} else {
cxx().arg("-c").out_exe(&obj_file).input(src).run();
};
let obj_file = if is_msvc() {
let obj_file = if is_windows_msvc() {
PathBuf::from(format!("{lib_name}.obj"))
} else {
PathBuf::from(format!("{lib_name}.o"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::Path;

use crate::command::Command;
use crate::{env_var, is_msvc};
use crate::{env_var, is_windows_msvc};

/// Construct a new platform-specific C compiler invocation.
///
Expand Down Expand Up @@ -82,7 +82,7 @@ impl Cc {
pub fn out_exe(&mut self, name: &str) -> &mut Self {
let mut path = std::path::PathBuf::from(name);

if is_msvc() {
if is_windows_msvc() {
path.set_extension("exe");
let fe_path = path.clone();
path.set_extension("");
Expand All @@ -108,7 +108,7 @@ impl Cc {
/// Optimize the output.
/// Equivalent to `-O3` for GNU-compatible linkers or `-O2` for MSVC linkers.
pub fn optimize(&mut self) -> &mut Self {
if is_msvc() {
if is_windows_msvc() {
self.cmd.arg("-O2");
} else {
self.cmd.arg("-O3");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{is_msvc, is_win7, is_windows, uname};
use crate::{is_win7, is_windows, is_windows_msvc, uname};

/// `EXTRACFLAGS`
pub fn extra_c_flags() -> Vec<&'static str> {
if is_windows() {
if is_msvc() {
if is_windows_msvc() {
let mut libs =
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
if is_win7() {
Expand All @@ -29,7 +29,7 @@ pub fn extra_c_flags() -> Vec<&'static str> {
/// `EXTRACXXFLAGS`
pub fn extra_cxx_flags() -> Vec<&'static str> {
if is_windows() {
if is_msvc() { vec![] } else { vec!["-lstdc++"] }
if is_windows_msvc() { vec![] } else { vec!["-lstdc++"] }
} else {
match &uname()[..] {
"Darwin" => vec!["-lc++"],
Expand Down
4 changes: 2 additions & 2 deletions src/tools/run-make-support/src/external_deps/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::command::Command;
use crate::env::env_var;
use crate::path_helpers::cwd;
use crate::util::set_host_compiler_dylib_path;
use crate::{is_aix, is_darwin, is_msvc, is_windows, target, uname};
use crate::{is_aix, is_darwin, is_windows, is_windows_msvc, target, uname};

/// Construct a new `rustc` invocation. This will automatically set the library
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
Expand Down Expand Up @@ -377,7 +377,7 @@ impl Rustc {
// So we end up with the following hack: we link use static:-bundle to only
// link the parts of libstdc++ that we actually use, which doesn't include
// the dependency on the pthreads DLL.
if !is_msvc() {
if !is_windows_msvc() {
self.cmd.arg("-lstatic:-bundle=stdc++");
};
} else if is_darwin() {
Expand Down
Loading
Loading