Cross-compiling from macOS to ARM

Trying to cross-compile from Mac to a raspberry pi zero W which runs ARMv6.

Edit: Now the compiling issue is with openssl. If anyone knows how to get compiling openssl working, that'd be awesome.

Original:
I've set up my .cargo/config as the following

[target.arm-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-ld"

but keep getting an error

--- stderr
  /bin/sh: arm-linux-musleabihf-gcc: command not found
  make[1]: *** [apps/app_rand.o] Error 127
  make[1]: *** Waiting for unfinished jobs....
  /bin/sh: arm-linux-musleabihf-gcc: command not found
  make[1]: *** [apps/apps.o] Error 127
  /bin/sh: arm-linux-musleabihf-gcc: command not found
  make[1]: *** [apps/bf_prefix.o] Error 127
  /bin/sh: arm-linux-musleabihf-gcc: command not found
  make[1]: *** [apps/opt.o] Error 127
  make: *** [build_libs] Error 2
  thread 'main' panicked at '

I've run brew install arm-linux-gnueabihf-binutils

Overall, I'm pretty confused and at a loss of what to do

1 Like

What type of mac? one of the new M1 macs?

It looks like you are building for a musl target, but you have a GNU toolchain installed. You should either switch to a GNU target, or install a musl toolchain like this one.

2 Likes

Intel 2016 MacBook Pro

So I installed the link musl toolchain via brew and updated my target in the .cargo/config to reflect the updated target

[target.arm-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-ld"

However I still get an error that the command can't be found
/bin/sh: arm-linux-musleabihf-gcc: command not found

Do I need to manually link it to where brew installed it?

Making progress. Now I'm getting an issue with compiling openssl. Here are some of the error messages:

/Users/X/target/arm-unknown-linux-musleabihf/debug/build/openssl-sys-0856812646163a02/out/openssl-build/build/src/ssl/d1_lib.c:439: undefined reference to `__gettimeofday_time64'
/usr/local/Cellar/musl-cross/0.9.9/libexec/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /Users/X/target/arm-unknown-linux-musleabihf/debug/build/openssl-sys-0856812646163a02/out/openssl-build/build/src/ssl/d1_lib.c:439: undefined reference to `__gettimeofday_time64'
collect2: error: ld returned 1 exit status

Not an ideal solution but I've decided to avoid using a dependency that relies on openssl since there have been numerous posts saying it's difficult to work with. I'm now able to compile everything.

If anyone knows how to get openssl compiling to work, that'd be awesome!

I got it working today with this one, In case anyone runs into this old thread.

Make sure to read the readme and set the env vars correctly. I compiled armv7-unknown-linux-musleabihf with the armv7-unknown-linux-gnueabihf CC

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.