ring icon indicating copy to clipboard operation
ring copied to clipboard

Can't compile ring with target aarch64-unknown-linux-musl

Open nuvanti opened this issue 2 years ago • 16 comments

I don't use ring directly but via jsowebtoken, rustls, etc.

I am trying to compile on AWS Graviton EC2 and get the following error for the following command: cargo build --release --target aarch64-unknown-linux-musl

If you see the error message below, what stands out is:

No such file or directory (os error 2)', /home/ssm-user/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9

error: failed to run custom build command for ring v0.16.20

Caused by: process didn't exit successfully: /tmp/lambda_build/target/release/build/ring-6fdf78c41c5d5ad7/build-script-build (exit status: 101) --- stdout OPT_LEVEL = Some("z") TARGET = Some("aarch64-unknown-linux-musl") HOST = Some("aarch64-unknown-linux-gnu") CC_aarch64-unknown-linux-musl = None CC_aarch64_unknown_linux_musl = None TARGET_CC = None CC = None CROSS_COMPILE = None CFLAGS_aarch64-unknown-linux-musl = None CFLAGS_aarch64_unknown_linux_musl = None TARGET_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None DEBUG = Some("false") CARGO_CFG_TARGET_FEATURE = None

--- stderr running "aarch64-linux-musl-gcc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/tmp/lambda_build/target/aarch64-unknown-linux-musl/release/build/ring-8d8172b2ed11f37e/out/aesv8-armx-linux64.o" "/home/ssm-user/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S" thread 'main' panicked at 'failed to execute ["aarch64-linux-musl-gcc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/tmp/lambda_build/target/aarch64-unknown-linux-musl/release/build/ring-8d8172b2ed11f37e/out/aesv8-armx-linux64.o" "/home/ssm-user/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"]: No such file or directory (os error 2)', /home/ssm-user/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9

nuvanti avatar Oct 13 '21 23:10 nuvanti

Same here.

Leandros avatar Oct 17 '21 16:10 Leandros

My solution was to use the messense/rust-musl-cross:aarch64-musl docker image to cross-compile, rather than using rustup add target ....

Leandros avatar Oct 19 '21 15:10 Leandros

This is critical to be able to deploy to AWS Lambda.

To reproduce:

rustup target add x86_64-unknown-linux-musl && cargo build --release --target x86_64-unknown-linux-musl

In this case all the cross compilation requirmemts were met as I had been able to deploy other Rust based software.

duaneking avatar Nov 07 '21 04:11 duaneking

Hello, same for me even with the messense/rust-musl-cross:x86_64-musl

After more tests, now it's work with messense/rust-musl-cross:x86_64-musl

jmfiaschi avatar Nov 14 '21 14:11 jmfiaschi

Do we have an ETA? This is 100% blocking for many people.

Respectfully pinging @briansmith with good vibes and good intentions.

duaneking avatar Nov 15 '21 19:11 duaneking

What is the output of which aarch64-linux-musl-gcc?

Look at mk/cargo.sh and .github/ci.yml to see how to configure cross-compilation. I would recommend doing it with clang. Feel free to submit a PR that adds the aarch64-unknown-linux-musl target to .gitlab/ci.yml so we can ensure this works and help people understand which environment variables to set.

I think using clang instead of gcc for the C compiler (again, see mk/cargo.sh) will make it work easier.

briansmith avatar Nov 15 '21 19:11 briansmith

For portability, gcc should also be supported as some platforms prefer it.

I'm trying to use Ubuntu to cross compile and deploy to AWS lambda, Ring seems to be the only thing blocking that.

Thing is, Ubuntu support is core for a lot of devs because of its use for wsl2 (on windows to allow unix via containers) and because a lot of devs use ubuntu laptops for rust development machines professionally when their companies are too cheap to provide macbooks.

On my Ubuntu machine I can show that they are installed by simply typing aarch64-linux-gnu-gcc --version to get the Ubuntu specific version of Ubuntu 9.3.0-17ubuntu1-20.04) 9.3.0

duaneking avatar Nov 15 '21 19:11 duaneking

