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

cross-compilation errors #47

Open
juli1 opened this issue Jun 30, 2023 · 12 comments
Open

cross-compilation errors #47

juli1 opened this issue Jun 30, 2023 · 12 comments
Labels
question Further information is requested

Comments

@juli1
Copy link

juli1 commented Jun 30, 2023

I am trying to cross-compile a program. There is the matrix of all the values that I defined:

      matrix:
        include:
          # Ubuntu
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          # Mac OS
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: universal-apple-darwin
            os: macos-latest
          # Windows
          - target: x86_64-pc-windows-msvc
            os: windows-latest

When compiling for Linux, I get the following output below. I tried installing libssl-dev in the GitHub action but it does not solve the problem.

Any idea how to solve this?

Thanks!

error: failed to run custom build command for `openssl-sys v0.9.90`

Caused by:
  process didn't exit successfully: `/home/runner/work/stella/stella/target/release/build/openssl-sys-aae445923f341257/build-script-main` (exit status: 101)
  --- stdout
  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 unset
  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 unset
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_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
  run pkg_config fail: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = aarch64-unknown-linux-gnu
  openssl-sys = 0.9.90

  ', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.90/build/find_normal.rs:190:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.
@taiki-e
Copy link
Owner

taiki-e commented Jun 30, 2023

This action uses cross to cross-compile by default, and the cross wiki has a section on openssl.

Probably the easiest way is to enable the vendored feature of openssl crate.

@taiki-e taiki-e added the question Further information is requested label Jun 30, 2023
@juli1
Copy link
Author

juli1 commented Jun 30, 2023

The problem is that I do not control how openssl is imported since it's imported by my dependencies (I do not import it directly). I will try to go the route to install libssl but there are other challenges to do this in GitHub actions.

@taiki-e
Copy link
Owner

taiki-e commented Jun 30, 2023

Because of the feature unification, it will work even if you add openssl with vendored feature enabled as a dependency of your crate.

Also, I think another way that might work is to install the toolchain for linux using setup-cross-toolchain-action mentioned in cross-compilation examples in readme, then enable the APT packages for arm64 (sudo dpkg --add-architecture arm64) and install libssl-dev:arm64 via APT.

@juli1
Copy link
Author

juli1 commented Jun 30, 2023

Thank you for your email! I am trying to include the vendored feature for openssl and see if this works.

I already tried to install libssl-dev:arm64 in the GitHub action. For a reason I still do not understand, dpkg --add-architecture adds invalid sources in the sources.list, which results to the following error.

E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/main/binary-arm64/Packages  404  Not Found [IP: 91.189.91.38 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/main/binary-arm64/Packages  404  Not Found [IP: 91.189.91.38 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-security/main/binary-arm64/Packages  404  Not Found [IP: 91.189.91.38 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/main/binary-arm64/Packages  404  Not Found [IP: 91.189.91.38 80]

@williamfzc
Copy link

williamfzc commented Mar 6, 2024

@taiki-e

Thanks for your quick response!
Enabling vendored can fix this issue on Mac and Linux, but not work on Windows.
It produces another error error: failed to run custom build command for openssl-sys v0.9.95``

Same as p2panda/send-to-node#7

Adding vendored breaks the windows build actually. It works fine before.

@taiki-e
Copy link
Owner

taiki-e commented Mar 6, 2024

Hmm, is it possible to use the way that doesn't use openssl (i.e., use rustls)?.

@taiki-e
Copy link
Owner

taiki-e commented Mar 6, 2024

Adding vendored breaks the windows build actually.

It is actually quite odd that it is failing though, since tarpaulin can build with this action and vendored feature enabled openssl without problems.

https://github.com/xd009642/tarpaulin/blob/a33d6dae1bac153a3c59cd112c74fccc58ea11dc/.github/workflows/release.yml#L61

@williamfzc
Copy link

It is actually quite odd that it is failing though, since tarpaulin can build with this action and vendored feature enabled openssl without problems.

Thanks!

I have followed https://github.com/xd009642/tarpaulin/blob/a33d6dae1bac153a3c59cd112c74fccc58ea11dc/Cargo.toml#L64 and solved this problem.

It seems that this problem caused by the difference between git2/openssl and openssl.

@davincios

This comment was marked as off-topic.

@davincios

This comment was marked as off-topic.

@taiki-e
Copy link
Owner

taiki-e commented May 8, 2024

@davincios Your issue sounds like a bug in your code, not an openssl-related problem. Please submit a new issue with complete information (e.g., link to the repository) on the actual code that has the error and a link to full CI/CD logs.

@davincios
Copy link

@taiki-e awesome thank you for the quick response. I have opened a new issue with a link to the repository.

That code issue occurs only on Windows builds though still, although I have now reconfigured it. Somehow I cannot solve this openssl-sys v0.9.102 issue.

Here is my new opened issue, I would greatly appreciate any help! 😀

#76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants