Hi there,

I am trying to setup RUST cross compilation and building on AMD64/FreeBSD 14.rc3 for aarch64/FreeBSD 14.rc3. I am very new to cross compilation so not sure what details are needed, please let me know if something is missing.

SO I have a project on Rust that I am trying to build for aarch64 architecture and I googled many things and got as far as being able to compile but not being able to link. SO I assume the linker is the problem.

The linker I downloaded is devel/freebsd-gcc12

I also downloaded sysroot from devel/freebsd-sysroot

I set up environment with sysroot as follows export PKG_CONFIG_SYSROOT_DIR=/usr/local/freebsd-sysroot/aarch64

Then I setup .cargo/config
Code:
[target.aarch64-unknown-freebsd]
linker="aarch64-unknown-freebsd14.0-gcc12"

Then I'm adding nightly toolchain rustup +nightly component add rust-src

And then I execute cargo +nightly build -Z build-std --target aarch64-unknown-freebsd

Where I am seeing that all dependencies compiled but then linker is throwing error
Code:
error: linking with `aarch64-unknown-freebsd14.0-gcc12` failed: exit status: 1
...

note: /usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib/Scrt1.o: Relocations in generic ELF (EM: 62)


          /usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib/Scrt1.o: Relocations in generic ELF (EM: 62)


          /usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib/Scrt1.o: Relocations in generic ELF (EM: 62)


          /usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib/Scrt1.o: Relocations in generic ELF (EM: 62)


          /usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib/Scrt1.o: Relocations in generic ELF (EM: 62)


          /usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib/Scrt1.o: Relocations in generic ELF (EM: 62)


          /usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib/Scrt1.o: error adding symbols: file in wrong format


          collect2: error: ld returned 1 exit status

And that is pretty much where I am at. Any help is greatly appreciated, thank you.
 
Last edited:
Back
Top