LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 12-28-2019, 04:07 PM   #1
InitEnabler
LQ Newbie
 
Registered: Nov 2019
Location: Texas
Distribution: Ubuntu
Posts: 3

Rep: Reputation: Disabled
LFS for Alt Target Architectures


I'm wanting a second opinion on this before I start dedicating my time on this. Anyways, I'm wanting to go through the LFS book however instead of compiling for x86_64 / amd64 I would be compiling for aarch64 but using a x86_64 host. I would also like to do PowerPC, RISC-V, etc. but I want to prove out I can do it for aarch64. So I've figured out how to chroot once I get past ch. 5 (Basically using qemu-system / binfmt to chroot into a foreign filesystem.). So the only question I have, is it possible to build ch. 5 for aarch64? I would assume all I would have to do is set LFS_TGT to "aarch64-lfs-linux-gnu". (Plus some small deviations from the book.)

I know I will have to deviate a bit in chapter 5. due to when you compile gcc you will have to change some flags around to get gcc compiled for aarch64.

Note I've already ventured into cross compiling but it got to the point where it feels janky and there's a worry I might contaminate the sysroot / chroot with host libraries.
 
Old 12-29-2019, 04:28 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,415

Rep: Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338
Have you tried CLFS? It has the grunt work done. Personally, the idea sounds like a black hole for spare time to me, but a great learning exercise, I suppose.

BTW, the kernel supports a variety of weird & wonderful architectures. Some are cpu cores designed by FPGA manufacturers for Lock-in purposes. The idea was: You buy Xilinx FPGAs, and they'll allow you use their cpu core on them. Many were added in the 1990s; Things have moved on in the real world, and linux support for the rest of the system (Beyond kernel,glibc, gcc & binutils) may be very weak indeed.

To try those LFS versions, you'd have to design, build & program at least an FPGA from each manufacturer. Are you up to that? Can you pay someone to do it? That's not a cheap undertaking.

Last edited by business_kid; 12-29-2019 at 05:03 AM.
 
Old 12-29-2019, 07:47 AM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,659
Blog Entries: 19

Rep: Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480
Quote:
Originally Posted by InitEnabler View Post
So the only question I have, is it possible to build ch. 5 for aarch64? I would assume all I would have to do is set LFS_TGT to "aarch64-lfs-linux-gnu". (Plus some small deviations from the book.)
That wouldn't work, because you would need a a Chapter 5 toolkit that already ran on aarch. That means having a prior stage to create those tools from x86. That's how CLFS does it. You first create a set of very basic tools, not the complete Chapter 5 toolset but only the essentials. That means binutils, gcc, glibc and one or two packages that gcc uses internally like file and zlib. You compile them for your fictitious build-compatible host but with the real final architecture as target. That means they will run on your current x86 machine but compile for aarch. Then you use this toolset to build the real Chapter 5 toolset. Those will be aarch programs that won't run on your current machine. You will need to add whatever you need to boot on the new machine unless you're going to chroot from an existing Linux system there. Then you tar it up, untar it on the other machine and run Chapters 6-7.
 
Old 12-29-2019, 12:46 PM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,415

Rep: Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338
Being honest, I can see you doing arm, which I think LFS does or has done. For most of the others, development has stopped while the versions roll on in Arm & x86. You should test the water by seeing what basic programs you can get for the other systems. I believe there has been at least one request to delist the h8300 from the kernel on grounds like lack of supporting software, kernel won't compile, and the h8300 doesn't exist anyhow.
 
Old 12-30-2019, 11:56 AM   #5
arch-linq
Member
 
Registered: Sep 2018
Location: Midwest, USA
Distribution: Arch,LFS,BLFS
Posts: 110

Rep: Reputation: Disabled
I have been toying with this OP idea for the last few weeks. I recently bought a Rock64 (rk3328 aarch64) w/mali 450 gpu for $20. I have Arch arm on it and Manjaro arm. I have KDE Plasma running wayland-egl. Working doesnt mean it's right though. Needs to have it's own image not a generic one like all the linux distro's use on their arm offerings. That led me to go for my own hand built cross compiler using Arch as my base. Most of the distro's have a pkg set for aarch64 cross compiler on bare metal. And that's the catch. Bare metal.

Most arm dev work is done on qemu not bm. Once you have the cc in /opt or /usr you can begin doing cross-lfs and or embedded lfs but the books are quite old and not ready for arm64. Google is almost useless too. I composed an email and sent it to clfs-support mail if anybody wants to join in with me on this endeavor. Send a mail to show your support and interest for this to happen on cross-lfs. All for fun and maybe we can get an up to date cross-embedded book for arm64 out of the efforts.

PS Hazel is correct on the way it gets done in essence. Dont think biz-kid understands current bm cross compiling very well. Kernels 5.2.x currently support my rock64.

