5/1/2023 0 Comments Install rust for macThat installs a set of tools named arm-linux-gnueabihf-addr2line, arm-linux-gnueabihf-ar and so on. So let’s install that with: brew install arm-linux-gnueabihf-binutils My first stop when looking to install open source tools on Mac OS is Homebrew, and indeed there’s a formula on there for arm-linux-gnueabihf-binutils – it looks like that could be what we need to get a linker targeting ARM Linux. So we need to install a C toolchain targeting ARM. Reading the guide seems to suggest that Rust doesn’t have its own linker for Linux targets – it uses the linker from a C toolchain, for example the GNU C compiler. So, it looks like we need a linker for ARM. Clang is the native C compiler for Mac OS, but I expect it can’t link an ARM executable in the way Rust wants. OK, so I guess this is clang giving that error. That failed with a message “error: linking with cc failed: exit code: 1” and then a note showing the entire cc command, and a note saying: = note: clang: warning: argument unused during compilation: '-pie' Ĭlang: error: linker command failed with exit code 1 (use -v to see invocation) OK, let’s try compiling a “hello world” Rust application with that target: cargo build -target=armv7-unknown-linux-gnueabihf I installed the armv7-unknown-linux-gnueabihf target with: rustup target add armv7-unknown-linux-gnueabihf I know the router runs Linux, so let’s try the first two. That leaves armv7-unknown-linux-gnueabihf, armv7-unknown-linux-musleabihf, armv7r-none-eabi and armv7r-none-eabihf. It’s probably not armv7-apple-ios or armv7-linux-androideabi, since this isn’t an iOS or Android OS. So I’d guess one of the armv7 targets is the best one. ![]() It’s a 32-bit architecture, so not AArch64.Looking at Wikipedia for the Cortex-A9 tells me: So, what kind of architecture is that? Googling for “BCM4709A0” brought me to Wikidevi, which says it’s an ARM Cortex-A9. So, let’s google to see what kind of CPU the router has.Īccording to the OpenWRT wiki it’s a Broadcom BCM4709A0. ![]() It looks like in the ARM space, there’s AArch64, arm-unknown, armebv7r, armv5te and armv7(r?) architectures of various variants. (many more x86, mips, powerpc and x86_64 targets) So I ran “rustup target list” to list all the installable targets: aarch64-apple-ios I already have rustup which I’ve used to install Rust for Mac OS and keep it up-to-date, so that’s handy. The guide suggests rustup can be used to install extra cross compilation targets. The top of that guide shows an example of installing the cross-compilation toolchain for ARM on Ubuntu, but it required some work to adapt to Mac OS High Sierra, my desktop environment. The router is a Netgear R7000 with an ARM processor, running FreshTomato, a distribution of Linux for ARM and MIPS architecture consumer routers. Wanting to compile a small program I’d written in Rust to run on my home router, I found this guide to cross compilation of Rust code. Published on Februin Rust Cross compiling Rust on Mac OS for an ARM Linux router
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |