-
-
Notifications
You must be signed in to change notification settings - Fork 107
64 Bit Native Compiler: Installation Instructions
This project now provides exclusive 64-bit ARM64 (aka AArch64) Raspberry Pi GCC Toolchains. These ARM64 Toolchains can be used directly on any Raspberry Pi 64-Bit OS flavors with 64-bit kernel only (such as Raspberry Pi OS (64-bit)) for compiling programs for it.
Warning
The Stretch (Debian Version 9) 32-bit/64-bit toolchains are no longer supported!
- Buster: Used and generate code for Raspberry Pi Buster 64-bit OS (a.k.a Debian Version 10) and any equivalent OS only.
- Bullseye: Used and generate code for Raspberry Pi Bullseye 64-bit OS (a.k.a Debian Version 11) and any equivalent OS only.
- Bookworm: Used and generate code for Raspberry Pi Bookworm 64-bit OS (a.k.a Debian Version 12) and any equivalent OS only.
Note
Supported Pi Models: These toolchains can be used with any Raspberry Pi Models/Versions with ARMV8-A
CPU Architecture that supports 64-Bit execution state. You can find complete all supported Pi's list here.
Important
- These instructions are exclusively for GCC version
14.2.0
but will work with any native-compiler version available with this project. - These instructions are Linux-machines specific only.
-
Update your environment:
sudo apt update && sudo apt dist-upgrade
-
Install Important Packages(including default gcc):
sudo apt-get install build-essential gawk gcc g++ gfortran git texinfo bison libncurses-dev
Our pre-compiled TAR-PIGZ compressed and OS-targeted GCC Toolchain binaries can easily be downloaded from the project's SourceForge Repository or by clicking the links provided in the following table:
Note
- Host OS: on which the toolchain is executed/used.
- Target OS: for which the toolchain generates code.
Warning
The Stretch (Debian Version 9) 32-bit/64-bit toolchains are no longer supported!
Toolchains | Host OS | Target OS | Current Status | Precompiled GCC versions available |
---|---|---|---|---|
Raspberry Pi GCC 64-Bit Native-Compiler Toolchains (Buster) | Buster 64-bit OS (Debian Version 10) only | Buster 64-bit OS (Debian Version 10) only | Stable/Production | 13.3.0, 14.2.0 |
Raspberry Pi GCC 64-Bit Native-Compiler Toolchains (Bullseye) | Bullseye 64-bit OS (Debian Version 11) only | Bullseye 64-bit OS (Debian Version 11) only | Stable/Production | 13.3.0, 14.2.0 |
Raspberry Pi GCC 64-Bit Native-Compiler Toolchains (Bookworm) | Bookworm 64-bit OS (Debian Version 12) only | Bookworm 64-bit OS (Debian Version 12) only | Stable/Production | 13.3.0, 14.2.0 |
These Raspberry toolchains have the same standardized headers with no hardcoded paths, thereby can be directly used for immediate application OR can be installed permanently for on a daily basis usage:
-
Extraction: Extract using
tar
terminal command as follows:tar xf <filename e.g native-gcc-14.2.0-pi_64.tar.gz>
-
Linking:
-
Setup paths as follows:
PATH=/<extracted folder-name e.g native-pi-gcc-14.2.0-64>/bin:$PATH LD_LIBRARY_PATH=/<extracted folder-name e.g native-pi-gcc-14.2.0-64>/lib:$LD_LIBRARY_PATH
-
Setup Important Symlinks as follows: Our toolchains requires few additional symbolic links to work properly. Therefore, to create all required symbolic link reliably, we need to download
SSymlinker
bash script as follows:wget https://raw.githubusercontent.com/abhiTronix/raspberry-pi-cross-compilers/master/utils/SSymlinker
Once it is downloaded, you just need to make it executable, and then run it for each path manually using the following commands:
sudo chmod +x SSymlinker ./SSymlinker -s /usr/include/aarch64-linux-gnu/asm -d /usr/include ./SSymlinker -s /usr/include/aarch64-linux-gnu/gnu -d /usr/include ./SSymlinker -s /usr/include/aarch64-linux-gnu/bits -d /usr/include ./SSymlinker -s /usr/include/aarch64-linux-gnu/sys -d /usr/include ./SSymlinker -s /usr/include/aarch64-linux-gnu/openssl -d /usr/include ./SSymlinker -s /usr/lib/aarch64-linux-gnu/crtn.o -d /usr/lib/crtn.o ./SSymlinker -s /usr/lib/aarch64-linux-gnu/crt1.o -d /usr/lib/crt1.o ./SSymlinker -s /usr/lib/aarch64-linux-gnu/crti.o -d /usr/lib/crti.o
-
-
Extraction: Extract using
tar
terminal command as follows:tar xf <filename e.g native-gcc-14.2.0-pi_64.tar.gz>
-
Configuring: Move extracted folder to any location (for e.g.
/opt
) by using following command:sudo mv <extracted folder-name e.g native-pi-gcc-14.2.0-64> /opt
-
Linking: Properly link Path/Environment Variables permanently with either of the following given methods:
-
Appending variables to your
.profile
: (Recommended)echo 'export PATH=/opt/<extracted folder-name e.g native-pi-gcc-14.2.0-64>/bin:$PATH' >> .profile echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g native-pi-gcc-14.2.0-64>/lib:$LD_LIBRARY_PATH' >> .profile source .profile
-
Appending variables to your
.bashrc
:⚠️ Some Linux users reported some trouble with configuring path variables at.profile
that doesn't seem to work for them. If you encounter a similar problem, try setting/configure by adding paths to your.bashrc
file instead of as follows:echo 'export PATH=/opt/<extracted folder-name e.g native-pi-gcc-14.2.0-64>/bin:$PATH' >> .bashrc echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g native-pi-gcc-14.2.0-64>/lib:$LD_LIBRARY_PATH' >> .bashrc source .bashrc
-
-
Setup Important Symlinks as follows:
sudo ln -sf /usr/include/aarch64-linux-gnu/asm/* /usr/include/asm sudo ln -sf /usr/include/aarch64-linux-gnu/gnu/* /usr/include/gnu sudo ln -sf /usr/include/aarch64-linux-gnu/bits/* /usr/include/bits sudo ln -sf /usr/include/aarch64-linux-gnu/sys/* /usr/include/sys sudo ln -sf /usr/include/aarch64-linux-gnu/openssl/* /usr/include/openssl sudo ln -sf /usr/lib/aarch64-linux-gnu/crtn.o /usr/lib/crtn.o sudo ln -sf /usr/lib/aarch64-linux-gnu/crt1.o /usr/lib/crt1.o sudo ln -sf /usr/lib/aarch64-linux-gnu/crti.o /usr/lib/crti.o
-
Extra Step to use these binaries(temporarily) as your default native GCC Compiler(instead of default GCC
12.2.0
) at the time of compilation: (For more info. refer #16, thanks @krcroft)export AR="gcc-ar-14.2.0" export CC="gcc-14.2.0" export CXX="g++-14.2.0" export CPP="cpp-14.2.0" export FC="gfortran-14.2.0" export RANLIB="gcc-ranlib-14.2.0" export LD="$CXX"
-
Further, To enable Link-time-optimization (LTO):
GCCPATH="/<extracted folder-name e.g native-pi-gcc-14.2.0-1>/libexec/gcc/aarch64-linux-gnu/14.2.0" export ARFLAGS="--plugin $GCCPATH/liblto_plugin.so" export RANLIBFLAGS="--plugin $GCCPATH/liblto_plugin.so"
Note
LTO also needs g++ to be the linker, and it can be enabled at compile-time by setting -flto=$(nproc)
and -fno-fat-lto-objects
flags in CFLAGS, CXXFLAGS, and LDFLAGS respectively.
If these binaries helped you big time, please consider supporting it. Thank you.
Also, don't forget to share your views & drop a ⭐
- Native-Compiler ARM Toolchains Guide
- Cross-Compiler ARM Toolchains Guide
- Native-Compiler 64-Bit GCC ARM64 Toolchains Guide
- Cross-Compiler 64-Bit GCC ARM64 Toolchains Guide