Skip to content
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

feat(go): switch to static build #232

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- master
- staging
- trying
pull_request:
schedule:
- cron: '0 2 * * *' # To test `wasmer-nightly` with `libwasmer_archive_name`.

Expand Down Expand Up @@ -70,7 +71,7 @@ jobs:
curl -L $libwasmer_url > release.tar.gz
tar xzvf release.tar.gz -C libwasmer
export CGO_CFLAGS="-I$(pwd)/libwasmer/include/"
export CGO_LDFLAGS="-Wl,-rpath,$(pwd)/libwasmer/lib/ -L$(pwd)/libwasmer/lib/ -lwasmer"
export CGO_LDFLAGS="-static -Wl,-rpath,$(pwd)/libwasmer/lib/ -L$(pwd)/libwasmer/lib/ -lwasmer -lm -ldl"
just test -tags custom_wasmer_runtime

- name: Run all the examples
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["golang", "extension", "webassembly"]
categories = ["wasm"]

[lib]
crate-type = ["cdylib"]
crate-type = ["staticlib"]

[dependencies]
wasmer-c-api = { git = "https://github.com/wasmerio/wasmer", branch = "master" }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ this library works (and is tested) on the following platforms:

```sh
$ # Build the new Wasmer C API shared object library.
$ cargo build --release
$ cargo build --release --features native
$
$ # Configure cgo.
$ export CGO_CFLAGS="-I$(pwd)/wasmer/packaged/include/"
$ export CGO_LDFLAGS="-Wl,-rpath,$(pwd)/target/release/ -L$(pwd)/target/release/ -lwasmer_go"
$ export CGO_LDFLAGS="-static -Wl,-rpath,$(pwd)/target/release/ -L$(pwd)/target/release/ -lwasmer_go -lm -ldl"
$
$ # Run the tests.
$ just test -tags custom_wasmer_runtime
Expand Down
2 changes: 1 addition & 1 deletion wasmer/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package wasmer

// #cgo CFLAGS: -I${SRCDIR}/packaged/include
// #cgo LDFLAGS: -lwasmer
// #cgo LDFLAGS: -static -lwasmer -lm -ldl
//
// #cgo linux,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/linux-amd64 -L${SRCDIR}/packaged/lib/linux-amd64
// #cgo linux,arm64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/linux-aarch64 -L${SRCDIR}/packaged/lib/linux-aarch64
Expand Down
Binary file added wasmer/packaged/lib/darwin-amd64/libwasmer.a
Binary file not shown.
Binary file removed wasmer/packaged/lib/darwin-amd64/libwasmer.dylib
Binary file not shown.
Binary file added wasmer/packaged/lib/linux-aarch64/libwasmer.a
Binary file not shown.
Binary file removed wasmer/packaged/lib/linux-aarch64/libwasmer.so
Binary file not shown.
Binary file added wasmer/packaged/lib/linux-amd64/libwasmer.a
Binary file not shown.
Binary file removed wasmer/packaged/lib/linux-amd64/libwasmer.so
Binary file not shown.