For portability, gcc should also be supported as some platforms prefer it.

I bet it does work. Presently you need to install a working musl toolchain for it. I believe if you use clang instead, it is easier.

On my Ubuntu machine I can show that they are installed by simply typing aarch64-linux-gnu-gcc --version to get the Ubuntu specific version of Ubuntu 9.3.0-17ubuntu1-20.04) 9.3.0

Please make a PR to add your configuration to ring's CI/CD, if you can. Then it would be easy for me to debug it.

briansmith avatar Nov 16 '21 01:11 briansmith

Unfortunately the code I'm deploying is such I can't make it public; but there is an easy repo.

In this case, I have a working musl toolchain on ubuntu; I was able to deploy to lambda just fine on it until I added the lambda_web crate; it seems to be triggered by the dependency of brotli and that pulls in Ring.

https://crates.io/crates/lambda-web/0.1.4

duaneking avatar Nov 16 '21 01:11 duaneking

failed to execute ["aarch64-linux-musl-gcc" makes it look a lot like the system can't find aarch64-linux-musl-gcc in the path.

briansmith avatar Nov 16 '21 17:11 briansmith

Unfortunately the code I'm deploying is such I can't make it public; but there is an easy repo.

You didn't give me the STR.

briansmith avatar Nov 16 '21 17:11 briansmith

You didn't give me the STR.

I'm confused by this comment and don't know what you mean.

The crate is at https://crates.io/crates/lambda-web/

aarch64-linux-musl-gcc is installed and we can easily get a version string from it on the cli, per the above.

duaneking avatar Nov 16 '21 20:11 duaneking

Just gonna cross-post this which solved the issue for me: https://github.com/briansmith/ring/issues/563#issuecomment-676861003

WilliamVenner avatar Jan 11 '22 17:01 WilliamVenner

@briansmith I’m running into the same issue described here, is there anything I could do to help?

jensmeindertsma avatar Feb 23 '22 14:02 jensmeindertsma

For the record I've been able to compile ring for aarch64 by using llvm like Brian mentioned.

I've taken environment variables from StackOverflow that took it from ring's config file:

ENV CC_aarch64_unknown_linux_musl=clang
ENV AR_aarch64_unknown_linux_musl=llvm-ar
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"

This of course needs LLVM and musl-tools: apt-get install musl-tools clang llvm -y

wiktor-k avatar Mar 01 '22 08:03 wiktor-k

Just encountered this today:

With RUST_BACKTRACE=1, the error output is:

error: failed to run custom build command for `ring v0.16.20`
Caused by:
  process didn't exit successfully: `/repo/target/release/build/ring-bdefb98f3de94c81/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("z")
  TARGET = Some("aarch64-unknown-linux-musl")
  HOST = Some("x86_64-unknown-linux-musl")
  CC_aarch64-unknown-linux-musl = None
  CC_aarch64_unknown_linux_musl = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_aarch64-unknown-linux-musl = None
  CFLAGS_aarch64_unknown_linux_musl = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("neon,pmuv3")
  --- stderr
  running "aarch64-linux-musl-gcc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/repo/target/aarch64-unknown-linux-musl/release/build/ring-4efa80a8699004e7/out/aesv8-armx-linux64.o" "/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"
  thread 'main' panicked at 'failed to execute ["aarch64-linux-musl-gcc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/repo/target/aarch64-unknown-linux-musl/release/build/ring-4efa80a8699004e7/out/aesv8-armx-linux64.o" "/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"]: No such file or directory (os error 2)', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/std/src/panicking.rs:584:5
     1: core::panicking::panic_fmt
               at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library/core/src/panicking.rs:142:14
     2: build_script_build::run_command::{{closure}}
     3: core::result::Result<T,E>::unwrap_or_else
     4: build_script_build::run_command
     5: build_script_build::compile
     6: build_script_build::build_library::{{closure}}
     7: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
     8: core::option::Option<T>::map
     9: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
    10: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
    11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
    12: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
    13: core::iter::traits::iterator::Iterator::collect
    14: build_script_build::build_library
    15: build_script_build::build_c_code::{{closure}}
    16: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
    17: build_script_build::build_c_code
    18: build_script_build::ring_build_rs_main
    19: build_script_build::main
    20: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The command '/bin/sh -c cargo build --release --target $CARGO_BUILD_TARGET --workspace' returned a non-zero code: 101

I'll try switching to LLVM for now

jokeyrhyme avatar Jul 03 '22 07:07 jokeyrhyme

I did the same env setup. I am getting the following error.

#12 373.4 error: failed to run custom build command for `ring v0.16.15`
#12 373.4 
#12 373.4 Caused by:
#12 373.4   process didn't exit successfully: `/jenkins/strck-cloud/target/release/build/ring-bbfe3777739977f5/build-script-build` (exit status: 101)
#12 373.4   --- stdout
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4   OPT_LEVEL = Some("3")
#12 373.4   TARGET = Some("aarch64-unknown-linux-musl")
#12 373.4   HOST = Some("x86_64-unknown-linux-gnu")
#12 373.4   CC_aarch64-unknown-linux-musl = None
#12 373.4   CC_aarch64_unknown_linux_musl = Some("clang")
#12 373.4   CFLAGS_aarch64-unknown-linux-musl = None
#12 373.4   CFLAGS_aarch64_unknown_linux_musl = None
#12 373.4   TARGET_CFLAGS = None
#12 373.4   CFLAGS = None
#12 373.4   CRATE_CC_NO_DEFAULTS = None
#12 373.4   DEBUG = Some("false")
#12 373.4 
#12 373.4   --- stderr
#12 373.4   ENV TARGET=aarch64-unknown-linux-musl
#12 373.4   ENV SSL_CERT_FILE=/usr/lib/ssl/certs/ca-certificates.crt
#12 373.4   ENV SSL_CERT_DIR=/usr/lib/ssl/certs
#12 373.4   ENV RUST_RECURSION_COUNT=1
#12 373.4   ENV RUSTUP_TOOLCHAIN=stable-x86_64-unknown-linux-gnu
#12 373.4   ENV RUSTUP_HOME=/root/.rustup
#12 373.4   ENV RUSTDOC=rustdoc
#12 373.4   ENV RUSTC=rustc
#12 373.4   ENV PWD=/jenkins/strck-cloud
#12 373.4   ENV PROFILE=release
#12 373.4   ENV PATH=/root/.cargo/bin:/jenkins/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#12 373.4   ENV OUT_DIR=/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out
#12 373.4   ENV OPT_LEVEL=3
#12 373.4   ENV NUM_JOBS=8
#12 373.4   ENV LD_LIBRARY_PATH=/jenkins/strck-cloud/target/release/deps:/jenkins/strck-cloud/target/release:/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib:/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib
#12 373.4   ENV HOST=x86_64-unknown-linux-gnu
#12 373.4   ENV HOME=/root
#12 373.4   ENV DEBUG=false
#12 373.4   ENV CC_aarch64_unknown_linux_musl=clang
#12 373.4   ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-Clink-self-contained=yes -Clinker=rust-lld
#12 373.4   ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64 -L /usr/aarch64-linux-gnu
#12 373.4   ENV CARGO_PKG_VERSION_PRE=
#12 373.4   ENV CARGO_PKG_VERSION_PATCH=15
#12 373.4   ENV CARGO_PKG_VERSION_MINOR=16
#12 373.4   ENV CARGO_PKG_VERSION_MAJOR=0
#12 373.4   ENV CARGO_PKG_VERSION=0.16.15
#12 373.4   ENV CARGO_PKG_RUST_VERSION=
#12 373.4   ENV CARGO_PKG_REPOSITORY=https://github.com/briansmith/ring
#12 373.4   ENV CARGO_PKG_NAME=ring
#12 373.4   ENV CARGO_PKG_LICENSE_FILE=LICENSE
#12 373.4   ENV CARGO_PKG_LICENSE=
#12 373.4   ENV CARGO_PKG_HOMEPAGE=
#12 373.4   ENV CARGO_PKG_DESCRIPTION=Safe, fast, small crypto using Rust.
#12 373.4   ENV CARGO_PKG_AUTHORS=Brian Smith <[email protected]>
#12 373.4   ENV CARGO_MANIFEST_LINKS=ring-asm
#12 373.4   ENV CARGO_MANIFEST_DIR=/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15
#12 373.4   ENV CARGO_MAKEFLAGS=-j --jobserver-fds=9,14 --jobserver-auth=9,14
#12 373.4   ENV CARGO_HOME=/root/.cargo
#12 373.4   ENV CARGO_FEATURE_ONCE_CELL=1
#12 373.4   ENV CARGO_FEATURE_DEV_URANDOM_FALLBACK=1
#12 373.4   ENV CARGO_FEATURE_DEFAULT=1
#12 373.4   ENV CARGO_FEATURE_ALLOC=1
#12 373.4   ENV CARGO_ENCODED_RUSTFLAGS=-Clink-self-contained=yes-Clinker=rust-lld
#12 373.4   ENV CARGO_CFG_UNIX=
#12 373.4   ENV CARGO_CFG_TARGET_VENDOR=unknown
#12 373.4   ENV CARGO_CFG_TARGET_POINTER_WIDTH=64
#12 373.4   ENV CARGO_CFG_TARGET_OS=linux
#12 373.4   ENV CARGO_CFG_TARGET_HAS_ATOMIC=128,16,32,64,8,ptr
#12 373.4   ENV CARGO_CFG_TARGET_FEATURE=neon
#12 373.4   ENV CARGO_CFG_TARGET_FAMILY=unix
#12 373.4   ENV CARGO_CFG_TARGET_ENV=musl
#12 373.4   ENV CARGO_CFG_TARGET_ENDIAN=little
#12 373.4   ENV CARGO_CFG_TARGET_ARCH=aarch64
#12 373.4   ENV CARGO_CFG_PANIC=unwind
#12 373.4   ENV CARGO=/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
#12 373.4   ENV AR_aarch64_unknown_linux_musl=llvm-ar
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/aesv8-armx-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/aesv8-armx-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/ghashv8-armx-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/ghashv8-armx-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/vpaes-armv8-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/vpaes-armv8-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/armv8-mont-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/armv8-mont-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/chacha-armv8-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/chacha-armv8-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/ecp_nistz256-armv8-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/ecp_nistz256-armv8-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/ghash-neon-armv8-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/ghash-neon-armv8-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/poly1305-armv8-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/poly1305-armv8-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/sha512-armv8-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/sha512-armv8-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/sha256-armv8-linux64.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/sha256-armv8-linux64.S"
#12 373.4   running "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-musl" "-I" "include" "-Wall" "-Wextra" "-std=c1x" "-Wbad-function-cast" "-Wnested-externs" "-Wstrict-prototypes" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/jenkins/strck-cloud/target/aarch64-unknown-linux-musl/release/build/ring-6dbfdc74a1174779/out/aes_nohw.o" "crypto/fipsmodule/aes/aes_nohw.c"
#12 373.4   In file included from crypto/fipsmodule/aes/aes_nohw.c:15:
#12 373.4   In file included from include/GFp/aes.h:52:
#12 373.4   include/GFp/base.h:117:1: error: static_assert failed due to requirement 'sizeof(unsigned long) == sizeof(unsigned int)' "uintptr_t and size_t differ."
#12 373.4   OPENSSL_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t), "uintptr_t and size_t differ.");
#12 373.4   ^                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#12 373.4   include/GFp/type_check.h:71:42: note: expanded from macro 'OPENSSL_STATIC_ASSERT'
#12 373.4   #define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
#12 373.4                                            ^              ~~~~
#12 373.4   1 error generated.
#12 373.4   thread 'main' panicked at 'execution failed', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:664:9
#12 373.4   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#12 373.4 warning: build failed, waiting for other jobs to finish...
------
executor failed running [/bin/sh -c cargo build --release --target aarch64-unknown-linux-musl]: exit code: 101

Using docker with --platform=x86_64 in an m1 mac. Anything that I am missing?

sakibstark11 avatar Nov 03 '22 17:11 sakibstark11

OPENSSL_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t), "uintptr_t and size_t differ.");

