LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 08-18-2017, 11:23 PM   #1
ordealbyfire83
Member
 
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 199

Rep: Reputation: 29
Trying my hand at building LFS on arm - cannot compile gcc


As the title suggests I am trying to build LFS-7.9 on an armv5 box. Please note I am NOT cross-compiling. I realize that the instructions of the book cannot be applied verbatim and some modification is necessary.

For GCC Pass 1 (still in the temporary toolchain) after a reasonably long time I am getting
Code:
*** Configuration armv5tel-lfs-linux-gnu not supported
Makefile:4056: recipe for target 'configure-gcc' failed
make[1]: *** [configure-gcc] Error 1
make[1]: Leaving directory '/tmp/lfs-extra/gcc-5.3.0/build'
Makefile:858: recipe for target 'all' failed
make: *** [all] Error 2
Before compiling I have replaced the line

Code:
for file in \
 $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
with

Code:
for file in gcc/config/arm/linux-eabi.h
but am not sure if that's right. Has anyone else any experience with this?

Output of version-check:

Code:
bash, version 4.3.30(1)-release
/bin/sh -> /bin/bash
Binutils: (GNU Binutils for Debian) 2.25
bison (GNU Bison) 3.0.2
/usr/bin/yacc -> /usr/bin/bison
bzip2,  Version 1.0.6, 6-Sept-2010.
Coreutils:  8.23
diff (GNU diffutils) 3.3
find (GNU findutils) 4.4.2
GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.2-p3, GNU MP 6.0.0)
/usr/bin/awk -> /usr/bin/gawk
gcc (Debian 4.9.2-10) 4.9.2
g++ (Debian 4.9.2-10) 4.9.2
(Debian GLIBC 2.19-18+deb8u6) 2.19
grep (GNU grep) 2.20
gzip 1.6
Linux version 3.16.0-4-kirkwood (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 Debian 3.16.36-1+deb8u2 (2016-10-19)
m4 (GNU M4) 1.4.17
GNU Make 4.0
GNU patch 2.7.5
Perl version='5.20.2';
sed (GNU sed) 4.2.2
tar (GNU tar) 1.27.1
makeinfo (GNU texinfo) 5.2
xz (XZ Utils) 5.1.0alpha
g++ compilation OK
 
Old 08-19-2017, 12:43 AM   #2
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 8.0 Custom, Merged Usr, Linux 4.9.35
Posts: 472

Rep: Reputation: 114Reputation: 114
I'm not 100% sure, but the temporary tools, especially the compiler (which is still actually a cross compiler), in chapter 5 may not support building on Arm. If you look closely at the configure options there are a lot of --disable-this and --disable-that. I don't know which features are required to build on Arm, but I don't think they test the basic LFS on anything but Intel x86/AMD64. Some of those disabled options may be required for the Arm capable backend to function.

Have a look at this project and examine their build scripts for changes from the book. http://intestinate.com/pilfs/

Also, look at the CLFS project and see what options they use on their cross compiler.
 
Old 08-20-2017, 10:07 PM   #3
ordealbyfire83
Member
 
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 199

Original Poster
Rep: Reputation: 29
Yeah, that's about what I thought. I had actually read through the "pilfs" pages and saw that their gcc options were identical to those in the LFS book (and that's how I found out about editing linux-eabi.h) - but they apply two patches, one for armv6 and the other for v7. But nothing for armv5 though.

As far as I can tell CLFS doesn't target arm. Then there's this but it is for embedded systems and doesn't look capable enough to serve as a foundation for actually building LFS, and they don't build g++ at all.

I know Debian targets armv5 but I haven't found any documentation for building gcc in these early stages.
 
Old 08-20-2017, 11:02 PM   #4
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 8.0 Custom, Merged Usr, Linux 4.9.35
Posts: 472

Rep: Reputation: 114Reputation: 114
Oh... that's way old. You're likely going to need to find something that runs on it already and dig through their source tree and figure out how they patched it. That, or start with the vendor's platform compiler and use that to build the initial GCC/G++. You might even try using GCC4, using an older LFS and just getting updated versions of it's packages.
 
Old 08-25-2017, 04:26 PM   #5
ordealbyfire83
Member
 
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 199

Original Poster
Rep: Reputation: 29
It turned out to be a problem with naming the triplet. Apparently this has changed in recent versions. According to this the first part should just be "arm" and the last part should, for v5, be armeabi.

The PILFS patches it turns out are just to get hardware float to work; for my particular machine this is not an option anyway. So otherwise this should work...

It took quite a while to try these different things because part of my build would "hang" on

