Skip to content

Commit 5d6db72

Browse files
committed
musl-ldd
1 parent c43abfb commit 5d6db72

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/validation.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,17 +2201,23 @@ fn verify_distribution_behavior(dist_path: &Path) -> Result<Vec<String>> {
22012201
// that fails this check (e.g. by setting an rpath on just python+libpython).
22022202
// https://github.com/pyinstaller/pyinstaller/issues/9204#issuecomment-3171050891
22032203
if cfg!(target_os = "linux") {
2204+
// musl's ldd is packaged in the "musl-dev" Debian package.
2205+
let ldd = if python_json.target_triple.contains("-musl") && cfg!(not(target_env = "musl")) {
2206+
"musl-ldd"
2207+
} else {
2208+
"ldd"
2209+
};
22042210
for (name, variants) in python_json.build_info.extensions.iter() {
22052211
for ext in variants {
22062212
let Some(shared_lib) = &ext.shared_lib else {
22072213
continue;
22082214
};
22092215
let shared_lib_path = temp_dir.path().join("python").join(shared_lib);
2210-
let output = duct::cmd("ldd", [shared_lib_path])
2216+
let output = duct::cmd(ldd, [shared_lib_path])
22112217
.unchecked()
22122218
.stdout_capture()
22132219
.run()
2214-
.context(format!("Failed to run `ldd {shared_lib}`"))?;
2220+
.context(format!("Failed to run `{ldd} {shared_lib}`"))?;
22152221
let stdout = String::from_utf8_lossy(&output.stdout);
22162222
// Format of ldd output, for both glibc and musl:
22172223
// - Everything starts with a tab.
@@ -2229,7 +2235,7 @@ fn verify_distribution_behavior(dist_path: &Path) -> Result<Vec<String>> {
22292235
// TODO: If we ever have any optional dependencies besides libcrypt (which is
22302236
// glibc-only), we will need to capture musl ldd's stderr and parse it.
22312237
errors.push(format!(
2232-
"`ldd {shared_lib}` exited with {}:\n{stdout}",
2238+
"`{ldd} {shared_lib}` exited with {}:\n{stdout}",
22332239
output.status
22342240
));
22352241
} else {
@@ -2241,7 +2247,9 @@ fn verify_distribution_behavior(dist_path: &Path) -> Result<Vec<String>> {
22412247
continue;
22422248
};
22432249
let dep_source = deps
2244-
.and_then(|deps| deps.iter().find(|dep| dep.0 == needed).map(|dep| dep.1))
2250+
.and_then(|deps| {
2251+
deps.iter().find(|dep| dep.0 == needed).map(|dep| dep.1)
2252+
})
22452253
.unwrap_or(SystemRequired);
22462254
if resolution.starts_with("not found") && dep_source != SystemOptional {
22472255
ldd_errors.push(format!("{needed} was expected to be found"));
@@ -2253,7 +2261,7 @@ fn verify_distribution_behavior(dist_path: &Path) -> Result<Vec<String>> {
22532261
}
22542262
if !ldd_errors.is_empty() {
22552263
errors.push(format!(
2256-
"In `ldd {shared_lib}`:\n - {}\n{stdout}",
2264+
"In `{ldd} {shared_lib}`:\n - {}\n{stdout}",
22572265
ldd_errors.join("\n - ")
22582266
));
22592267
}

0 commit comments

Comments
 (0)