I am embedding wasmer in a go application and want to make a proper static binary. I also had issues with the cdylib I compiled under recent Ubuntu not working on old versions of linux (like CentOS7, which uses glibc 2.12 I believe).
So, after installing the toolchains, I ended up with something like:
RUSTFLAGS="-C target-feature=-crt-static" rustup run nightly cargo build --release --target x86_64-unknown-linux-musl
This managed to compile and link most of the deps, but it dies on wasmer-runtime-core
This is build on Ubuntu 18.04 with a recent rust nightly (12-26-2019) and wasmer 0.12.
I ran the following beforehand:
sudo apt install musl-tools
rustup target add x86_64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl --toolchain=nightly
I thought this would compile.
error[E0432]: unresolved imports `libc::_libc_xmmreg`, `libc::REG_R10`, `libc::REG_R11`, `libc::REG_R12`, `libc::REG_R13`, `libc::REG_R14`, `libc::REG_R15`, `libc::REG_R8`, `libc::REG_R9`, `libc::REG_RAX`, `libc::REG_RBP`, `libc::REG_RBX`, `libc::REG_RCX`, `libc::REG_RDI`, `libc::REG_RDX`, `libc::REG_RIP`, `libc::REG_RSI`, `libc::REG_RSP`
--> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-0.12.0/src/fault.rs:552:9
|
552 | _libc_xmmreg, ucontext_t, REG_R10, REG_R11, REG_R12, REG_R13, REG_R14, REG_R15, REG_R8,
| ^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^ no `REG_R8` in the root
| | | | | | | |
| | | | | | | no `REG_R15` in the root
| | | | | | no `REG_R14` in the root
| | | | | no `REG_R13` in the root
| | | | no `REG_R12` in the root
| | | no `REG_R11` in the root
| | no `REG_R10` in the root
| no `_libc_xmmreg` in the root
553 | REG_R9, REG_RAX, REG_RBP, REG_RBX, REG_RCX, REG_RDI, REG_RDX, REG_RIP, REG_RSI, REG_RSP,
| ^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^
| | |
| | no `REG_RAX` in the root
| | help: a similar name exists in the module: `ORIG_RAX`
| no `REG_R9` in the root
Compiling schemars v0.5.1
Compiling cbindgen v0.9.1
Compiling cosmwasm v0.6.3
error[E0609]: no field `gregs` on type `libc::unix::linux_like::linux::musl::b64::x86_64::mcontext_t`
--> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-0.12.0/src/fault.rs:574:46
|
574 | let gregs = &mut (*ucontext).uc_mcontext.gregs;
| ^^^^^ unknown field
error[E0609]: no field `fpregs` on type `libc::unix::linux_like::linux::musl::b64::x86_64::mcontext_t`
--> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-0.12.0/src/fault.rs:595:33
|
595 | if !(*ucontext).uc_mcontext.fpregs.is_null() {
| ^^^^^^ unknown field
error[E0609]: no field `fpregs` on type `libc::unix::linux_like::linux::musl::b64::x86_64::mcontext_t`
--> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-0.12.0/src/fault.rs:596:48
|
596 | let fpregs = &*(*ucontext).uc_mcontext.fpregs;
| ^^^^^^ unknown field
Thanks for reporting this! It looks like some of these issues have been fixed on Wasmer master already and I've made a PR to libc to add the rest!
Nice response. And thanks.
This should be fixed now in master with #1180. Closing issue.
Feel free to comment here @ethanfrey if the bug persists
Thanks @syrusakbary and @MarkMcCaskey Super fast turnaround time
@losfair shipped the an intermediary change which should work in most situations (mentioned in the PR comments). We'll update it to be fully correct once the libc PR lands!
I've been in frontend land for our blockchain, and just got back into rust land, including binding with go. And tried out static builds of dlls. It looks much better than last time, but I still got two errors.
error[E0432]: unresolved imports `libc::REG_R10`, `libc::REG_R11`, `libc::REG_R12`, `libc::REG_R13`, `libc::REG_R14`, `libc::REG_R15`, `libc::REG_R8`, `libc::REG_R9`, `libc::REG_RAX`, `libc::REG_RBP`, `libc::REG_RBX`, `libc::REG_RCX`, `libc::REG_RDI`, `libc::REG_RDX`, `libc::REG_RIP`, `libc::REG_RSI`, `libc::REG_RSP`
--> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-0.14.1/src/fault.rs:817:21
|
817 | ucontext_t, REG_R10, REG_R11, REG_R12, REG_R13, REG_R14, REG_R15, REG_R8, REG_R9, REG_RAX,
| ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^ ^^^^^^ ^^^^^^^
| | | | | | | | | |
| | | | | | | | | no `REG_RAX` in the root
| | | | | | | | | help: a similar name exists in the module: `ORIG_RAX`
| | | | | | | | no `REG_R9` in the root
| | | | | | | no `REG_R8` in the root
| | | | | | no `REG_R15` in the root
| | | | | no `REG_R14` in the root
| | | | no `REG_R13` in the root
| | | no `REG_R12` in the root
| | no `REG_R11` in the root
| no `REG_R10` in the root
818 | REG_RBP, REG_RBX, REG_RCX, REG_RDI, REG_RDX, REG_RIP, REG_RSI, REG_RSP,
| ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^
| |
| no `REG_RBP` in the root
Compiling cosmwasm v0.7.0
error[E0609]: no field `gregs` on type `libc::unix::linux_like::linux::musl::b64::x86_64::mcontext_t`
--> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-0.14.1/src/fault.rs:840:46
|
840 | let gregs = &mut (*ucontext).uc_mcontext.gregs;
| ^^^^^ unknown field
error: aborting due to 2 previous errors
These seem to be libc issues, here is the section from Cargo.lock:
[[package]]
name = "libc"
version = "0.2.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
This is the same compiler environment (and musl instalation) as above. Running in Ubuntu 18.04 with rust 1.40 stable, 1.42 nightly
$ cargo --version
cargo 1.40.0 (bc8e4c8be 2019-11-22)
$ cargo +nightly --version
cargo 1.42.0-nightly (86134e766 2019-12-23)
I will update them and try again
I updated code and tried again:
$ cargo +nightly --version
cargo 1.43.0-nightly (e57bd0299 2020-02-21)
[[package]]
name = "libc"
version = "0.2.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
And it does compile (no more rust errors!). :tada:
Most helpful comment
Thanks @syrusakbary and @MarkMcCaskey Super fast turnaround time