about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-07-23 13:06:55 +0200
committerGitHub <noreply@github.com>2024-07-23 13:06:55 +0200
commit3ab435b7052a528cdf6ef83a0a0ecae9fa0cd0c0 (patch)
treee6080576fde094c812835c3fb90d8f9e90a9a61a
parent1b4b0e9a4d00837aa3e96725b13e894d95bb4152 (diff)
parent3855c5441399adf14d8b8b9e7a87f715a0ae3692 (diff)
downloadrust-3ab435b7052a528cdf6ef83a0a0ecae9fa0cd0c0.tar.gz
rust-3ab435b7052a528cdf6ef83a0a0ecae9fa0cd0c0.zip
Rollup merge of #127962 - jieyouxu:cleanup-dll-compiletest, r=fmease
Cleanup compiletest dylib name calculation

Use `std::env::consts::{DLL_PREFIX, DLL_EXTENSION}` for dylib name calculation which is more accurate for the various different platforms, and is more likely to be looked at by target maintainers.

cc ``@bzEq`` (as this impacts how compiletest handles AIX dll extensions)
-rw-r--r--src/tools/compiletest/src/runtest.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 53988203136..16c08f709df 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -82,26 +82,22 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
 }
 
 /// The platform-specific library name
-fn get_lib_name(lib: &str, aux_type: AuxType) -> Option<String> {
+fn get_lib_name(name: &str, aux_type: AuxType) -> Option<String> {
     match aux_type {
         AuxType::Bin => None,
         // In some cases (e.g. MUSL), we build a static
         // library, rather than a dynamic library.
         // In this case, the only path we can pass
         // with '--extern-meta' is the '.rlib' file
-        AuxType::Lib => Some(format!("lib{}.rlib", lib)),
-        AuxType::Dylib => Some(if cfg!(windows) {
-            format!("{}.dll", lib)
-        } else if cfg!(target_vendor = "apple") {
-            format!("lib{}.dylib", lib)
-        } else if cfg!(target_os = "aix") {
-            format!("lib{}.a", lib)
-        } else {
-            format!("lib{}.so", lib)
-        }),
+        AuxType::Lib => Some(format!("lib{name}.rlib")),
+        AuxType::Dylib => Some(dylib_name(name)),
     }
 }
 
+fn dylib_name(name: &str) -> String {
+    format!("{}{name}.{}", std::env::consts::DLL_PREFIX, std::env::consts::DLL_EXTENSION)
+}
+
 pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
     match &*config.target {
         "arm-linux-androideabi"