I am trying to build my project for armv7 on a Mac (M1). The project uses openssl and declares it as dependency like this:
openssl = { version = "0.10", features = ["vendored"] }
I created a dockerfile like this
FROM rust:latest
RUN apt update && apt upgrade -y
RUN apt install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross openssl libssl-dev pkg-config
RUN rustup target add armv7-unknown-linux-gnueabihf
RUN rustup toolchain install stable-armv7-unknown-linux-gnueabihf
WORKDIR /app
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
RUN export OPENSSL_DIR=`openssl version -d`
CMD ["cargo", "build", "--target", "armv7-unknown-linux-gnueabihf", "--release"]
but when I lauch the image to build the project the build fails when compiling openssl. The error I get is this:
--- stderr
arm-linux-gnueabihf-ar: creating apps/libapps.a
arm-linux-gnueabihf-ar: creating libssl.a
arm-linux-gnueabihf-ar: creating libcrypto.a
arm-linux-gnueabihf-ar: crypto/dso/dso_win32.o: Operation not permitted
make[1]: *** [Makefile:727: libcrypto.a] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:177: build_libs] Error 2
thread 'main' panicked at '
Error building OpenSSL:
Command: cd "/app/target/armv7-unknown-linux-gnueabihf/release/build/openssl-sys-5ca185d59ecdacfe/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=8,12 --jobserver-auth=8,12" "make" "build_libs"
Exit status: exit status: 2
', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-111.24.0+1.1.1s/src/lib.rs:498:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I don't understand what is going on here.
Update: I tried with cross and the error is very similar:
--- stderr
<jemalloc>: MADV_DONTNEED does not work (memset will be used instead)
<jemalloc>: (This is the expected behaviour if you are running under QEMU)
make: Warning: File 'Makefile' has modification time 0.14 s in the future
make: warning: Clock skew detected. Your build may be incomplete.
crypto/asn1/a_int.c: In function 'asn1_string_get_int64':
crypto/asn1/a_int.c:260:19: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
} else if (r == ABS_INT64_MIN) {
^
crypto/asn1/a_int.c:252:14: note: 'r' was declared here
uint64_t r;
^
arm-linux-gnueabihf-ar: creating apps/libapps.a
arm-linux-gnueabihf-ar: creating libssl.a
arm-linux-gnueabihf-ar: creating libcrypto.a
arm-linux-gnueabihf-ar: crypto/des/pcbc_enc.o: Operation not permitted
make[1]: *** [libcrypto.a] Error 1
make: *** [build_libs] Error 2
thread 'main' panicked at '
Error building OpenSSL:
Command: cd "/target/armv7-unknown-linux-gnueabihf/debug/build/openssl-sys-e7e5ee7368f76501/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=15,16 --jobserver-auth=15,16" "make" "build_libs"
Exit status: exit status: 2
', /cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.24.0+1.1.1s/src/lib.rs:498:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace