0

I need to compile kernel 3.4 for armhf, and this requires gcc-4.9.
the cmd line is:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- tegra_defconfig (here i'm not sure that I need to set CROSS_COMPILE)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

The issue is that I can't get ubuntu to use gcc-4.9, which is not available, I had to add xenial to the 'sources.list' file and now I have it on my system but am unable to use it.
Adding CC=gcc-4.9 to the commands will then not use the arm-linux-gnueabihf prefix defined by CROSS_COMPILE.
update-alternatives does not recognise gcc-4.9 as a second c compiler. Does anyone see a way around this ?
Please don't just drop a comment like "install xenial".

Yvain
  • 29
  • 10
  • You can try these commands before running ```make```: ```update-alternatives --set gcc "/usr/bin/gcc-4.9"``` and ```update-alternatives --set g++ "/usr/bin/g++-4.9"```. Don't forget to reverse that to the current version when you're ready. – flappix May 08 '20 at 19:55
  • Thanks but you might have answered before I edited: the output is: `update-alternatives: error: no alternatives for gcc` – Yvain May 08 '20 at 20:16
  • @flappix my default compiler is gcc-9, I tried installing gcc-10 thinking that it might unlock the update-alternatives features to set it to 4.9 but even with gcc-10 installed I got the same error that I refer to in the previous comment. – Yvain May 08 '20 at 20:23

1 Answers1

0

From this thread: How to change the default GCC compiler in Ubuntu?

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
sudo update-alternatives --set gcc /usr/bin/gcc-4.9
gcc --version
gcc (Ubuntu 4.9.3-13ubuntu2) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

To stick to my case (cross compiling):

sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-4.9 50
sudo update-alternatives --set arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-4.9

for kernel 3.x.x and older perl is required, you can get past the errors with perlbrew use perl-5.10.0, after having done perlbrew init and perlbrew install perl-5.10.0 (read well the output of the last two commands).

NOTE that even when cross compiling you need to set the host's gcc to 4.9 because the configuration generator requires it.

Yvain
  • 29
  • 10