cross compiler for RPi

General discussion about anything related to Ultibo.
develone
Posts: 315
Joined: Wed Dec 28, 2016 7:40 pm
Location: El Paso Tx USA

cross compiler for RPi

Postby develone » Sat Jun 01, 2019 1:30 pm

Hello All,
For the past few days I have been trying to understand how to cross compile
for my RPi3B on a Ubuntu 16.04.
model name : AMD FX(tm)-4130 Quad-Core Processor
stepping : 2
microcode : 0x600063e
cpu MHz : 1400.000
cache size : 2048 KB

This article is very well written

https://solarianprogrammer.com/2018/05/06/building-gcc-cross-compiler-raspberry-pi/

So far I was able to cross compile a small C program (pi_jpeg.c & lifting.c)
that preforms the lifting step using the gcc-6.3.0 cross compiler on my Ubuntu 16.04.
My testing is found at
https://github.com/develone/cross-compiler

I have been trying to create a script to perform the 100 plus steps.
This has not been successful. My latest successful build is found
in the file build-from-patched.sh.

A note from article
As a side note, building GCC 9.1 with the above cross compiler took about 15 minutes on a Debian 9 x86-64 machine. Compare this with the 5 hours I needed to build GCC 8.1 directly on my Pi 3 in the past and you will see the advantage of having a cross compiler on your main machine. Someone told me that compiling GCC 7 on a Raspberry Pi Zero took about 5 days!


Now I am working on the next gen version gcc-9.1.0.
develone
Posts: 315
Joined: Wed Dec 28, 2016 7:40 pm
Location: El Paso Tx USA

Re: cross compiler for RPi

Postby develone » Sat Jun 01, 2019 2:47 pm

Hello all,
I was to get the gcc-9.1.0 cross compiler.
arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/cross-pi-gcc/libexec/gcc/arm-linux-gnueabihf/9.1.0/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../gcc-9.1.0/configure --prefix=/opt/cross-pi-gcc --target=arm-linux-gnueabihf --enable-languages=c,c++,fortran --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-multilib
Thread model: posix
gcc version 9.1.0 (GCC)


Next step to create a gcc-9.1.0 for the RPi using this compiler.
develone
Posts: 315
Joined: Wed Dec 28, 2016 7:40 pm
Location: El Paso Tx USA

Re: cross compiler for RPi

Postby develone » Mon Jun 03, 2019 4:25 pm

Hello All,
I tested installing cross compiled gcc-9.1.0 on a RPI3B.
The file gcc-9.1.0-armhf-raspbian.tar.tjz was cross compiled on
a Ubuntu 16.04 x86_64
-rw-r--r-- 1 pi pi 46903472 Jun 3 08:06 /home/pi/gcc-9.1.0-armhf-raspbian.tar.tjz
Transfer the gcc-9.1.0-armhf-raspbian.tar.tjz file to raspbian target.
The file gcc-9.1.0-armhf-raspbian.tar.tjz needs to be extracted in /opt.
sudo tar xhjf /home/pi/gcc-9.1.0-armhf-raspbian.tar.tjz
Created links in /usr/include & /usr/lib see
the https://github.com/develone/cross-compiler/blob/master/result-links.txt
Add the new compiler PATH & LD_LIBRARY_PATH to your .bashrc
Compile the examples of if_test.cpp & fs_test.cpp see
https://github.com/develone/cross-compiler/blob/master/results-example.txt
Let me know if you have any questions.

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 21 guests