Skip to content

Commit

Permalink
chore: move darwin static build to separate example
Browse files Browse the repository at this point in the history
  • Loading branch information
helder-moreira committed Jan 24, 2023
1 parent 1635da2 commit d323e99
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ jobs:
mkdir artifacts
cp ./internal/api/libwasmvm_muslc.a artifacts/libwasmvm_muslc.x86_64.a
cp ./internal/api/libwasmvm_muslc.aarch64.a artifacts/libwasmvm_muslc.aarch64.a
cp ./internal/api/static/libwasmvm_darwin.a artifacts/libwasmvm_darwin.a
cp ./internal/api/libwasmvmstatic_darwin.a artifacts/libwasmvmstatic_darwin.a
- run:
name: Create checksums
working_directory: artifacts
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ release-build-macos-static:
-v $(shell pwd)/libwasmvm:/code \
-v $(shell pwd)/builders/guest/build_macos_static.sh:/usr/local/bin/build_macos_static.sh \
$(BUILDERS_PREFIX)-cross build_macos_static.sh
cp libwasmvm/artifacts/libwasmvm_darwin.a internal/api/static/libwasmvm_darwin.a
cp libwasmvm/artifacts/libwasmvmstatic_darwin.a internal/api/libwasmvmstatic_darwin.a
make update-bindings

# Creates a release build in a containerized build environment of the shared library for Windows (.dll)
Expand Down
2 changes: 1 addition & 1 deletion builders/guest/build_macos_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export CXX=o64-clang++
cargo build --release --target x86_64-apple-darwin --example wasmvmstatic

# Create a universal library with both archs
lipo -output artifacts/libwasmvm_darwin.a -create \
lipo -output artifacts/libwasmvmstatic_darwin.a -create \
target/x86_64-apple-darwin/release/examples/libwasmvmstatic.a \
target/aarch64-apple-darwin/release/examples/libwasmvmstatic.a
8 changes: 4 additions & 4 deletions builders/guest/build_muslc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ set -e # Note we are not using bash here but the Alpine default shell

echo "Starting aarch64-unknown-linux-musl build"
export CC=/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
cargo build --release --target aarch64-unknown-linux-musl --example wasmvmstatic
cargo build --release --target aarch64-unknown-linux-musl --example muslc
unset CC

echo "Starting x86_64-unknown-linux-musl build"
cargo build --release --target x86_64-unknown-linux-musl --example wasmvmstatic
cargo build --release --target x86_64-unknown-linux-musl --example muslc

cp target/aarch64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.aarch64.a
cp target/x86_64-unknown-linux-musl/release/examples/libwasmvmstatic.a artifacts/libwasmvm_muslc.a
cp target/aarch64-unknown-linux-musl/release/examples/libmuslc.a artifacts/libwasmvm_muslc.aarch64.a
cp target/x86_64-unknown-linux-musl/release/examples/libmuslc.a artifacts/libwasmvm_muslc.a
2 changes: 1 addition & 1 deletion internal/api/link_mac_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

package api

// #cgo LDFLAGS: -L${SRCDIR}/static -lwasmvm_darwin
// #cgo LDFLAGS: -L${SRCDIR} -lwasmvmstatic_darwin
import "C"
Binary file removed internal/api/static/libwasmvm_darwin.a
Binary file not shown.
9 changes: 7 additions & 2 deletions libwasmvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ readme = "README.md"
exclude = [".circleci/*", ".gitignore"]

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

# the example is to allow us to compile a muslc static lib with the same codebase as we compile the
# normal dynamic libs (best workaround I could find to override crate-type on the command line)
[[example]]
name = "wasmvmstatic"
name = "muslc"
path = "src/lib.rs"
crate-type = ["staticlib"]

[[example]]
name = "wasmvmstatic"
path = "src/examples/wasmvmstatic.rs"
crate-type = ["staticlib"]

[features]
default = []
# This feature requires Rust nightly because it depends on the unstable backtrace feature.
Expand Down
1 change: 1 addition & 0 deletions libwasmvm/src/examples/wasmvmstatic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use wasmvm::*;

0 comments on commit d323e99

Please sign in to comment.