This comment below is not true at all.

Quote:
To try those LFS versions, you'd have to design, build & program at least an FPGA from each manufacturer. Are you up to that? Can you pay someone to do it? That's not a cheap undertaking.

Last edited by arch-linq; 12-30-2019 at 12:14 PM.
 
Old 12-31-2019, 03:20 AM   #6
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,659
Blog Entries: 19

Rep: Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480
Quote:
Originally Posted by arch-linq View Post
I have Arch arm on it and Manjaro arm. I have KDE Plasma running wayland-egl. Working doesnt mean it's right though. Needs to have it's own image not a generic one like all the linux distro's use on their arm offerings. That led me to go for my own hand built cross compiler using Arch as my base. Most of the distro's have a pkg set for aarch64 cross compiler on bare metal. And that's the catch. Bare metal.
Why do you need to cross-compile? Can't you just do a native compilation in aarch?
 
Old 12-31-2019, 03:45 AM   #7
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,415

Rep: Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338Reputation: 2338
[QUOTE-arch-linq]Dont think biz-kid understands current bm cross compiling very well. Kernels 5.2.x currently support my rock64. [/QUOTE]

It certainly looks that way, doesn't it? In fact, I completely misread the Original Post and answered the wrong question. My bad.
 
Old 12-31-2019, 06:44 AM   #8
arch-linq
Member
 
Registered: Sep 2018
Location: Midwest, USA
Distribution: Arch,LFS,BLFS
Posts: 110

Rep: Reputation: Disabled
WHy CC vs native? Speed mainly. Take llvm, the kernel or whole qt5-everywhere-5.14.0 for example. Would take days and days for just those 3 pkgs to build natively. My goal is to install arm the same way one installs LFS. Document it and share it.
 
1 members found this post helpful.
Old 01-02-2020, 07:24 AM   #9
InitEnabler
LQ Newbie
 
Registered: Nov 2019
Location: Texas
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by business_kid View Post
Have you tried CLFS? It has the grunt work done.
Yes I have, though its a bit out of date. I'm actually taking inspiration from Ataraxia Linux as a base (Using glibc instead of musl.)

Quote:
Originally Posted by hazel View Post
That wouldn't work, because you would need a a Chapter 5 toolkit that already ran on aarch. That means having a prior stage to create those tools from x86. That's how CLFS does it. You first create a set of very basic tools, not the complete Chapter 5 toolset but only the essentials. That means binutils, gcc, glibc and one or two packages that gcc uses internally like file and zlib. You compile them for your fictitious build-compatible host but with the real final architecture as target. That means they will run on your current x86 machine but compile for aarch. Then you use this toolset to build the real Chapter 5 toolset. Those will be aarch programs that won't run on your current machine. You will need to add whatever you need to boot on the new machine unless you're going to chroot from an existing Linux system there. Then you tar it up, untar it on the other machine and run Chapters 6-7.
Yup it seems that is correct. Thought it over a little more and it seems its not possible. I'll just wing it and go for cross compiling like CLFS.
 
Old 01-03-2020, 02:42 PM   #10
derguteweka
Member
 
Registered: Sep 2018
Distribution: BLFS
Posts: 74

Rep: Reputation: 21
Moin,

I did something like this some months ago. Yes, it worked somehow.
But it was really nasty. CLFS seems to be rather dead, and not support aarch64 - so i started somehow with CLFS and then slowly migrated back to the LFS-Book before chrooting, resulting in multiple builds of tools, lacking tools and lots of hassle. But in the end i got some rootfs, which seemed to behave nicely, when i chroot into it on a xilinx ultrascale+ platform.
For the building i used some x64 (older i3) system with a static qemu-aarch64 binary and the binfmt magic. But this is pretty slow - as expected. I was surprised, that "uname" worked OK in the qemu chroot. This is something, where i rembembered to have difficulties in the past (a couple of years ago, i already tried that for an arm926 and failed).

Gruss
WK
 
  


Reply



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] LFS 6.7 : $LFS/sources and $LFS/tools folders missing prakashsince92 Linux From Scratch 5 12-09-2010 02:26 PM
Switching window focus (like alt+tab in windows) and Ctrl+Alt+F1 X windows problem... DiZASTiX Linux - Software 3 01-20-2005 04:56 PM
alt tab with right alt teacup LinuxQuestions.org Member Success Stories 1 11-04-2004 12:18 AM
FreeBSD: Difference between Alt Gr and Alt Sharph *BSD 0 10-02-2004 03:45 AM
Alt-Tab and Alt-F4 in Fluxbox? tavilach Linux - Software 2 07-17-2004 04:03 PM

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

All times are GMT -5. The time now is 11:10 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
Open Source Consulting | Domain Registration