- Toolchain
- Contents
- Part of distributions
- Ubuntu
- Debian
- Fedora
- Gentoo
- ARM crosscompiler
- ARM64 crosscompiler
- OpenRISC crosscompiler
- Standalone
- Linaro toolchain
- Download
- Usage
- no hardfloat?
- Code Sourcery
- Bootlin
- gcc-arm-linux-gnueabihf on Ubuntu 20.10 (Groovy Gorilla)
- 2. Uninstall / Remove gcc-arm-linux-gnueabihf package
- 3. Details of gcc-arm-linux-gnueabihf package
- 4. References on Ubuntu 20.10 (Groovy Gorilla)
- 5. The same packages on other Linux Distributions
- how Install GCC-5-arm-linux-gnueabihf on ubuntu 20.04
- 2 Answers 2
Toolchain
The toolchain is a set of binaries, system libraries and tools which allow you to build (in our case, cross-compile) u-boot and the kernel for a target platform. This will, to some limited extent, need to match the target rootfs. A large and incompatible change has taken place recently, through the Hard Float ABI. Now, two different debian and ubuntu ports are binary incompatible with each other.
Contents
- 1 Part of distributions
- 1.1 Ubuntu
- 1.2 Debian
- 1.3 Fedora
- 1.4 Gentoo
- 1.4.1 ARM crosscompiler
- 1.4.2 ARM64 crosscompiler
- 1.4.3 OpenRISC crosscompiler
- 2.1 Linaro toolchain
- 2.1.1 Download
- 2.1.2 Usage
- 2.1.3 no hardfloat?
Part of distributions
Ubuntu
A complete cross toolchain is available as a package, just run:
apt-get install gcc-arm-linux-gnueabihf
The gcc cross compiler from the standard package in Ubuntu 16 may have a bug that manifests itself as the following error while compiling U-Boot:
: Assembler messages: :323: Error: push/pop do not support ^ -- `pop ^' scripts/Makefile.build:280: recipe for target 'arch/arm/cpu/armv7/sunxi/psci.o' failed
Version of the compiler with the bug:
arm-linux-gnueabihf-gcc-5 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
A suggested solution is to use the Linaro toolchain
Debian
Details on cross-development Toolchains for Debian are at the Debian Wiki.
Installing Cross Compiler and build utilities:
dpkg --add-architecture armhf apt-get update apt-get install g++-arm-linux-gnueabihf
dpkg --add-architecture arm64 apt-get update apt-get install g++-aarch64-linux-gnu
You might want additional tools for building a sunxi system that are not related to the cross-compiler:
apt-get install build-essential git debootstrap u-boot-tools device-tree-compiler
Fedora
A complete cross toolchain is available as a package, just run:
yum install gcc-arm-linux-gnu
Gentoo
The crossdev tool [1] is the standard way of dealing with crosscompilers in Gentoo. Command line options are used to specify any arbitrary mix of different versions of the kernel headers, glibc, binutils and gcc. You can also use the -S option instead (to pick whatever is considered to be stable at the moment), but in this case the crosscompiler will be also upgraded as part of the regular distribution updates, which might be a bit annoying.
ARM crosscompiler
Even though Gentoo normally uses armv7a-hardfloat-linux-gnueabi as the toolchain triplet on ARM, we can also use Debian alike arm-linux-gnueabihf variant in order to be able to use the compilation instructions from the linux-sunxi wiki as-is (without substituting the toolchain name).
emerge crossdev crossdev --kernel =3.18 --libc =2.20-r2 --binutils =2.24-r3 --gcc =4.8.5 \ --genv 'USE="-fortran -mudflap -nls -openmp multilib" EXTRA_ECONF="--with-cpu=cortex-a8 --with-float=hard"' -t arm-linux-gnueabihf
ARM64 crosscompiler
emerge crossdev crossdev --kernel =3.18 --libc =2.21-r1 --binutils =9999 --gcc =4.9.3 \ --genv 'USE="-fortran -mudflap -nls -openmp multilib -sanitize" EXTRA_ECONF="--enable-fix-cortex-a53-843419"' -t aarch64-linux-gnu
Note: binutils =9999 (fetch sources from git) should be replaced with =2.26 as soon as binutils 2.26 is added to portage. Such new binutils version is necessary for having a Cortex-A53 erratum 843419 workaround.
OpenRISC crosscompiler
If you have one of the Allwinner SoC variants with an additional OpenRISC core (for example A31 and H3 have it), then you might want to also build an OpenRISC crosscompiler too:
emerge crossdev mkdir -p /etc/portage/patches/cross-or1k-elf/gcc-5.2.0 cd /etc/portage/patches/cross-or1k-elf/gcc-5.2.0 wget https://gist.githubusercontent.com/ssvb/28e22f4086af26ec9cd0/raw/8d3d091177156a92497f31de3bfb3d7da9e52649/0001-OpenRISC-support-for-GCC-5.2.0.patch crossdev --binutils =2.25.1-r1 --gcc =5.2.0 --libc =2.2.0.20150423 \ --genv 'USE="cxx multilib -fortran -mudflap -nls -openmp -sanitize"' \ -s4 -t or1k-elf
Please note that the upstream GCC does not support OpenRISC yet, so the OpenRISC code is still brewing in https://github.com/openrisc/or1k-gcc.git and we can solve this problem by just providing a patch for GCC in the /etc/portage/patches directory.
- ↑ The Gentoo website has undergone a major overhaul as of April 2015. While a backup of the old content is still available, it seems to have left the Gentoo Embedded Handbook in a non-functional state. You can still find a copy via archive.org. The wiki article on Raspberry Pi Cross building might also be helpful.
Standalone
These standalone toolchains are big tarballs which come with everything you need.
Linaro toolchain
Download
Linaro has been very good at changing the location and availability of just about everything, making it very hard to keep a wiki up to date which refers to it. So the below download locations might be stale already.
It lists the following toolchains:
When in doubt, try 4.9 first.
WARNING: Do not use the 4.8 gcc versions of the linaro toolchain to build legacy kernels (sunxi-3.4 etc.), those seem to have issues building the kernel. ( TODO: Verify that this is still true today ).
Usage
Take a gcc-linaro-.-..tar.xz file and untar it. You will find a bin directory in there. Temporarily add it to the environment you are building from:
export PATH="$PATH":/home/user/folder/gcc-linaro-arm-linux-gnueabihf-*_linux/bin/
no hardfloat?
Recent linaro toolchains are Hard Float (hf), this will be used throughout the wiki you see something like:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
Replace arm-linux-gnueabihf- with arm-linux-gnueabi- if your are not using a hardfloat toolchain.
Code Sourcery
Another option is to install the Sourcery toolchain from Code Sourcery (now in Mentor Graphics). Download Code Sourcery G++ 2010 9-50 https://sourcery.mentor.com/sgpp/lite/arm/portal/release1600 (official link, email registration required)
chmod +x arm-2010.09-50-arm-none-linux-gnueabi.bin ./arm-2010.09-50-arm-none-linux-gnueabi.bin
If you are using Ubuntu, you may need to switch to use bash shell (instead of dash shell)
sudo dpkg-reconfigure -plow dash ( then choose [No], this changes from using dash shell to using bash shell )
It will now install CodeSourcery with a GUI installer
Follow default settings and do Next , Next, Next, etc…
It should install in: ~/CodeSourcery/ ( for example: /home/penguin/CodeSourcery/ )
Make sure the CodeSourcery binaries are added to your path (if your username is penguin, then this should be correct):
echo "export PATH=~/CodeSourcery/Sourcery_G++_Lite/bin:\$" >> ~/.bashrc export PATH=~/CodeSourcery/Sourcery_G++_Lite/bin:$PATH (or you can just spawn a new terminal window to update the path) echo $PATH (make sure your path is updated)
Bootlin
Bootlin also provices glibc / musl / uclibc based toolchains for building:
gcc-arm-linux-gnueabihf on Ubuntu 20.10 (Groovy Gorilla)
Please follow the guidelines below to install gcc-arm-linux-gnueabihf package:
2. Uninstall / Remove gcc-arm-linux-gnueabihf package
This is a short guide on how to uninstall gcc-arm-linux-gnueabihf package:
3. Details of gcc-arm-linux-gnueabihf package
Package: gcc-arm-linux-gnueabihf
Architecture: amd64
Version: 4:10.2.0-1ubuntu1
Multi-Arch: foreign
Priority: optional
Section: devel
Source: gcc-defaults (1.189ubuntu1)
Origin: Ubuntu
Maintainer: Ubuntu Developers
Original-Maintainer: Debian GCC Maintainers
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 25
Depends: cpp-arm-linux-gnueabihf (= 4:10.2.0-1ubuntu1), gcc-10-arm-linux-gnueabihf (>= 10.2.0-8~)
Recommends: libc6-dev-armhf-cross | libc-dev-armhf-cross
Suggests: make, manpages-dev, autoconf, automake, libtool, flex, bison, gdb-arm-linux-gnueabihf, gcc-doc
Filename: pool/main/g/gcc-defaults/gcc-arm-linux-gnueabihf_10.2.0-1ubuntu1_amd64.deb
Size: 1424
MD5sum: c003c1158da5af20252bee3685c0c10d
SHA1: 96047c83d6b9086060284469a98499b0315a6a3e
SHA256: d40126ea677f4e27985132ee2da33adcc085dd9ebac357d1d8d31b6edf84d5fb
SHA512: 3ff9c127392d3a5558d00aef749feb7c4bdc9d7a7a2a62a26d634e4923aed28fe9bec79f31d886bfe6d2a880efacc2e15d1fc9514f715cc496db68bceca0db6f
Description-en: GNU C compiler for the armhf architecture
This is the GNU C compiler, a fairly portable optimizing compiler for C.
.
This is a dependency package providing the default GNU C cross-compiler
for the armhf architecture.
Description-md5: 341bee5927aa97cd38931c348b808c554. References on Ubuntu 20.10 (Groovy Gorilla)
gcc-9-s390x-linux-gnu-base (9.3.0-18ubuntu1cross2)
gcc-9-sh4-linux-gnu-base (9.3.0-18ubuntu1cross1)
gcc-9-sh4-linux-gnu (9.3.0-18ubuntu1cross1)
gcc-9-source (9.3.0-18ubuntu1)
gcc-9-sparc64-linux-gnu (9.3.0-18ubuntu1cross1)
gcc-9 (9.3.0-18ubuntu1)
gcc-aarch64-linux-gnu (4:10.2.0-1ubuntu1)
gcc-arm-linux-gnueabi (4:10.2.0-1ubuntu1)
gcc-arm-none-eabi-source (15:9-2019-q4-0ubuntu1)
gcc-arm-none-eabi (15:9-2019-q4-0ubuntu1)
gcc-avr (1:5.4.0+Atmel3.6.1-2build1)
gcc-bpf (10.2.0-13ubuntu1+4)
gcc-hppa-linux-gnu (4:10.2.0-1ubuntu1)
gcc-mingw-w64-i686 (9.3.0-7ubuntu1+22~exp1ubuntu4)
gcc-mingw-w64-x86-64 (9.3.0-7ubuntu1+22~exp1ubuntu4)
gcc-mingw-w64 (9.3.0-7ubuntu1+22~exp1ubuntu4)
5. The same packages on other Linux Distributions
gcc-arm-linux-gnueabihf (4:7.4.0-1ubuntu2.3) Ubuntu 18.04 LTS (Bionic Beaver)
gcc-arm-linux-gnueabihf (4:5.3.1-1ubuntu1) Ubuntu 16.04 LTS (Xenial Xerus)
gcc-arm-linux-gnueabihf (4:10.3.0-1ubuntu1) Ubuntu 21.04 (Hirsute Hippo)
gcc-arm-linux-gnueabihf (4:11.2.0-1ubuntu1) Ubuntu 21.10 (Impish Indri)
gcc-arm-linux-gnueabihf (4:11.2.0-1ubuntu1) Ubuntu 22.04 LTS (Jammy Jellyfish)
gcc-arm-linux-gnueabihf (4:8.3.0-1) Debian 10 (Buster)
how Install GCC-5-arm-linux-gnueabihf on ubuntu 20.04
I am doing cross compiling on ubuntu20.04. but a errro «/libm.so.6: version GLIBC_2.27′ not found» when run it on my arm platform. I install gcc-9-arm-linux-gnueabihf on ubuntu 20.04 and there is GLIBC_2.24′ on my arm platform. so, how can i install gcc-5-arm-linux-gnueabihf under ubuntu 20.04 witch source is on ubuntu 16.04. or, how can I install glbc 2.24 for gcc-9-arm-linux-gnueabihf on ubuntu 20.04. Thanks.
2 Answers 2
You have to download the needed package manually with
cd ~/Downloads wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-5-cross/gcc-5-arm-linux-gnueabihf_5.5.0-12ubuntu1cross1_amd64.deb sudo apt-get install ./gcc-5-arm-linux-gnueabihf_5.5.0-12ubuntu1cross1_amd64.deb wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-5-cross/gcc-5-multilib-arm-linux-gnueabihf_5.5.0-12ubuntu1cross1_amd64.deb sudo apt-get install ./gcc-5-multilib-arm-linux-gnueabihf_5.5.0-12ubuntu1cross1_amd64.deb wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-5-cross/gcc-5-arm-linux-gnueabihf-base_5.5.0-12ubuntu1cross1_amd64.deb sudo apt-get install ./gcc-5-arm-linux-gnueabihf-base_5.5.0-12ubuntu1cross1_amd64.deb
I added Ubuntu Bionic (18.04) to my apt sources:
# /etc/apt/sources.list deb http://ports.ubuntu.com/ubuntu-ports bionic universe
This old version of Ubuntu contains the GCC in version 4.9:
$ apt policy gcc-5-arm-linux-gnueabi gcc-5-arm-linux-gnueabi: Installed: 5.3.1-14ubuntu2cross1 Candidate: 5.5.0-12ubuntu1cross1 Version table: 5.5.0-12ubuntu1cross1 500 500 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 Packages *** 5.3.1-14ubuntu2cross1 500 500 http://ports.ubuntu.com/ubuntu-ports xenial/universe arm64 Packages 100 /var/lib/dpkg/status
I installed the 5.3.* version, because the default 5.5.* had some version conflicts:
sudo apt-get install gcc-5-arm-linux-gnueabi=5.3*
For even older gcc (4.9), I had to go all the way back to Xenial (14.04), and it also worked the same way.