Skip to content

Commit b55526f

Browse files
committed
libkrun: stop using patchelf
Using patchelf to set soname in the library has always been kind of a hack. Let's get rid of it. Signed-off-by: Sergio Lopez <[email protected]>
1 parent 5b68d16 commit b55526f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,20 @@ $(LIBRARY_RELEASE_$(OS)): $(INIT_BINARY)
9191
ifeq ($(SEV),1)
9292
mv target/release/libkrun.so target/release/$(KRUN_BASE_$(OS))
9393
endif
94-
ifeq ($(OS),Linux)
95-
patchelf --set-soname $(KRUN_SONAME_$(OS)) --output $(LIBRARY_RELEASE_$(OS)) target/release/$(KRUN_BASE_$(OS))
96-
else
97-
ifeq ($(EFI),1)
9894
ifeq ($(OS),Darwin)
95+
ifeq ($(EFI),1)
9996
install_name_tool -id libkrun-efi.dylib target/release/libkrun.dylib
10097
endif
10198
mv target/release/libkrun.dylib target/release/$(KRUN_BASE_$(OS))
10299
endif
103100
cp target/release/$(KRUN_BASE_$(OS)) $(LIBRARY_RELEASE_$(OS))
104-
endif
105101

106102
$(LIBRARY_DEBUG_$(OS)): $(INIT_BINARY)
107103
cargo build $(FEATURE_FLAGS)
108104
ifeq ($(SEV),1)
109105
mv target/debug/libkrun.so target/debug/$(KRUN_BASE_$(OS))
110106
endif
111-
ifeq ($(OS),Linux)
112-
patchelf --set-soname $(KRUN_SONAME_$(OS)) --output $(LIBRARY_DEBUG_$(OS)) target/debug/$(KRUN_BASE_$(OS))
113-
else
114107
cp target/debug/$(KRUN_BASE_$(OS)) $(LIBRARY_DEBUG_$(OS))
115-
endif
116108

117109
libkrun.pc: libkrun.pc.in Makefile
118110
rm -f $@ $@-t

src/libkrun/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
fn main() {
2+
#[cfg(target_os = "linux")]
3+
println!(
4+
"cargo:rustc-cdylib-link-arg=-Wl,-soname,libkrun.so.{}",
5+
std::env::var("CARGO_PKG_VERSION_MAJOR").unwrap()
6+
);
27
#[cfg(target_os = "macos")]
38
println!("cargo:rustc-link-lib=framework=Hypervisor");
49
}

0 commit comments

Comments
 (0)