Skip to content

fix: switch to cross for cross-compilation #5

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

Merged
merged 3 commits into from
Oct 20, 2021
Merged

Conversation

nmoutschen
Copy link
Contributor

@nmoutschen nmoutschen commented Oct 11, 2021

Issue #, if available: #2

Description of changes:

Switch to cross for cross-compiling to aarch64-unknown-linux-gnu.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nmoutschen
Copy link
Contributor Author

Hey @brainstorm ! Could you tell me if this PR solves the issue for you on an M1 mac?

I tried on an Intel Mac and Linux and it worked, but I don't have an M1 mac unfortunately.

@brainstorm
Copy link
Contributor

Hey @nmoutschen, thanks for iterating on this!

Unfortunately it does not work on my M1:

% make build
cross build --release --target aarch64-unknown-linux-gnu
   Compiling regex v1.5.4
   Compiling regex-automata v0.1.10
   Compiling http-body v0.4.3
   Compiling ring v0.16.20
   Compiling parking_lot_core v0.8.5
   Compiling signal-hook-registry v1.4.0
   Compiling mio v0.7.13
   Compiling num_cpus v1.13.0
error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `/Users/rvalls/dev/umccr/serverless-rust-demo/target/release/build/ring-5100f9369a354546/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("3")
  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("false")
  CARGO_CFG_TARGET_FEATURE = None

  --- stderr
  running "aarch64-linux-gnu-gcc" "-O3" "-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" "-DNDEBUG" "-c" "-o/Users/rvalls/dev/umccr/serverless-rust-demo/target/aarch64-unknown-linux-gnu/release/build/ring-5243877d4a8e9964/out/aesv8-armx-linux64.o" "/Users/rvalls/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"
  thread 'main' panicked at 'failed to execute ["aarch64-linux-gnu-gcc" "-O3" "-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" "-DNDEBUG" "-c" "-o/Users/rvalls/dev/umccr/serverless-rust-demo/target/aarch64-unknown-linux-gnu/release/build/ring-5243877d4a8e9964/out/aesv8-armx-linux64.o" "/Users/rvalls/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"]: No such file or directory (os error 2)', /Users/rvalls/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
make: *** [build] Error 101

@brainstorm
Copy link
Contributor

brainstorm commented Oct 11, 2021

So I guess at this point it's either podman:

https://news.ycombinator.com/item?id=28429650

Or the older Docker workaround you pointed at:

https://github.community/t/why-is-docker-not-installed-on-macos/17017/7

I'd prefer to have it solved natively though (cargo build), but I get it can be tricky to fix up properly... happy to test out things you throw my way in any case ;)

@ScriptSmith
Copy link

Using cross works for me on archlinux.

I needed to install aarch64-linux-gnu-gcc to compile for arm, but then my OS had a too-recent version of glibc for al2:

/var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bootstrap)
/var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by /var/task/bootstrap)
/var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /var/task/bootstrap)

Building with cross worked & passed all the tests

@nmoutschen
Copy link
Contributor Author

Thanks @ScriptSmith ! I'm going to merge this for now, but keep the issue on M1 macs open until I find a way to reproduce/explore this.

@nmoutschen nmoutschen merged commit 16bde82 into main Oct 20, 2021
@nmoutschen nmoutschen deleted the fix/macos-cross branch October 30, 2021 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants