cargo-zigbuild: [bug] - Zigbuilds fails - when static linking pkg-config
Description
cargo build --target aarch64-unknown-linux-gnu -r works fine ✅
but
cargo zigbuild --target aarch64-unknown-linux-gnu -r ❌
Steps to reproduce
Command
rustup target add aarch64-unknown-linux-gnu
cargo zigbuild --target aarch64-unknown-linux-gnu -r
Error
The following warnings were emitted during compilation:
warning: In file included from build/expando.c:1:
warning: In file included from /usr/include/openssl/opensslv.h:109:
warning: /usr/include/openssl/macros.h:14:10: fatal error: 'openssl/opensslconf.h' file not found
warning: #include <openssl/opensslconf.h>
warning: ^~~~~~~~~~~~~~~~~~~~~~~
warning: 1 error generated.
error: failed to run custom build command for `openssl-sys v0.9.80`
Caused by:
process didn't exit successfully: `/app/target/release/build/openssl-sys-bc542764a529c6f7/build-script-main` (exit status: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rustc-cfg=openssl
cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
OPENSSL_LIB_DIR = /usr/lib/aarch64-linux-gnu
cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
OPENSSL_INCLUDE_DIR = /usr/include
cargo:rustc-link-search=native=/usr/lib/aarch64-linux-gnu
cargo:include=/usr/include
cargo:rerun-if-changed=build/expando.c
OPT_LEVEL = Some("3")
TARGET = Some("aarch64-unknown-linux-gnu")
HOST = Some("aarch64-unknown-linux-gnu")
cargo:rerun-if-env-changed=CC_aarch64-unknown-linux-gnu
CC_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CC_aarch64_unknown_linux_gnu
CC_aarch64_unknown_linux_gnu = Some("/root/.cache/cargo-zigbuild/0.16.0/zigcc-aarch64-unknown-linux-gnu.sh")
cargo:rerun-if-env-changed=CFLAGS_aarch64-unknown-linux-gnu
CFLAGS_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CFLAGS_aarch64_unknown_linux_gnu
CFLAGS_aarch64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_CFLAGS
HOST_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("neon")
running: "/root/.cache/cargo-zigbuild/0.16.0/zigcc-aarch64-unknown-linux-gnu.sh" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "/usr/include" "-Wall" "-Wextra" "-E" "build/expando.c"
cargo:warning=In file included from build/expando.c:1:
cargo:warning=In file included from /usr/include/openssl/opensslv.h:109:
cargo:warning=/usr/include/openssl/macros.h:14:10: fatal error: 'openssl/opensslconf.h' file not found
cargo:warning=#include <openssl/opensslconf.h>
cargo:warning= ^~~~~~~~~~~~~~~~~~~~~~~
cargo:warning=1 error generated.
exit status: 1
--- stderr
thread 'main' panicked at '
Header expansion error:
Error { kind: ToolExecError, message: "Command \"/root/.cache/cargo-zigbuild/0.16.0/zigcc-aarch64-unknown-linux-gnu.sh\" \"-O3\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-I\" \"/usr/include\" \"-Wall\" \"-Wextra\" \"-E\" \"build/expando.c\" with args \"zigcc-aarch64-unknown-linux-gnu.sh\" did not execute successfully (status code exit status: 1)." }
Failed to find OpenSSL development headers.
You can try fixing this setting the `OPENSSL_DIR` environment variable
pointing to your OpenSSL installation or installing OpenSSL headers package
specific to your distribution:
# On Ubuntu
sudo apt-get install libssl-dev
# On Arch Linux
sudo pacman -S openssl
# On Fedora
sudo dnf install openssl-devel
# On Alpine Linux
apk add openssl-dev
See rust-openssl documentation for more information:
https://docs.rs/openssl
', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.80/build/main.rs:185:13
stack backtrace:
0: rust_begin_unwind
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
2: build_script_main::validate_headers
3: build_script_main::postprocess
4: build_script_main::main
5: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (6 by maintainers)
Docker isn’t required for
cargo-zigbuild, can you try run it directly on macOS? Cargo has some oddities when--targetis the same as the build/host target namely https://github.com/rust-lang/cargo/issues/3349.Thanks for the help! @NobodyXu