mirror of
https://github.com/extism/extism.git
synced 2026-01-08 21:38:13 -05:00
fix(libextism): improve static linking pkgconfig (#726)
This includes three fixes: * link static library by absolute path (should fix static linking on Mac/ with `lld`) * link static library with `-framework Security` on Mac * link `libpthread` , this should be a no-op on systems with modern libc, but should fix static linking on systems with glibc pre 2.34 see https://developers.redhat.com/articles/2021/12/17/why-glibc-234-removed-libpthread and error http://www.cpantesters.org/cpan/report/669fdfc8-25a4-11ef-9502-51fb6d8775ea --------- Co-authored-by: zach <zachshipko@gmail.com> Co-authored-by: zach <zach@dylibso.com>
This commit is contained in:
5
Makefile
5
Makefile
@@ -4,10 +4,12 @@ AEXT=a
|
|||||||
FEATURES?=default
|
FEATURES?=default
|
||||||
DEFAULT_FEATURES?=yes
|
DEFAULT_FEATURES?=yes
|
||||||
RUST_TARGET?=
|
RUST_TARGET?=
|
||||||
|
EXTRA_LIBS=
|
||||||
|
|
||||||
UNAME := $(shell uname -s)
|
UNAME := $(shell uname -s)
|
||||||
ifeq ($(UNAME),Darwin)
|
ifeq ($(UNAME),Darwin)
|
||||||
SOEXT=dylib
|
SOEXT=dylib
|
||||||
|
EXTRA_LIBS=-framework Security
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(DEFAULT_FEATURES),no)
|
ifeq ($(DEFAULT_FEATURES),no)
|
||||||
@@ -29,7 +31,8 @@ endif
|
|||||||
build:
|
build:
|
||||||
cargo build --release $(FEATURE_FLAGS) --manifest-path libextism/Cargo.toml $(TARGET_FLAGS)
|
cargo build --release $(FEATURE_FLAGS) --manifest-path libextism/Cargo.toml $(TARGET_FLAGS)
|
||||||
sed -e "s%@CMAKE_INSTALL_PREFIX@%$(DEST)%" libextism/extism.pc.in > libextism/extism.pc
|
sed -e "s%@CMAKE_INSTALL_PREFIX@%$(DEST)%" libextism/extism.pc.in > libextism/extism.pc
|
||||||
sed -e "s%@CMAKE_INSTALL_PREFIX@%$(DEST)%" libextism/extism-static.pc.in > libextism/extism-static.pc
|
sed -e "s%@CMAKE_INSTALL_PREFIX@%$(DEST)%" \
|
||||||
|
-e "s%Libs: %Libs: $(EXTRA_LIBS) %" libextism/extism-static.pc.in > libextism/extism-static.pc
|
||||||
|
|
||||||
bench:
|
bench:
|
||||||
@(cargo criterion $(TARGET_FLAGS) || echo 'For nicer output use cargo-criterion: `cargo install cargo-criterion` - using `cargo bench`') && cargo bench $(TARGET_FLAGS)
|
@(cargo criterion $(TARGET_FLAGS) || echo 'For nicer output use cargo-criterion: `cargo install cargo-criterion` - using `cargo bench`') && cargo bench $(TARGET_FLAGS)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build:
|
|||||||
|
|
||||||
.PHONY: static
|
.PHONY: static
|
||||||
static:
|
static:
|
||||||
$(CC) -g -o example example.c -l:libextism.a -lm
|
$(CC) -g -o example example.c -l:libextism.a -lm -lpthread
|
||||||
|
|
||||||
# if needed, set PKG_CONFIG_PATH= to the directory with extism*.pc installed
|
# if needed, set PKG_CONFIG_PATH= to the directory with extism*.pc installed
|
||||||
LDFLAGS=`pkg-config --libs extism`
|
LDFLAGS=`pkg-config --libs extism`
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void log_handler(const char *line, uintptr_t length) {
|
void log_handler(const char *line, ExtismSize length) {
|
||||||
fwrite(line, length, 1, stderr);
|
fwrite(line, length, 1, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ includedir=${prefix}/include
|
|||||||
Version: 1.0.0
|
Version: 1.0.0
|
||||||
Name: Extism
|
Name: Extism
|
||||||
Description: The framework for building with WebAssembly (wasm).
|
Description: The framework for building with WebAssembly (wasm).
|
||||||
Libs: -L${libdir} -l:libextism.a
|
Libs: ${libdir}/libextism.a
|
||||||
Libs.private: -lm
|
Libs.private: -lm -lpthread
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ Version: 1.0.0
|
|||||||
Name: Extism
|
Name: Extism
|
||||||
Description: The framework for building with WebAssembly (wasm).
|
Description: The framework for building with WebAssembly (wasm).
|
||||||
Libs: -L${libdir} -lextism
|
Libs: -L${libdir} -lextism
|
||||||
Libs.private: -lm
|
Libs.private: -lm -lpthread
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ serde_json = "1"
|
|||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = {version = "0.3", features = ["std", "env-filter", "fmt"]}
|
tracing-subscriber = {version = "0.3.18", features = ["std", "env-filter", "fmt"]}
|
||||||
url = "2"
|
url = "2"
|
||||||
glob = "0.3"
|
glob = "0.3"
|
||||||
ureq = {version = "2.5", optional=true}
|
ureq = {version = "2.5", optional=true}
|
||||||
|
|||||||
Reference in New Issue
Block a user