Skip to content

Commit

Permalink
Add support for GNU/Hurd
Browse files Browse the repository at this point in the history
  • Loading branch information
sthibaul authored and lu-zero committed Dec 4, 2024
1 parent 8914ddf commit c4e6c08
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,11 +1387,13 @@ mod tests {
pub fn test_lib_listing() {
let libs_osx = "-lSystem -lc -lm";
let libs_linux = "-lgcc_s -lutil -lrt -lpthread -lm -ldl -lc";
let libs_hurd = "-lgcc_s -lutil -lrt -lpthread -lm -ldl -lc";
let libs_msvc = "kernel32.lib advapi32.lib kernel32.lib ntdll.lib userenv.lib ws2_32.lib kernel32.lib ws2_32.lib kernel32.lib msvcrt.lib /defaultlib:msvcrt";
let libs_mingw = "-lkernel32 -ladvapi32 -lkernel32 -lntdll -luserenv -lws2_32 -lkernel32 -lws2_32 -lkernel32";

let target_osx = target::Target::new(Some("x86_64-apple-darwin"), false).unwrap();
let target_linux = target::Target::new(Some("x86_64-unknown-linux-gnu"), false).unwrap();
let target_hurd = target::Target::new(Some("x86_64-unknown-hurd-gnu"), false).unwrap();
let target_msvc = target::Target::new(Some("x86_64-pc-windows-msvc"), false).unwrap();
let target_mingw = target::Target::new(Some("x86_64-pc-windows-gnu"), false).unwrap();

Expand All @@ -1400,6 +1402,10 @@ mod tests {
static_libraries(libs_linux, &target_linux),
"-lgcc_s -lutil -lrt -lpthread -lm -ldl -lc"
);
assert_eq!(
static_libraries(libs_hurd, &target_hurd),
"-lgcc_s -lutil -lrt -lpthread -lm -ldl -lc"
);
assert_eq!(
static_libraries(libs_msvc, &target_msvc),
"-lkernel32 -ladvapi32 -lntdll -luserenv -lws2_32 -lmsvcrt"
Expand Down
3 changes: 2 additions & 1 deletion src/build_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl FileNames {
fn from_target(target: &Target, lib_name: &str, targetdir: &Path) -> Option<Self> {
let (shared_lib, static_lib, impl_lib, debug_info, def) = match target.os.as_str() {
"none" | "linux" | "freebsd" | "dragonfly" | "netbsd" | "android" | "haiku"
| "illumos" | "openbsd" | "emscripten" => {
| "illumos" | "openbsd" | "emscripten" | "hurd" => {
let static_lib = targetdir.join(format!("lib{lib_name}.a"));
let shared_lib = targetdir.join(format!("lib{lib_name}.so"));
(shared_lib, static_lib, None, None, None)
Expand Down Expand Up @@ -207,6 +207,7 @@ mod test {
"haiku",
"illumos",
"emscripten",
"hurd",
] {
let target = Target {
is_target_overridden: false,
Expand Down
3 changes: 2 additions & 1 deletion src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ impl LibType {
| ("haiku", _)
| ("illumos", _)
| ("openbsd", _)
| ("emscripten", _) => LibType::So,
| ("emscripten", _)
| ("hurd", _) => LibType::So,
("macos", _) | ("ios", _) | ("tvos", _) | ("visionos", _) => LibType::Dylib,
("windows", _) => LibType::Windows,
_ => unimplemented!("The target {}-{} is not supported yet", os, env),
Expand Down
1 change: 1 addition & 0 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl Target {
|| os == "haiku"
|| os == "illumos"
|| os == "openbsd"
|| os == "hurd"
{
lines.push(if capi_config.library.versioning {
format!("-Wl,-soname,lib{lib_name}.so.{sover}")
Expand Down

0 comments on commit c4e6c08

Please sign in to comment.