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

Build error for innernet binary on AlpineLinux #107

Closed
fuller0815 opened this issue Jun 24, 2021 · 8 comments
Closed

Build error for innernet binary on AlpineLinux #107

fuller0815 opened this issue Jun 24, 2021 · 8 comments

Comments

@fuller0815
Copy link

I tried to build the innernet client binary on Alpine Linux with stable-x86_64-unknown-linux-musl as the default toolchain for Rust.
There is an error while building wgctrl-sys I cannot solve:

$ cargo build --release --bin innernet
Compiling serde v1.0.126
Compiling wgctrl-sys v1.4.0-beta.3 (/home/sysadmin/tmp/innernet-1.4.0-beta.3/wgctrl-sys)
error: failed to run custom build command for wgctrl-sys v1.4.0-beta.3 (/home/sysadmin/tmp/innernet-1.4.0-beta.3/wgctrl-sys)

Caused by:
process didn't exit successfully: /home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/build/wgctrl-sys-4aed27b106087c18/build-script-build (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: build failed

Any hint where to search?

Thanks, fuller

@strohel
Copy link
Member

strohel commented Jun 24, 2021

Whoa, that looks like a compiler crash. You may be the first person to try building with must libc. I'm not sure if that's supposed to work (I know building on static musl libc had limitations with proc macros), but it it hopefully shouldn't crash.

General hint is to run with -v to see exact failing command: cargo build -v --release --bin innernet.

@fuller0815
Copy link
Author

Already tried that, but -v only gives the above error message.

@strohel
Copy link
Member

strohel commented Jun 24, 2021

It looks like the following rust issues are related to this:
rust-lang/rust#76021
rust-lang/rust#84576

@fuller0815
Copy link
Author

Looks more like rust-lang/rust/issues/82193 ...

@fuller0815
Copy link
Author

Ok, if I add

[build] rustflags = [ "-C", "target-feature=-crt-static" ]
to .cargo/config.toml and ran the build again, wgctrl-sys compiles, but wgctrl errors out due to undefined fields:

Compiling wgctrl v1.4.0-beta.3 (/home/sysadmin/tmp/innernet-1.4.0-beta.3/wgctrl-rs) Running rustc --crate-name wgctrl --edition=2018 wgctrl-rs/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C metadata=a6f9ad40fc03bd67 -C extra-filename=-a6f9ad40fc03bd67 --out-dir /home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps -L dependency=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps --extern base64=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/libbase64-632c34b96a1dccfe.rmeta --extern hex=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/libhex-c51b72f2fa9c8b35.rmeta --extern libc=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/liblibc-63a365dedaa12bf0.rmeta --extern wgctrl_sys=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/libwgctrl_sys-53ca2a2ce8decc0b.rmeta -C target-feature=-crt-static -L native=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/build/wgctrl-sys-fd680249f180a1cb/out
error[E0609]: no field __in6_u on type wgctrl_sys::in6_addr
--> wgctrl-rs/src/backends/kernel.rs:21:62
|
21 | IpAddr::V6(unsafe { raw.__bindgen_anon_1.ip6.__in6_u.__u6_addr8 }.into())
| ^^^^^^^ unknown field
|
= note: available fields are: __in6_union

error[E0609]: no field __in6_u on type wgctrl_sys::in6_addr
--> wgctrl-rs/src/backends/kernel.rs:157:50
|
157 | let bytes = unsafe { addr6.sin6_addr.__in6_u.__u6_addr8 };
| ^^^^^^^ unknown field
|
= note: available fields are: __in6_union

error[E0609]: no field __in6_u on type wgctrl_sys::in6_addr
--> wgctrl-rs/src/backends/kernel.rs:193:51
|
193 | wg_allowedip.__bindgen_anon_1.ip6.__in6_u.__u6_addr8 = a.octets();
| ^^^^^^^ unknown field
|
= note: available fields are: __in6_union

error[E0560]: union in6_addr__bindgen_ty_1 has no field named __u6_addr8
--> wgctrl-rs/src/backends/kernel.rs:223:17
|
223 | __u6_addr8: s.ip().octets(),
| ^^^^^^^^^^ help: a field with a similar name exists: __s6_addr

error[E0560]: struct wgctrl_sys::in6_addr has no field named __in6_u
--> wgctrl-rs/src/backends/kernel.rs:227:51
|
227 | sin6_addr: wgctrl_sys::in6_addr { __in6_u: in6_addr },
| ^^^^^^^ wgctrl_sys::in6_addr does not have this field
|
= note: available fields are: __in6_union

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0560, E0609.
For more information about an error, try rustc --explain E0560.
error: could not compile wgctrl

Caused by:
process didn't exit successfully: rustc --crate-name wgctrl --edition=2018 wgctrl-rs/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C metadata=a6f9ad40fc03bd67 -C extra-filename=-a6f9ad40fc03bd67 --out-dir /home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps -L dependency=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps --extern base64=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/libbase64-632c34b96a1dccfe.rmeta --extern hex=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/libhex-c51b72f2fa9c8b35.rmeta --extern libc=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/liblibc-63a365dedaa12bf0.rmeta --extern wgctrl_sys=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/deps/libwgctrl_sys-53ca2a2ce8decc0b.rmeta -C target-feature=-crt-static -L native=/home/sysadmin/tmp/innernet-1.4.0-beta.3/target/release/build/wgctrl-sys-fd680249f180a1cb/out (exit status: 1)

@fuller0815
Copy link
Author

fuller0815 commented Jun 25, 2021

The bindings to the WireGuard embeddable C Library are the problem, I think. There seems to be a problem with IPv6.
I was able to finish the build after commenting out the IPv6 parts in wgctrl-rs/src/backend/kernel.rs.

@fuller0815
Copy link
Author

fuller0815 commented Jun 25, 2021

The binary works as expected, as long as you do not need IPv6.

@mcginty
Copy link
Collaborator

mcginty commented Feb 2, 2022

Innernet no longer uses the WireGuard FFI and builds just fine on Alpine :).

@mcginty mcginty closed this as completed Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants