-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(
github-release
): 🐛 detect the lib version needed (musl/libc) (#899
) This replaces the `prefer_musl` flag by a detection, which makes more sense actually, since it would depend on the current system. Partially reverts 24faed9
- Loading branch information
Showing
5 changed files
with
68 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::path::Path; | ||
use std::process::Command as StdCommand; | ||
|
||
/// Detects the C library used by the current system. | ||
/// Returns true for glibc and false for musl. | ||
#[cfg(target_os = "linux")] | ||
#[inline] | ||
pub fn detect_libc() -> bool { | ||
// First try filesystem check as it's faster | ||
if Path::new("/lib/ld-musl-x86_64.so.1").exists() { | ||
return false; | ||
} | ||
|
||
if Path::new("/lib64/ld-linux-x86-64.so.2").exists() | ||
|| Path::new("/lib32/ld-linux.so.2").exists() | ||
{ | ||
return true; | ||
} | ||
|
||
// Fallback to ldd check | ||
if let Ok(output) = StdCommand::new("ldd") | ||
.arg("--version") | ||
.stderr(std::process::Stdio::piped()) | ||
.stdout(std::process::Stdio::piped()) | ||
.output() | ||
{ | ||
let output_str = String::from_utf8_lossy(&output.stdout).to_lowercase(); | ||
if output_str.contains("gnu") || output_str.contains("glibc") { | ||
return true; | ||
} else if output_str.contains("musl") { | ||
return false; | ||
} | ||
|
||
let error_str = String::from_utf8_lossy(&output.stderr).to_lowercase(); | ||
if error_str.contains("musl") { | ||
return false; | ||
} | ||
} | ||
|
||
// Default to glibc if we can't determine | ||
true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
pub(crate) mod base62; | ||
pub(crate) use base62::encode as base62_encode; | ||
|
||
#[cfg(target_os = "linux")] | ||
mod libc; | ||
#[cfg(target_os = "linux")] | ||
pub(crate) use libc::detect_libc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters