Skip to content

Commit ca882a2

Browse files
committed
Allow static and dynamic linking
Currently both `userfaultfd` and `userfaultfd-sys` always load libclang dynamically. This commit keeps this as the default behavior but adds the "static" and "runtime" features. The "static" feature will statically link libclang, while "runtime" will load libclang at runtime. Users using `default-features=false` will need to specify `features = ["runtime"]` to maintain current behavior, but they should be in the minority, given that neither crate currently has default features.
1 parent 6b9b777 commit ca882a2

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ cfg-if = "^1.0.0"
1414
libc = "0.2.65"
1515
nix = { version = "0.27", features = ["ioctl"] }
1616
thiserror = "1.0.4"
17-
userfaultfd-sys = { path = "userfaultfd-sys", version = "^0.5.0" }
17+
userfaultfd-sys = { path = "userfaultfd-sys", version = "^0.5.0", default-features = false }
1818

1919
[dev-dependencies]
2020
nix = { version = "0.27", features = ["poll", "mman", "feature"] }
2121

2222
[features]
23-
default = []
23+
default = ["runtime"]
24+
2425
linux4_14 = ["userfaultfd-sys/linux4_14", "nix/process"]
2526
linux5_7 = ["userfaultfd-sys/linux5_7"]
27+
28+
runtime = ["userfaultfd-sys/runtime"]
29+
static = ["userfaultfd-sys/static"]

userfaultfd-sys/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ build = "build.rs"
1313
cfg-if = "^1.0.0"
1414

1515
[build-dependencies]
16-
bindgen = { version = "^0.68.1", default-features = false, features = ["runtime"] }
16+
bindgen = { version = "^0.68.1", default-features = false }
1717
cc = "1.0"
1818

1919
[features]
20-
default = []
20+
default = ["runtime"]
21+
2122
linux4_14 = []
2223
linux5_7 = []
24+
25+
runtime = ["bindgen/runtime"]
26+
static = ["bindgen/static"]

0 commit comments

Comments
 (0)