about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-06 11:15:31 +0000
committerbors <bors@rust-lang.org>2024-08-06 11:15:31 +0000
commit60d146580c10036ce89e019422c6bc2fd9729b65 (patch)
tree5530020589ce8d3e470f0e22be20e31cb3174fa9 /src
parent93ea767e2928589b74296ba85b57d80e108db712 (diff)
parent20332dae2f3373f155ffe1a2e99621d9886e3a7f (diff)
Auto merge of #128245 - Oneirical:total-linkage-ownage, r=jieyouxu
Migrate `cdylib-dylib-linkage` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

~~Those sysroot tests are always fun. I'm getting local errors that don't make a lot of sense about my own sysroot not existing, so I am trying this in CI to see what happens.~~

~~EDIT: I am getting the same error here. The strange thing is, when I try to navigate to `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib` on my personal computer, the directory does exist, but the error message is that the directory does not.~~

EDIT 2: The sysroot path just needed to be trimmed!

Please try:

// try-job: x86_64-msvc // passed previously
try-job: x86_64-mingw
try-job: x86_64-gnu-llvm-18
try-job: i686-msvc
try-job: aarch64-apple
Diffstat (limited to 'src')
-rw-r--r--src/tools/run-make-support/src/artifact_names.rs11
-rw-r--r--src/tools/run-make-support/src/lib.rs7
-rw-r--r--src/tools/run-make-support/src/path_helpers.rs8
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
4 files changed, 22 insertions, 5 deletions
diff --git a/src/tools/run-make-support/src/artifact_names.rs b/src/tools/run-make-support/src/artifact_names.rs
index bc6ec7566e5..0d7b5cb9838 100644
--- a/src/tools/run-make-support/src/artifact_names.rs
+++ b/src/tools/run-make-support/src/artifact_names.rs
@@ -38,6 +38,17 @@ pub fn dynamic_lib_name(name: &str) -> String {
     format!("{}{name}.{}", std::env::consts::DLL_PREFIX, std::env::consts::DLL_EXTENSION)
 }
 
+/// Construct the name of the import library for the dynamic library, exclusive to MSVC and
+/// accepted by link.exe.
+#[track_caller]
+#[must_use]
+pub fn msvc_import_dynamic_lib_name(name: &str) -> String {
+    assert!(is_msvc(), "this function is exclusive to MSVC");
+    assert!(!name.contains(char::is_whitespace), "import library name cannot contain whitespace");
+
+    format!("{name}.dll.lib")
+}
+
 /// Construct the dynamic library extension based on the target.
 #[must_use]
 pub fn dynamic_lib_extension() -> &'static str {
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index 63c4c4d8863..fc7e5ceae40 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -72,13 +72,14 @@ pub use targets::{is_darwin, is_msvc, is_windows, llvm_components_contain, targe
 
 /// Helpers for building names of output artifacts that are potentially target-specific.
 pub use artifact_names::{
-    bin_name, dynamic_lib_extension, dynamic_lib_name, rust_lib_name, static_lib_name,
+    bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name,
+    static_lib_name,
 };
 
 /// Path-related helpers.
 pub use path_helpers::{
-    cwd, filename_not_in_denylist, has_extension, has_prefix, has_suffix, not_contains, path,
-    shallow_find_files, source_root,
+    cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix, has_suffix,
+    not_contains, path, shallow_find_files, source_root,
 };
 
 /// Helpers for scoped test execution where certain properties are attempted to be maintained.
diff --git a/src/tools/run-make-support/src/path_helpers.rs b/src/tools/run-make-support/src/path_helpers.rs
index f37ea8dfef8..b788bc6ef30 100644
--- a/src/tools/run-make-support/src/path_helpers.rs
+++ b/src/tools/run-make-support/src/path_helpers.rs
@@ -3,6 +3,7 @@
 use std::path::{Path, PathBuf};
 
 use crate::env::env_var;
+use crate::rfs;
 
 /// Return the current working directory.
 ///
@@ -40,7 +41,7 @@ pub fn shallow_find_files<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
     filter: F,
 ) -> Vec<PathBuf> {
     let mut matching_files = Vec::new();
-    for entry in std::fs::read_dir(path).unwrap() {
+    for entry in rfs::read_dir(path) {
         let entry = entry.expect("failed to read directory entry.");
         let path = entry.path();
 
@@ -78,3 +79,8 @@ pub fn has_extension<P: AsRef<Path>>(path: P, extension: &str) -> bool {
 pub fn has_suffix<P: AsRef<Path>>(path: P, suffix: &str) -> bool {
     path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().ends_with(suffix))
 }
+
+/// Returns true if the filename at `path` contains `needle`.
+pub fn filename_contains<P: AsRef<Path>>(path: P, needle: &str) -> bool {
+    path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(needle))
+}
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 38880e5e95f..a2cfdea712e 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -1,6 +1,5 @@
 run-make/branch-protection-check-IBT/Makefile
 run-make/cat-and-grep-sanity-check/Makefile
-run-make/cdylib-dylib-linkage/Makefile
 run-make/cross-lang-lto-upstream-rlibs/Makefile
 run-make/dep-info-doesnt-run-much/Makefile
 run-make/dep-info-spaces/Makefile