From ff0d6b11aad835c1d553a9e2ce615f6cee921d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20B=C3=B6gel?= Date: Wed, 16 Oct 2024 11:31:30 -0700 Subject: [PATCH 1/2] rust - re-export libceed-sys features through libceed to allow building non-static without using libceed-sys directly --- rust/libceed/Cargo.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rust/libceed/Cargo.toml b/rust/libceed/Cargo.toml index 42dce37e2d..b26351b3f4 100644 --- a/rust/libceed/Cargo.toml +++ b/rust/libceed/Cargo.toml @@ -18,12 +18,17 @@ keywords = ["libceed", "exascale", "high-order"] categories = ["science"] [dependencies] -libceed-sys = { version = "0.12", path = "../libceed-sys" } +libceed-sys = { version = "0.12", path = "../libceed-sys", default-features = false} katexit = { version = "0.1.1", optional = true } [dev-dependencies] version-sync = "0.9.2" +[features] +default = ["static"] +static = ["libceed-sys/static"] +system = ["libceed-sys/system"] + [package.metadata.docs.rs] features = ["katexit"] From d58007642d868a5bda9a99e90e2f08a6acd4f8f9 Mon Sep 17 00:00:00 2001 From: Jed Brown Date: Sat, 26 Apr 2025 23:24:24 -0600 Subject: [PATCH 2/2] WIP: cargo: change libceed feature `static` to `shared` This way no features are activated by default. It has the downside that if only the shared feature is enabled, it will attempt to statically link to the system library (which is most likely a shared library). --- rust/libceed-sys/Cargo.toml | 3 +-- rust/libceed-sys/build.rs | 6 +++--- rust/libceed/Cargo.toml | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rust/libceed-sys/Cargo.toml b/rust/libceed-sys/Cargo.toml index 18f514a52a..38f905a295 100644 --- a/rust/libceed-sys/Cargo.toml +++ b/rust/libceed-sys/Cargo.toml @@ -25,8 +25,7 @@ include = [ ] [features] -default = ["static"] -static = [] +shared = [] system = [] [build-dependencies] diff --git a/rust/libceed-sys/build.rs b/rust/libceed-sys/build.rs index d1cc93be6e..b165c9b504 100644 --- a/rust/libceed-sys/build.rs +++ b/rust/libceed-sys/build.rs @@ -6,7 +6,7 @@ use std::process::Command; fn main() { let out_dir = PathBuf::from(env("OUT_DIR").unwrap()); - let statik = env("CARGO_FEATURE_STATIC").is_some(); + let shared = env("CARGO_FEATURE_SHARED").is_some(); let system = env("CARGO_FEATURE_SYSTEM").is_some(); let ceed_pc = if system { @@ -28,7 +28,7 @@ fn main() { .arg("FC=") // Don't try to find Fortran (unused library build/install) .env("MAKEFLAGS", makeflags) .current_dir("c-src"); - if statik { + if !shared { make.arg("STATIC=1"); } run(&mut make); @@ -40,7 +40,7 @@ fn main() { .into_owned() }; pkg_config::Config::new() - .statik(statik) + .statik(!shared) .atleast_version("0.12.0") .probe(&ceed_pc) .unwrap(); diff --git a/rust/libceed/Cargo.toml b/rust/libceed/Cargo.toml index b26351b3f4..ec827fe3cf 100644 --- a/rust/libceed/Cargo.toml +++ b/rust/libceed/Cargo.toml @@ -25,8 +25,7 @@ katexit = { version = "0.1.1", optional = true } version-sync = "0.9.2" [features] -default = ["static"] -static = ["libceed-sys/static"] +shared = ["libceed-sys/shared"] system = ["libceed-sys/system"] [package.metadata.docs.rs]