Skip to content

Commit 1410562

Browse files
Make novendor feature the default
Make novendor feature the default Merge vendored feature into static There is now only two settings - default (formerly novendor, all libs are dynamic) - static (formerly vendored, all libs are static) Side Effect: Clients of libbpf-sys will now compile zlib and elfutils as part of the libbpf-sys project. This has the benefit of ensuring that the libraries are well suited for the rust bindings, but takes extra time during compilation Signed-off-by: Michael Mullin <[email protected]>
1 parent 0be8935 commit 1410562

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- rust-target: x86_64-unknown-linux-gnu
1717
os-target: x86_64-linux-gnu
1818
os-arch: amd64
19-
features: novendor
19+
features: static
2020

2121
- rust-target: aarch64-unknown-linux-gnu
2222
os-target: aarch64-linux-gnu
@@ -59,7 +59,6 @@ jobs:
5959
zlib1g-dev:${{ matrix.os-arch }}
6060
6161
- name: Install libbpf-dev
62-
if: matrix.features == 'novendor'
6362
run: sudo apt-get install libbpf-dev:${{ matrix.os-arch }}
6463

6564
- name: Install linker for ${{ matrix.os-target }}
@@ -84,7 +83,6 @@ jobs:
8483
matrix:
8584
features:
8685
- ''
87-
- novendor
8886
env:
8987
CARGO_TERM_VERBOSE: 'true'
9088
steps:
@@ -105,7 +103,6 @@ jobs:
105103
zlib-dev
106104
107105
- name: Install libbpf-dev
108-
if: matrix.features == 'novendor'
109106
run: apk add libbpf-dev
110107
shell: alpine.sh --root {0}
111108

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ num_cpus = "^1.16.0"
3636
crate-type = ["lib", "staticlib"]
3737

3838
[features]
39-
novendor = []
4039
static = []
41-
vendored = ["static"]
40+
novendor = [] # depricated, novendor is the default

build.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn main() {
9797

9898
generate_bindings(src_dir.clone());
9999

100-
if cfg!(feature = "novendor") {
100+
if cfg!(not(feature = "static")) {
101101
println!("cargo:rustc-link-lib={}bpf\n", library_prefix());
102102
return;
103103
}
@@ -107,13 +107,11 @@ fn main() {
107107
// check for all necessary compilation tools
108108
pkg_check("make");
109109
pkg_check("pkg-config");
110-
if cfg!(feature = "vendored") {
111-
pkg_check("autoreconf");
112-
pkg_check("autopoint");
113-
pkg_check("flex");
114-
pkg_check("bison");
115-
pkg_check("gawk");
116-
}
110+
pkg_check("autoreconf");
111+
pkg_check("autopoint");
112+
pkg_check("flex");
113+
pkg_check("bison");
114+
pkg_check("gawk");
117115

118116
let compiler = match cc::Build::new().try_get_compiler() {
119117
Ok(compiler) => compiler,
@@ -127,9 +125,7 @@ fn main() {
127125
let _ = fs::create_dir(&obj_dir);
128126

129127
// compile static zlib and static libelf
130-
#[cfg(feature = "vendored")]
131128
make_zlib(&compiler, &src_dir, &out_dir);
132-
#[cfg(feature = "vendored")]
133129
make_elfutils(&compiler, &src_dir, &out_dir);
134130

135131
let cflags = if cfg!(feature = "vendored") {
@@ -187,7 +183,6 @@ fn main() {
187183
}
188184
}
189185

190-
#[cfg(feature = "vendored")]
191186
fn make_zlib(compiler: &cc::Tool, src_dir: &path::PathBuf, out_dir: &path::PathBuf) {
192187
use nix::fcntl;
193188
use std::os::fd::AsRawFd;
@@ -232,7 +227,6 @@ fn make_zlib(compiler: &cc::Tool, src_dir: &path::PathBuf, out_dir: &path::PathB
232227
assert!(status.success(), "make failed");
233228
}
234229

235-
#[cfg(feature = "vendored")]
236230
fn make_elfutils(compiler: &cc::Tool, src_dir: &path::PathBuf, out_dir: &path::PathBuf) {
237231
use nix::fcntl;
238232
use std::os::fd::AsRawFd;

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
include!("bindings.rs");
88

9+
#[cfg(feature = "static")]
910
macro_rules! header {
1011
($file:literal) => {
1112
($file, include_str!(concat!("../libbpf/src/", $file)))
@@ -15,7 +16,7 @@ macro_rules! header {
1516
/// Vendored libbpf headers
1617
///
1718
/// Tuple format is: (header filename, header contents)
18-
#[cfg(not(feature = "novendor"))]
19+
#[cfg(feature = "static")]
1920
pub const API_HEADERS: [(&'static str, &'static str); 10] = [
2021
header!("bpf.h"),
2122
header!("libbpf.h"),

0 commit comments

Comments
 (0)