-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distro packaging improvements #2135
Changes from all commits
8041f03
80ec06f
a9537c9
a0800cb
59b5544
637351c
53c4d4f
1cd42ce
7eef4b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,6 +328,9 @@ $(info ) | |
# Building # | ||
############ | ||
|
||
# Not really "all", just the default target that builds enough so make install will go through | ||
all: build-wasmer build-capi | ||
|
||
bench: | ||
cargo bench $(compiler_features) | ||
|
||
|
@@ -493,7 +496,7 @@ test-packages: | |
cargo test -p wasmer-engine-native --release --no-default-features | ||
cargo test -p wasmer-engine-jit --release --no-default-features | ||
cargo test -p wasmer-compiler --release | ||
cargo test -p wasmer-cli --release | ||
cargo test --manifest-path lib/cli/Cargo.toml $(compiler_features) --release | ||
cargo test -p wasmer-cache --release | ||
cargo test -p wasmer-engine --release | ||
cargo test -p wasmer-derive --release | ||
|
@@ -657,6 +660,44 @@ endif | |
tar -C package -zcvf wasmer.tar.gz bin lib include LICENSE ATTRIBUTIONS | ||
mv wasmer.tar.gz dist/ | ||
|
||
######################## | ||
# (Distro-) Installing # | ||
######################## | ||
|
||
DESTDIR ?= /usr/local | ||
|
||
install: install-wasmer install-capi-headers install-capi-lib install-capi-staticlib install-pkgconfig install-misc | ||
|
||
install-wasmer: | ||
install -Dm755 target/release/wasmer $(DESTDIR)/bin/wasmer | ||
|
||
install-capi-headers: | ||
for header in lib/c-api/*.{h,hh}; do install -Dm644 "$$header" $(DESTDIR)/include/$$(basename $$header); done | ||
install -Dm644 lib/c-api/README.md $(DESTDIR)/include/wasmer-README.md | ||
|
||
# Currently implemented for linux only. TODO | ||
install-capi-lib: | ||
pkgver=$$(target/release/wasmer --version | cut -d\ -f2) && \ | ||
shortver="$${pkgver%.*}" && \ | ||
majorver="$${shortver%.*}" && \ | ||
install -Dm755 target/release/libwasmer_c_api.so "$(DESTDIR)/lib/libwasmer.so.$$pkgver" && \ | ||
ln -sf "libwasmer.so.$$pkgver" "$(DESTDIR)/lib/libwasmer.so.$$shortver" && \ | ||
ln -sf "libwasmer.so.$$pkgver" "$(DESTDIR)/lib/libwasmer.so.$$majorver" && \ | ||
ln -sf "libwasmer.so.$$pkgver" "$(DESTDIR)/lib/libwasmer.so" | ||
|
||
install-capi-staticlib: | ||
install -Dm644 target/release/libwasmer_c_api.a "$(DESTDIR)/lib/libwasmer.a" | ||
|
||
install-misc: | ||
install -Dm644 LICENSE "$(DESTDIR)"/share/licenses/wasmer/LICENSE | ||
|
||
install-pkgconfig: | ||
unset WASMER_DIR # Make sure WASMER_INSTALL_PREFIX is set during build | ||
target/release/wasmer config --pkg-config | install -Dm644 /dev/stdin "$(DESTDIR)"/lib/pkgconfig/wasmer.pc | ||
|
||
install-wasmer-headless-minimal: | ||
install -Dm755 target/release/wasmer-headless $(DESTDIR)/bin/wasmer-headless | ||
|
||
################# | ||
# Miscellaneous # | ||
################# | ||
|
@@ -678,7 +719,7 @@ lint-packages: | |
RUSTFLAGS=${RUSTFLAGS} cargo clippy -p wasmer-compiler | ||
RUSTFLAGS=${RUSTFLAGS} cargo clippy -p wasmer-compiler-cranelift | ||
RUSTFLAGS=${RUSTFLAGS} cargo clippy -p wasmer-compiler-singlepass | ||
RUSTFLAGS=${RUSTFLAGS} cargo clippy -p wasmer-cli | ||
RUSTFLAGS=${RUSTFLAGS} cargo clippy --manifest-path lib/cli/Cargo.toml $(compiler_features) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since LLVM is likely to be part of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I guess I'll add that to the CI setup. There actually was one problem in the code that would have been caught by linting with all compilers on. Should I additionally keep the "lint with all off"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reckon we should keep the Lints as they are in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not an option, as compiling without any compiler_features will fail. But I guess I could temporarily remove linting wasmer-cli and do another PR? Dangerous... |
||
RUSTFLAGS=${RUSTFLAGS} cargo clippy -p wasmer-cache | ||
RUSTFLAGS=${RUSTFLAGS} cargo clippy -p wasmer-engine | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Wasmer distro packaging notes | ||
|
||
* Where possible, do not directly invoke cargo, but use the supplied Makefile | ||
* wasmer has several compiler backends and the Makefile autodetects whether to enable llvm and singlepass. | ||
Set `ENABLE_{CRANELIFT,LLVM,SINGLEPASS}=1` to build the full set or fail trying | ||
* Set `WASMER_CAPI_USE_SYSTEM_LIBFFI=1` to force dynamic linking of libffi on the shared library | ||
* `make install` respects `DESTDIR`, but `prefix` must be configured as e.g. `WASMER_INSTALL_PREFIX=/usr make all` | ||
* In case you must build/install directly with cargo, make sure to enable at least one compiler backend feature | ||
* Beware that compiling with `cargo build --workspace/--all --features ...` will not enable features on the subcrates in the workspace and result in a headless wasmer binary that can not run wasm files directly. | ||
* If you split the package into several subpackages, beware that the create-exe command of wasmer requires `libwasmer.a` to be installed at `$WASMER_INSTALL_PREFIX/lib/libwasmer.a`. | ||
Suggestion for splitting: | ||
* `wasmer` and `wasmer-headless`, containing the respective executables | ||
* `wasmer-headless` contains a subset of `wasmer`'s functionality and should only be packaged when splitting - it must be built explicitly with `make build-wasmer-headless-minimal install-wasmer-headless-minimal` | ||
* `libwasmer`, containing `libwasmer.so*` | ||
* `libwasmer-dev`, containing the header files and a `.pc` file | ||
* `libwasmer-static`, containing `libwasmer.a` | ||
|
||
The wasmer distro packaging story is still in its infancy, so feedback is very welcome. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-env-changed=WASMER_INSTALL_PREFIX"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
use wasmer_cli::cli::wasmer_main; | ||
|
||
#[cfg(not(any(feature = "cranelift", feature = "singlepass", feature = "llvm")))] | ||
compile_error!( | ||
"Either enable at least one compiler, or compile the wasmer-headless binary instead" | ||
); | ||
jcaesar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
fn main() { | ||
wasmer_main(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a mention that
install-capi-lib
is for Linux distros only, which excludes Darwin and Windows. A simple documentation line dropped beforeinstall-capi-lib
would be OK for me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I could also migrate some parts over from
package-capi
to support Windows/Darwin, but I have little in the way of testing it.I'm also not exactly happy with the duplication between
package-*
andinstall-*
, but I don't think I can smoothly migrate whatever is usingpackage-*
toinstall-*
. I'll leave that for someone with more inside knowledge.