Code:
build/genautomata ../../gcc/common.md ../../gcc/config/arm/arm.md \
insn-conditions.md > tmp-automata.c
for a ridiculously long time - upwards of 11 hours (I suspected infinite loop, but reading on about this I saw other people getting stuck for even longer amounts of time), even with more than comfortable swap space. So try this, try that, here goes a week waiting.

Setting the triplet this way gets past this problem but we get stuck farther on when gcc starts linking to gmp. Apparently gmp sets part of the triplet to "none" (see this and the latter portion of this which have been finalized (I refuse to say "resolved") as WONTFIX. Whether it's a "bug", an "issue" or something else, or whether it's with gcc, gmp, or some assembler really doesn't matter to me because the bottom line is gcc will not build natively on arm. And NONE of the proposed solutions worked - one that did only caused a whole host of assembling problems later on.

Maybe it works with the ridiculously new versions (gcc 7 already, really?), but those will probably break building anything other than development versions everything in the whole book.

So on to cross-compiling.
 
Old 08-26-2017, 12:55 AM   #6
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 8.0 Custom, Merged Usr, Linux 4.9.35
Posts: 472

Rep: Reputation: 114Reputation: 114
If I recall correctly, GMP uses a different config.guess than any other autotools package. config.guess is what typically determines the target triplet. If you're running into issues with it not being detected properly, copy the one out of the latest BinUtils. That said, there's little that can be done about GMP's custom triplet detection. Running it on my desktop produces an output of "haswell", so it's clear it doesn't follow the typical rules.
 
Old 09-01-2017, 10:54 PM   #7
ordealbyfire83
Member
 
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 199

Original Poster
Rep: Reputation: 29
Quote:
Originally Posted by Luridis View Post
If you're running into issues with it not being detected properly, copy the one out of the latest BinUtils.
That is a great suggestion - but this causes another issue

Code:
configure: error: error verifying int64_t uses long long
Ultimately I went with cross-compiling LFS - which is not straightforward for this platform - and got to the point that I can chroot into the temporary system from my armv5 box to build the real system. I just got gcc built, and as you mentioned before I can confirm that for attempting a native LFS build on arm, the initial cross-compile stage of GCC is not supported.

However, building gcc at any rate (either native LFS + initial cross-compile, or full-blown LFS cross-compile, i.e. in the sense of building LFS arm on an x86_64 system) on most armv5 machines is not possible at this time, particularly due to a HUGE memory footprint for the "genautomata" step for gcc >= 4.9. This is a known bug #60743 and while it has been fixed for armv7 there is no patch as of yet for armv5. It is said that adding a lot of extra swap space (I used a 4 gb flash drive) would mitigate these concerns but it unfortunately does not do so reliably. Of the six times I tried building on armv5 I only got through "genautomata" once; the other times failed with either some bash script failing or some things segfaulting. Apparently just adding ram/swap isn't enough.

In short I had to cheat to build gcc. I chrooted from my (more powerful) Beaglebone Black. This is of course armv7, so this means being extra cautious with the configure flags. While there wasn't much more ram, the faster processor got through the troublesome step more reliably.

Code:
../gcc-5.3.0/configure --prefix=/usr --enable-languages=c,c++ \
--disable-multilib --disable-bootstrap --with-system-zlib \
--with-arch=armv5te --with-float=soft --with-default-libstdcxx-abi=gcc4-compatible \
--build=armv5tel-unknown-linux-gnueabi --host=armv5tel-unknown-linux-gnueabi \
--target=armv5tel-unknown-linux-gnueabi
For building gcc on arm, you in addition to the configure flags in the book need to address the following for your particular hardware

- arm architecture (here armv5te)
- how is floating point handled (here 'soft'ware)
- fpu, i.e. if hardware or 'softp' float, then what kind (if 'soft' this option is ignored)

If it is not possible to build on armv5 and chroot from another chroot-able arm flavor then specify host, build, and target for your armv5 system.

Also this kind of cross-compiled build required ISL - no idea why, it wasn't asked for until way far into the build process.

I guess bootstrapping might be appropriate if it helps one to sleep better.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Building LFS/BLFS without GCC anak_bawang Linux From Scratch 4 04-18-2016 03:22 PM
Issues compiling GCC v4.7.1 while building LFS for ARM (Raspberry Pi) jvilla1983 Linux From Scratch 7 12-25-2012 02:03 PM
Building GCC for LFS dbbolton Linux - Software 9 11-27-2009 03:35 AM
using gcc built for arm for building a .c file raphtor Linux - Software 3 11-11-2009 05:51 PM
Compile the linux2.6.14.1 for arm must ues the arm-linux-gcc-3.4.4? frankyue Linux - Embedded & Single-board computer 2 12-20-2008 07:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 10:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration