Skip to content

Commit

Permalink
Merge #3134
Browse files Browse the repository at this point in the history
3134: Bring libwasmer-headless.a from 22MiB to 7.2MiB (on my machine) r=epilys a=epilys

By using lto optimization flags.

A qjs.wasm executable using the headless engine now weights 4.6MiB:

% du -sh qjs-he*.out
 20M    qjs-headfull.out
4.6M    qjs-headless.out

<!-- 
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests

-->

# Description
<!-- 
Provide details regarding the change including motivation,
links to related issues, and the context of the PR.
-->

# Review

- [ ] Add a short description of the change to the CHANGELOG.md file


Co-authored-by: Manos Pitsidianakis <[email protected]>
  • Loading branch information
bors[bot] and epilys authored Aug 23, 2022
2 parents a077f4c + 056268c commit 6b199f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ build-wasmer-headless-minimal: RUSTFLAGS += -C panic=abort
build-wasmer-headless-minimal:
RUSTFLAGS="${RUSTFLAGS}" xargo build --target $(HOST_TARGET) --release --manifest-path=lib/cli/Cargo.toml --no-default-features --features headless-minimal --bin wasmer-headless
ifeq ($(IS_DARWIN), 1)
strip -u target/$(HOST_TARGET)/release/wasmer-headless
strip target/$(HOST_TARGET)/release/wasmer-headless
else ifeq ($(IS_WINDOWS), 1)
strip --strip-unneeded target/$(HOST_TARGET)/release/wasmer-headless.exe
else
Expand Down Expand Up @@ -455,8 +455,13 @@ build-capi-llvm-universal: capi-setup
# Headless (we include the minimal to be able to run)

build-capi-headless: capi-setup
RUSTFLAGS="${RUSTFLAGS} -C panic=abort" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
ifeq ($(CARGO_TARGET),)
RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build --target $(HOST_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features compiler-headless,wasi
else
RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features compiler-headless,wasi
endif

build-capi-headless-ios: capi-setup
RUSTFLAGS="${RUSTFLAGS} -C panic=abort" cargo lipo --manifest-path lib/c-api/Cargo.toml --release \
Expand Down
2 changes: 1 addition & 1 deletion lib/c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ edition = "2018"
# a conflict with the existing `wasmer` crate, see below.
name = "wasmer" # ##lib.name##
# ^ DO NOT REMOVE, it's used the `Makefile`, see `build-docs-capi`.
crate-type = ["cdylib", "rlib", "staticlib"]
crate-type = ["staticlib", "cdylib"] #"cdylib", "rlib", "staticlib"]

[dependencies]
# We rename `wasmer` to `wasmer-api` to avoid the conflict with this
Expand Down
3 changes: 0 additions & 3 deletions lib/wasi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ license = "MIT"
readme = "README.md"
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
cfg-if = "1.0"
thiserror = "1"
Expand Down

0 comments on commit 6b199f9

Please sign in to comment.