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

Example for using cross from x86_64 to arm64 for a package using libssl-dev ? #486

Closed
shadiakiki1986 opened this issue Nov 15, 2020 · 3 comments

Comments

@shadiakiki1986
Copy link

The package I'm trying to cross-compile depends on libssl-dev.

I'm trying to cross-compile it to arm64 to benefit from some cost reductions on aws t4g.nano instances,
but I couldn't get it to work.

My thoughts were that I'd need a custom docker image as follows

FROM rustembedded/cross:aarch64-unknown-linux-gnu-0.2.1
RUN dpkg --add-architecture arm64 && \
    apt-get update && \
    apt-get install --assume-yes libssl-dev pkg-config

whereby I would've thought that I should use libssl-dev:arm64 in the above, but that doesn't exist, eg by running:

docker run rustembedded/cross:aarch64-unknown-linux-gnu-0.2.1 dpkg --add-architecture arm64 &&     sudo apt-get update &&     sudo apt-cache search libssl-dev:arm64

with the output at https://pastebin.com/7Q6FzRS4

Is there an example of this somewhere?

@jbg
Copy link

jbg commented Jan 2, 2021

If your package uses openssl via native-tls, you can consider enabling the vendored feature of native-tls to build openssl as part of the cargo build.

@Alexhuszagh
Copy link
Contributor

This is relatively trivial now, and is well documented. An example repository of using a non-vendored, system OpenSSL install with pkg-config to find the OpenSSL installation for the aarch64 architecture is shown.

The logic is quite simple. First, create a Dockerfile with your additional dependencies:

FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge
RUN dpkg --add-architecture arm64
RUN apt-get update && apt-get install --assume-yes libssl-dev:arm64

Then build the image:

docker build -t openssl:aarch64 .

Update Cross.toml to use your custom image:

[target.aarch64-unknown-linux-gnu]
image = "openssl:aarch64"

And then you can use the openssl crate. Documenting how to use abstract external dependencies is shown here.

@Alexhuszagh
Copy link
Contributor

Because this is a fairly common use case, I've documented in the Recipes on the Wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants