cargo icon indicating copy to clipboard operation
cargo copied to clipboard

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

Open bcba25 opened this issue 2 years ago • 5 comments

Do the checklist before filing an issue:

  • [x] Is this related to the actions-rs Actions? If you think it's a problem related to Github Actions in general, use GitHub Community forum instead: https://github.community
  • [ ] You've read the Contributing section about bugs reporting: https://github.com/actions-rs/.github/blob/master/CONTRIBUTING.md#reporting-bugs
  • [ ] Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome.

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 avatar Jan 01 '23 03:01 bcba25

Hello! Did you figure out a way around this?

lpil avatar Jan 12 '23 11:01 lpil

Hello! Did you figure out a way around this?

The issue is similar to https://github.com/sfackler/rust-openssl/issues/1865#issuecomment-1491079210. 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

uncomfyhalomacro avatar Apr 10 '23 13:04 uncomfyhalomacro

It doesn't work for musl target neither.

hilaolu avatar Apr 14 '23 11:04 hilaolu

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

uncomfyhalomacro avatar Apr 17 '23 22:04 uncomfyhalomacro

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".

fosskers avatar Apr 24 '23 06:04 fosskers