I'm guessing that something in your configuration is confusing clang about what headers to use.

In build.rs we have this:

    if (target.arch == "wasm32" && target.os == "unknown")
        || (target.os == "linux" && target.is_musl && target.arch != "x86_64")
    {
        if let Ok(compiler) = c.try_get_compiler() {
            // TODO: Expand this to non-clang compilers in 0.17.0 if practical.
            if compiler.is_like_clang() {
                let _ = c.flag("-nostdlibinc");
                let _ = c.define("RING_CORE_NOSTDLIBINC", "1");
            }
        }
    }

Try removing the && target.arch != "x86_64" and see if that helps you make progress.

briansmith avatar Nov 03 '22 18:11 briansmith

#0 76.99 error: failed to run custom build command for `ring v0.16.20`
#0 76.99 
#0 76.99 Caused by:
#0 76.99   process didn't exit successfully: `/app/target/debug/build/ring-ed6fad5ef3828358/build-script-build` (exit status: 101)
#0 76.99   --- stdout
#0 76.99   OPT_LEVEL = Some("0")
#0 76.99   TARGET = Some("aarch64-unknown-linux-musl")
#0 76.99   HOST = Some("x86_64-unknown-linux-musl")
#0 76.99   CC_aarch64-unknown-linux-musl = None
#0 76.99   CC_aarch64_unknown_linux_musl = None
#0 76.99   TARGET_CC = None
#0 76.99   CC = None
#0 76.99   CROSS_COMPILE = None
#0 76.99   CFLAGS_aarch64-unknown-linux-musl = None
#0 76.99   CFLAGS_aarch64_unknown_linux_musl = None
#0 76.99   TARGET_CFLAGS = None
#0 76.99   CFLAGS = None
#0 76.99   CRATE_CC_NO_DEFAULTS = None
#0 76.99   DEBUG = Some("false")
#0 76.99   CARGO_CFG_TARGET_FEATURE = Some("neon")
#0 76.99 
#0 76.99   --- stderr
#0 76.99   running "aarch64-linux-musl-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/app/target/aarch64-unknown-linux-musl/debug/build/ring-6d9336830535abc3/out/aesv8-armx-linux64.o" "/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"
#0 76.99   thread 'main' panicked at 'failed to execute ["aarch64-linux-musl-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/app/target/aarch64-unknown-linux-musl/debug/build/ring-6d9336830535abc3/out/aesv8-armx-linux64.o" "/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"]: No such file or directory (os error 2)', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9

