Skip to content

Can't cross compile with ring dependency #705

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

Closed
ivnsch opened this issue May 4, 2022 · 6 comments
Closed

Can't cross compile with ring dependency #705

ivnsch opened this issue May 4, 2022 · 6 comments
Labels
A-aarch64-host Area: ARMv8 hosts bug

Comments

@ivnsch
Copy link

ivnsch commented May 4, 2022

rustup target add aarch64-unknown-linux-gnu
cross build -vv --target aarch64-unknown-linux-gnu

Can be reproduced too with x86_64-unknown-linux-gnu

My system:
rustup 1.24.3 (ce5817a94 2021-05-31)
cargo 1.62.0-nightly (f63f23ff1 2022-04-28) -- (also happens with stable)
cross 0.2.1
MacOS 12.1 Apple M1

error: failed to run custom build command for `ring v0.16.20`
Caused by:
  process didn't exit successfully: `/Users/---/dev/repo/github/capi/api/target/debug/build/ring-350ce28c869f8eeb/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("0")
  TARGET = Some("aarch64-unknown-linux-gnu")
  HOST = Some("aarch64-apple-darwin")
  CC_aarch64-unknown-linux-gnu = None
  CC_aarch64_unknown_linux_gnu = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_aarch64-unknown-linux-gnu = None
  CFLAGS_aarch64_unknown_linux_gnu = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("llvm14-builtins-abi,neon,pmuv3")

  --- stderr
  running "aarch64-linux-gnu-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-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" "-DNDEBUG" "-c" "-o/Users/---/dev/repo/github/capi/api/target/aarch64-unknown-linux-gnu/debug/build/ring-f9f9aec49163fbc2/out/aesv8-armx-linux64.o" "/Users/---/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"
  thread 'main' panicked at 'failed to execute ["aarch64-linux-gnu-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-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" "-DNDEBUG" "-c" "-o/Users/---/dev/repo/github/capi/api/target/aarch64-unknown-linux-gnu/debug/build/ring-f9f9aec49163fbc2/out/aesv8-armx-linux64.o" "/Users/---/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"]: No such file or directory (os error 2)', /Users/---/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9
@Emilgardis
Copy link
Member

what's your Cargo.toml like?

this seems like a ring issue, or a missing dependency, or just something that has been fixed in unreleased cross version.

try using cross from the main branch: cargo install cross --git https://github.com/cross-rs/cross

@Darkspirit
Copy link

TARGET_CC = None

TARGET_CC and TARGET_AR environment variables must be manually set.
https://github.com/briansmith/ring/blob/main/BUILDING.md#cross-compiling

@ivnsch
Copy link
Author

ivnsch commented May 24, 2022

Okay this seems fixed:

echo $TARGET_CC
/.../.cargo/bin/cross
echo $TARGET_AR
/.../.cargo/bin/cross

Now I ran into

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

(using a Mac M1)

After which the build process gets stuck always exactly at 24%. Let it there for several hours and it didn't move.

This seems the issue? #645

Any quick fix?

@Alexhuszagh Alexhuszagh added bug A-aarch64-host Area: ARMv8 hosts labels May 29, 2022
@Alexhuszagh
Copy link
Contributor

We're finally getting hardware to actually debug aarch64 host issues, there's a whole number of issues currently with the M1 processors (and also likely the new ARM64 Windows previews). Now that we've got maintainers with hardware to debug this, we should be able to eventually get fixes in.

@Alexhuszagh
Copy link
Contributor

Okay this seems fixed:

echo $TARGET_CC
/.../.cargo/bin/cross
echo $TARGET_AR
/.../.cargo/bin/cross

Now I ran into

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

(using a Mac M1)

After which the build process gets stuck always exactly at 24%. Let it there for several hours and it didn't move.

This seems the issue? #645

Any quick fix?

Those aren't the right values, also, that's weird they don't use CC_aarch64_unknown_linux_gnu and AR_aarch64_unknown_linux_gnu, because those are normally how you provide those values (this is where Cargo looks for them when cross-compiling).

These should be the correct values:

  • TARGET_CC=aarch64-linux-gnu-gcc
  • TARGET_AR=aarch64-linux-gnu-ar

This however has to be defined in the environment passthrough. See build.env for more info.

@ivnsch
Copy link
Author

ivnsch commented Aug 3, 2022

@Alexhuszagh thanks - my bad, I must have been tired. I corrected the variables and set them via build.env.

The build was still freezing, but the solution turned to be simple: I just had to assign more resources to Docker.

@ivnsch ivnsch closed this as completed Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-aarch64-host Area: ARMv8 hosts bug
Projects
None yet
Development

No branches or pull requests

4 participants