Failed to build "openssl-sys" on yocto?

I‘m working on a project which depency on openssl-sys in Yocto , but it didn't work.There is error:

  error: failed to run custom build command for `openssl-sys v0.9.101`
| note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
|
| Caused by:
|   process didn't exit successfully: `/home/xxxx/yocto/build/tmp/work/aarch64-poky-linux/metricsservice/0.1.0-r0/build/target/release/build/openssl-sys-f23c1c93a0e81019/build-script-main` (exit status: 101)
|   --- stdout
|   cargo:rerun-if-env-changed=AARCH64_POKY_LINUX_OPENSSL_NO_VENDOR
|   AARCH64_POKY_LINUX_OPENSSL_NO_VENDOR unset
|   cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
|   OPENSSL_NO_VENDOR unset
|
|   --- stderr
|   thread 'main' panicked at /home/xxx/yocto/build/tmp/work/aarch64-poky-linux/metricsservice/0.1.0-r0/cargo_home/bitbake/openssl-src-300.2.3+3.2.1/src/lib.rs:366:18:
|   don't know how to configure OpenSSL for aarch64-poky-linux
|   stack backtrace:
|      0: rust_begin_unwind
|      1: core::panicking::panic_fmt
|      2: openssl_src::Build::build
|      3: build_script_main::find_vendored::get_openssl
|      4: build_script_main::find_openssl
|      5: build_script_main::main
|      6: 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...

The file of /home/xxx/yocto/build/tmp/work/aarch64-poky-linux/metricsservice/0.1.0-r0/cargo_home/bitbake/openssl-src-300.2.3+3.2.1/src/lib.rs shows the os have not the option of aarch64-poky-linux:

...........
         let os = match target {
            "aarch64-apple-darwin" => "darwin64-arm64-cc",
            // Note that this, and all other android targets, aren't using the
            // `android64-aarch64` (or equivalent) builtin target. That
            // apparently has a crazy amount of build logic in OpenSSL 1.1.1
            // that bypasses basically everything `cc` does, so let's just cop
            // out and say it's linux and hope it works.
            "aarch64-linux-android" => "linux-aarch64",
            "aarch64-unknown-freebsd" => "BSD-generic64",
            "aarch64-unknown-linux-gnu" => "linux-aarch64",
            "aarch64-unknown-linux-musl" => "linux-aarch64",
            "aarch64-alpine-linux-musl" => "linux-aarch64",
            "aarch64-unknown-netbsd" => "BSD-generic64",
            "aarch64_be-unknown-netbsd" => "BSD-generic64",
            "aarch64-pc-windows-msvc" => "VC-WIN64-ARM",
            "aarch64-uwp-windows-msvc" => "VC-WIN64-ARM-UWP",
            "arm-linux-androideabi" => "linux-armv4",

anyone know how to fix it ?

I think there are two options:

  • Disable the vendored feature of the openssl crate and install openssl inside the build env to dynamically link against a precompiled openssl. You may need to set OPENSSL_DIR to guide the build script to where openssl is installed.
  • Patch the openssl-src crate to add support for Yocto.

Thanks for your reply!!
The first option should not be useful for me because my build environment is x86_64, whereas my target device architecture is aarch64。
I will try the second option
THanks again!!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.