6543 avatar Apr 14 '23 01:04 6543

Not sure if this could help anyone but if you are using ring with sqlite, I successfully managed to make it work by using this.

ENV CC_aarch64_unknown_linux_musl="clang"
ENV AR_aarch64_unknown_linux_musl="llvm-ar"
ENV CFLAGS_aarch64_unknown_linux_musl="-nostdinc -nostdlib -isystem/usr/include/x86_64-linux-musl/"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld -Clink-args=-L/usr/lib/x86_64-linux-musl/"

If we did not add this option, I found that clang used the header of gcc, more specifically headers inside /usr/include/x86_64-linux-gnu/ to compile even if the target is aarch64-unknown-linux-musl and leaded to something like fatal error: 'bits/libc-header-start.h' file not found while compiling with sqlite.

Maybe even if we don't use sqlite, IMHO this should be the default option because I had high CPU usage if I cross-compiled using

ENV CC_aarch64_unknown_linux_musl="clang"
ENV AR_aarch64_unknown_linux_musl="llvm-ar"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"

vnghia avatar Jun 18 '23 23:06 vnghia

I was able to solve all my compilation issues by using cross project:

  • cross build --release --target aarch64-unknown-linux-gnu ...
  • cross build --release --target aarch64-unknown-linux-musl ...

nyurik avatar Sep 29 '23 03:09 nyurik

Great! I am going to close this issue then.

briansmith avatar Sep 29 '23 17:09 briansmith