9

GitHub - tttapa/docker-arm-cross-toolchain

 2 years ago
source link: https://github.com/tttapa/docker-arm-cross-toolchain
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

docker-arm-cross-toolchain

Repository with ARM cross-compilation toolchains, built using Docker and crosstool-NG.

Includes C, C++ and Fortran cross-compilers (GCC 11.2), including the address and undefined behavior sanitizers (Asan and UBsan), cross-GDB and gdbserver (10.2). Compatible with glibc 2.28 and Linux 5.8 or later. These cross-compilers have been patched for Debian Multiarch.

Download

Docker images are available from GitHub Packages, and the ready-to-use toolchains can be downloaded from the Releases page.

Direct links:

For modern Raspberry Pi boards running 64-bit Raspberry Pi OS or 64-bit Ubuntu, use the aarch64-rpi3-linux-gnu toolchain.

For modern Raspberry Pi boards running 32-bit Raspberry Pi OS, use the armv8-rpi3-linux-gnueabihf toolchain.

For older Raspberry Pi boards, or if you need to support all boards, use the armv6-rpi-linux-gnueabihf toolchain.

There is no specific toolchain for the first version of the RPi 2B (which uses a quad-core ARMv7 Cortex-A7), but the armv6-rpi-linux-gnueabihf toolchain is compatible with this architecture as well.

For the RPi 4B/400 and the CM 4, use the aarch64-rpi3-linux-gnu or the armv8-rpi3-linux-gnueabihf toolchain, depending on whether you're using a 64-bit or a 32-bit operating system. For optimal performance, you can include the -mcpu=cortex-a72 or -mtune=cortex-a72 flags (GCC ARM options).

Installation

Download the archive of the toolchain you need using the links above. Then extract it to a convenient location, e.g. ~/opt.

You can download and extract the toolchain in one go using wget and tar, for example:

mkdir -p ~/opt
wget -qO- https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-aarch64-rpi3-linux-gnu.tar.bz2 | tar xJ -C ~/opt

If you want to use the toolchain directly, you can add the ~/opt/x-tools/aarch64-rpi3-linux-gnu/bin folder to your path:

export PATH="$HOME/opt/x-tools/aarch64-rpi3-linux-gnu/bin:$PATH"

To make it permanent, you can add it to your ~/.profile:

echo 'export PATH="$HOME/opt/x-tools/aarch64-rpi3-linux-gnu/bin:$PATH"' >> ~/.profile

Usage

For new software configured using CMake, use a CMake toolchain file. Examples can be found in https://github.com/tttapa/RPi-Cross-Cpp-Development/tree/master/cmake.

I highly recommend using CMake for your own projects as well, this makes it much easier for other people to depend on, package, and cross-compile your software.

For legacy software configured using Autotools, you usuall have to set a flag --host="aarch64-rpi3-linux-gnu" when invoking the configure script.
Packages with custom configuration scripts might have differently named options, for example, OpenSSL has --cross-compile-prefix="aarch64-rpi3-linux-gnu-".
Custom Makefiles might require you to set a variable such as CROSS=aarch64-rpi3-linux-gnu- or CROSS_COMPILE=aarch64-rpi3-linux-gnu-.
If all else fails, try setting the CC, CXX or FC environment variables explicitly.

For more detailed instructions on how to cross-compile software and how to handle dependencies, see https://tttapa.github.io/Pages/Raspberry-Pi/index.html.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK