Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Unable to compile with openssl for aarch64-unknown-linux-gnu #227

Open
1 of 3 tasks
bcba25 opened this issue Jan 1, 2023 · 5 comments
Open
1 of 3 tasks

Unable to compile with openssl for aarch64-unknown-linux-gnu #227

bcba25 opened this issue Jan 1, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@bcba25
Copy link

bcba25 commented Jan 1, 2023

Do the checklist before filing an issue:

Description

Hi, I'm creating this issue because i've spend a couple of DAYS trying to solve the following problem but no success.
I got a rust web server which has the following dependency openssl = { version = "=0.10.45", features = ["vendored"] } which is fails to compile when i use cross in Github Action. Previously it was working, but as i understand there is no longer support of openssl in cross so it is just started to fail. I've tried to install openssl, it is present in a system but during compilation i got the following error:

error: failed to run custom build command for `sasl2-sys v0.1.20+2.1.28`

Caused by:
  process didn't exit successfully: `/target/release/build/sasl2-sys-f091b2042744285f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=SASL2_STATIC
  cargo:rerun-if-env-changed=LIBSASL2_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
  thread 'main' panicked at 'Unable to find libsasl2 on your system. Hints:

    * Have you installed the libsasl2 development package for your platform?
      On Debian-based systems, try libsasl2-dev. On RHEL-based systems, try
      cyrus-sasl-devel. On macOS with Homebrew, try cyrus-sasl.

    * Have you incorrectly set the SASL2_STATIC environment variable when your
      system only supports dynamic linking?

    * Are you willing to enable the `vendored` feature to instead build and link
      against a bundled copy of libsasl2?
  ', /cargo/registry/src/github.com-1ecc6299db9ec823/sasl2-sys-0.1.20+2.1.28/build.rs:342:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Looking for help and suggestions for this, thank you very much

Workflow code

This is my pipeline which was working previously:

...
jobs:
  build:
    name: Build for Raspberry PI
    runs-on: ubuntu-20.04

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2
        with:
          submodules: recursive

      - uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.62.1-x86_64-unknown-linux-gnu
          target: aarch64-unknown-linux-gnu
          override: true

      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --release --target aarch64-unknown-linux-gnu
...

Action output

error: failed to run custom build command for `sasl2-sys v0.1.20+2.1.28`

Caused by:
  process didn't exit successfully: `/target/release/build/sasl2-sys-f091b2042744285f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=SASL2_STATIC
  cargo:rerun-if-env-changed=LIBSASL2_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
  thread 'main' panicked at 'Unable to find libsasl2 on your system. Hints:

    * Have you installed the libsasl2 development package for your platform?
      On Debian-based systems, try libsasl2-dev. On RHEL-based systems, try
      cyrus-sasl-devel. On macOS with Homebrew, try cyrus-sasl.

    * Have you incorrectly set the SASL2_STATIC environment variable when your
      system only supports dynamic linking?

    * Are you willing to enable the `vendored` feature to instead build and link
      against a bundled copy of libsasl2?
  ', /cargo/registry/src/github.com-1ecc6299db9ec823/sasl2-sys-0.1.20+2.1.28/build.rs:342:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior

Should be able to cross compile to specified target especially when openssl is set as vendored

Additional context

I had another pipeline which doesn't compile due to openssl but it is not cross compiling to another target and it was fixed just but adding those suggested commands.

I've tried adding following configuration but doesn't matter what i do openssl package can't detect openssl on a system

sudo apt install libssl-dev libsasl2-dev
touch $HOME/.cargo/config && cd $HOME/.cargo
echo [target.aarch64-unknown-linux-gnu] >> ./config
echo pre-build = [\"sudo apt install libssl-dev libsasl2-dev\"] >> ./config

and

sudo dpkg --add-architecture arm64
sudo apt-get update && sudo apt install libssl-dev libssl-dev:arm64 libsasl2-dev -y
sudo apt install gcc-aarch64-linux-gnu
sudo apt-get install build-essential gcc make perl dkms
touch $HOME/.cargo/config && cd $HOME/.cargo
echo "[target.aarch64-unknown-linux-gnu]" >> ./config
echo "linker = \"/usr/bin/aarch64-linux-gnu-gcc\"" >> ./config

Looking for help and suggestions for this, thank you very much

@bcba25 bcba25 added the bug Something isn't working label Jan 1, 2023
@lpil
Copy link

lpil commented Jan 12, 2023

Hello! Did you figure out a way around this?

@uncomfyhalomacro
Copy link

Hello! Did you figure out a way around this?

The issue is similar to sfackler/rust-openssl#1865 (comment). You can't compile it because the deps can't be carried over to the docker container (which cross uses) from the host even if the host has libssl-dev

@hilaolu
Copy link

hilaolu commented Apr 14, 2023

It doesn't work for musl target neither.

@uncomfyhalomacro
Copy link

It doesn't work for musl target neither.

The repository seems to be abandoned. I guess let's look elsewhere. I don't use this action, but I want to contribute to a project that uses it which caused some issues there too

@fosskers
Copy link

A similar problem happens if you need protoc installed on the system to build a Rust crate. This repo doesn't seem to advertise a way to include system dependencies into the Docker image that cross runs in.

For the openssl problem specifically, I managed to get around it. Even if your main crate doesn't depend on openssl, you can command all transitive variants of it to be vendored by doing:

[dependencies.openssl-sys]
version = "0.9"
features = ["vendored"]

and by making sure also to set resolver = "1".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

No branches or pull requests

5 participants