From c4e6c08da0c9a12d16b1e00666e5ce67e3d013a9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 4 Dec 2024 19:34:26 +0100 Subject: [PATCH] Add support for GNU/Hurd --- src/build.rs | 6 ++++++ src/build_targets.rs | 3 ++- src/install.rs | 3 ++- src/target.rs | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/build.rs b/src/build.rs index 096bd26..19f2472 100644 --- a/src/build.rs +++ b/src/build.rs @@ -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(); @@ -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" diff --git a/src/build_targets.rs b/src/build_targets.rs index e9640fd..3113146 100644 --- a/src/build_targets.rs +++ b/src/build_targets.rs @@ -148,7 +148,7 @@ impl FileNames { fn from_target(target: &Target, lib_name: &str, targetdir: &Path) -> Option { 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) @@ -207,6 +207,7 @@ mod test { "haiku", "illumos", "emscripten", + "hurd", ] { let target = Target { is_target_overridden: false, diff --git a/src/install.rs b/src/install.rs index b6db6fa..7cc1c4b 100644 --- a/src/install.rs +++ b/src/install.rs @@ -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), diff --git a/src/target.rs b/src/target.rs index 416af28..a13c48e 100644 --- a/src/target.rs +++ b/src/target.rs @@ -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}")