-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the state of CMLFS methods for cross-compiling? #91
Comments
I am successful on x86_64. I'm revising the LLVM 15.0.6 build/branch for the last time before upgrading to 16.0.6. I've attempted a 32bit build (i686) but hit a snag while compiling python3 for the final system: built python locks up the the system and will not finish the build...even if I left it over night. Cgnutools and llvmtools work as intended.... tricky as LLVM seems to use i386 built is for i686... kind of like Musl Libc. With the release of Raspberry Pi, I'm getting my pi4 ready to build a aarch64 build. |
What is your CPU? This sounds more like a CPU bug to me.
Well, have you already got anything from ARM/aarch64? Just out of curiosity. Another question: how is the performance of this? Is it really worse than GCC built Musl-LFS as some LLVM haters say? And how could I measure it by myself? |
Intel Core Duo T2600 in an old HP Compaq nc6400. I then tried resuming the build on an old mini-iTX board that has an Intel Atom N2800...but ran the chroot in 32-but mode. Same issue. Build hangs on |
That's really strange, maybe it's not your CPU fault. Maybe we should try contacting the Python development team? |
My amd64 build is 36 packages behind my i686 build... I will see if there was a mistake in the i686 build or if the same issue shows up in the amd64 build. I have found my RPi4 but not sure if it can still boot from the USB(3.0)-SATA 2.5" SSD it has. |
Finished python3 for the final system in my amd64 build: No issues. |
I wish I had a i{3,4,5,6}86 hanging around so I could test this out, but for now I'm only going with x86_64 for Copacabana. |
Per CLFS, you could build i686 on a x86_64 machine via 'setarch' or a kernel module:
or even "Uname Hack":
|
I built llvmtools for i686 on a amd64 machine then used |
I have completed an i686 build on an x86_64 host. Biggest issue was stage 2 python3 compiles but stalls with any python script like pip. Workaround for it was building stage 2 python with stage1 clang instead of stage 2. I am now doing another i686 build on another x86_64 to clean up the repo and verify it works. For "non-similar" cross builds, like arm64 on a x86_64 host most likely will need a different build method. I probably will create another repo like ... xCMLFS? |
Pardon for not giving any return yet, I have been a little bit busy on other projects beside Copacabana --- but on which it depends --- and I couldn't test any of the hypothesis that you made yet. |
No problem! My MLFS repo is getting stale as the last few months have I havetaken a break (built some plastic models, gunpla, in my free time instead of updating my repos) and started working on updating CMLFS. |
Why? How much would it differ from building from one platform to itself? |
Say, I want to build CMLFS for a Raspberry Pi 4 on my x86_64 host. I would have to build a cross-toolchain ( Then Therefore for "non-similar" cross-builds, I would have to deploy some sort of emulation, such as QEMU (run a virtual machine) or binfmt-support. There is Cross-LFS, but it relies on booting a minimal LFS system on hardware that supports the target CPU architecture:
|
Oh, I was aware of this, but can we cross-build it all instead of breaking it in two stages or the way a Linux system is built forbids us? Like was done on SunOS, for instance, where it was entirely cross-built from one platform for another if needed.
QEmu could be a good shot, but, correct me if I'm erred, maybe an ARM-specific emulator can perform better for cross-compiling an entire system than QEmu. I'll be studying some of this since I'm with some free time lately. |
That's a good point. I would think it might be possible to cross-compile each package... but I'm not sure if some packages require running a binary that runs on the target. Since I managed to build a "skeleton" PC (unfinished case, bare minimal parts) with 6 cores, I can try cross-compiling aarch64 on it. |
Sure thing that the biggest problem on making something such this is the fact that we don't have control of all the components on the system, in the sense of how it work. |
So I have begun cross-compiling aarch64 on x86_64. As expected, mussel script executed fine, bootstrapping the
Not sure if I need to patch LLVM source more. |
Did a quick Google search. Perhaps I need to build I first had to disable Then I appended the cmake invocation with:
But the build still fails:
I suppose aarch64 libraries are being loaded during the build? If so, then I would need to deploy some emulation for aarch64 on x86_64. |
That sounded like a undefined variable when auto-generating a file, strange. |
So we're now back to ground one? Hmmm... |
Yes, somewhat. I am now trying your suggestion of building a cross-compiler from LLVM instead of GCC (via mussel)... this means ditching mussel and using the host's GCC to build stage 0 LLVM with cross-compiling support. |
Correct me if I'm erred, but does not mussel support building a cross-compiler for another architectures? |
My fault, I left out a few details. I did initially start with mussel but stage0 clang kept using the runtimes that mussel built. But yes, mussel does support cross-compiling. Perhaps I am wasting time trying to build a cross-compiling stage 0 LLVM without mussel. I may need to use mussel to build a cross-gcc and disable it when running stage0 clang. |
When I tested this stage 0 clang, it would compile for the target (aarch64) but then link against runtime obejcts of the host:
Maybe I just need to reconfigure stage clang. |
Yup. Fixed it with a clang config:
test it via
|
Good question. I think I printed out some websites on cross-compiling back in 2017. It helped me under stand the difference between target, build, and host. I'll have to dig that out. I used to help me understand how to "cross-compile" from glibc to musl for my MLFS repo. I did recently looked at this question asked at Stack Overflow |
That means that a working cross-compiler was built or that a aarch64 binary could be cross-compiled? |
It seems so. I was able to cross-compile stage 0 clang with cross-GCC (built by mussel). Stage 0 clang can build aarch64 binaries like chimera's libatomic or even zlib-ng. BUT! Now build fails for stage 2 clang, using stage 0 clang. The tblgen binaries fail to build (unresolved symbols). |
How does Chimera, Alpine and other Linux distributions do automatic nightly (and even release) builds? I highly doubt that the team maintains a QEmu (even if headless and fine-tuned on scripts) "just" to cross-build. |
I got stage 1 LLVM to build further, but looks like stage 1 clang fails to build unlike stage 1 lld:
I checked that binary to see if needs the rpath set:
Make me wonder if build failed because just built |
I'm not sure. I haven't thoroughly looked through their repos to see how things are built. Chimera uses python scripting to automate the build process, I believe. |
I'm going to take a break from cross-compiling CMLFS. I probably will have to look into using binfmt & qemu... Maybe use mussel to build a cross-gcc toolchain to cross-compile enough packages to run an "emulated" chroot environment (use qemu to allow aarch64 binaries to run the host CPU while in chroot). |
I just remembered I tried using crosstool-ng and buildroot back in 2010 when trying to cross-compile LFS for my Acer A200 tablet (armv7).... Perhaps, I should look at those and see if I can use them to cross-compile CMLFS UPDATE: |
Well, I erred (at least for x86-64). I've done some research from the links at Projeto-Pindorama/copacabana#5 and concluded that, from Chimera to Kiss, all of them end up chrooting at some point for finish building packages, the only difference is that it's better integrated with the rest of the, lets say, build system. The only one who does it different is this tutorial at LinuxJournal.com, but it builds from GCC and the system is barely usable as it is and any new package that is minimally more complex would require chroot (making a safe bet here); and, of course, I said I would be studying mkroot and, after doing it, I realized it's pratically the same as the LinuxJournal.com article, with the difference that it uses Perhaps we can made a basic CMLFS rootfs instead of a intermediary throw-away stage and then configure the rest per chroot anyway. It would erase the need to redo some steps. It's a little bit late here, so pardon if this note is a little bit confuse or anything. Just wanted to make some updates. |
P.S.: For compiling to different architectures, there are plenty of articles of how to do that. https://www.plop.at/en/ploplinux/arm/crossbuildchroot.html (This one uses a set of custom utilities for compiling to ARM, but I think we can "reverse engineer" the code and/or try to understand how to replicate the process generically for other architectures) https://www.nccgroup.com/es/research-blog/cross-execute-your-linux-binaries-don-t-cross-compile-them/ (Another way to achieve what the first link proposes) In any case, most of these articles propose using QEmu, even if it is "under the hood", hidden by some program and/or boilerplate. |
Have any of you looked at T/2 SDE? It is a toolkit by Rene Rebe to build Linux-based (and possibly more) systems. He provides Musl, Glibc, LLVM/Clang and Gcc editions. Its basically a build-system for creating entire Linux distributions with a highly configurable set of options, and in an automated fashion. Here are some examples (of the capabilities of the build system (in the form of ISOs)), the most notable one being the desktop flavor built using Musl/CLang With T/2, its not really hard to build a usable Musl/Clang-based system. (I've built one before, using Busybox + Sway + Dbin as the package manager, and replacing utils with Toybox + cherry-picked Busybox utils) LINKS
EDIT: Added links |
Is it documented at a source code level? Since CMLFS/Musl-LFS have the purpose of teaching, I think it would be better to discover the method used by René for T/2 and then make something out of it. |
Very interesting anyway, I will take a look at it. |
I looked at the t2sde.org website. Really interesting. I went ahead and downloaded an ISO, burned it to a dvd and attempted to install it on an old "minipc" running an Intel B960... a rough adventure. I had a more pleasant experience with Arch Linux... Bootable DVD worked and booted into a basic system running in RAM. This system had a 5-10 second "input lag" which made navigating the TUI frustrating. Eventually I installed t/2 but the installer segfaulted when I attempted to reboot. After a few rounds of trial and error I booted t/2. Unfortunately, there is the same "input lag" from before. I know it's definitely not a hardware issue as I've built and booted a build of CMLFS on it without this annoying lag. But now I'm faced with an issue of how to connect to WiFi as my minipc has mini-PCIE WiFi adapter. Looks like t/2 uses old wpa-supplicant instead of iwd. Documentation online is --not that great either.-- Update 1: Figured out how to configure wpa_supplicat... but sudo and wget are not installed. Online documentation talks extensively about building T/2 from source but not on how to install desired packages for a freshly installed T/2. Do I have to build sudo and wget from source ?? Update 2: Perl and Xz-utils were not installed in T/2. I need both to compile the Linux Kernel. Interestingly enough, there were no linker issues during the build.... an issue that become prevalent in CMLFS.... perhaps libelf from elfutils should be built? |
I agree with @takusuman. CMLFS/MLFS was originally created to document my work and back it up on github. The way I organized my work follows somewhat along the same lines of LFS: Learn how to compile a Unix like system from scratch... not so much produce another 'Linux distro'. Eventually, other people were interested in my work, so the goal/rationale changed from a backup solution to a guide on how to build a unix-like system from scratch... using a different libc (i.e. musl) or compiler collection (i.e. LLVM/clang) . If one is not really interested on the how of buildling a Musl/Clang-based system, then go ahead and use T/2. Just like if one wants a Musl+Clang based system, just install Chimera Linux. BUT! T/2 seems to be another good resource, like Chimera Linux, Alpine Linux, and Void Linux. |
When I installed T/2 I was greeted with a TUI where I had the ability to select everything from coreutils, to libc, desktop, etc. (I was cross-compiling from Alpine) |
Your work is educational and fun and I guess a little bit more flexible with some options (though limited for some others). Gentoo with Clang/Musl only profile is also a good option next to Chimera and T2. You can change libstdc++ to libc++ too along with llvm-unwinder. Now you don't even need a secondary compiler. It's very smooth and easy to set-up a system with it. It's crazy that you can build almost everything bleeding edge with optimizations. Back then Clang couldn't compile most of the stuff let alone combined with Musl. |
Back after some time of being sick.
Splendid.
How is the build made? I couldn't find, at first, any build scripts that were clear. The fact that T/2 use technologies that were obsolete at the time they were released --- svn, for instance --- also annoys me a bit.
So... We're going to make another standalone package? |
@xplshn Would you mind sending the page with the guide to it? I will try to debug this TUI and see how it cross-compiles, then come back here which the information I could collect. |
The profile? Well, besides it's being copyrighted by the GPL, I think we can study it and get something useful out for CMLFS. |
I will try installing T/2 again. Perhaps skipping the bootloader part of the install messed up my installation. The miniPC I used already has GRUB installed. I wasn't sure if T/2 install would override it. Unfortunately, I've gotten busy at work, training fellow coworkers so I no longer have time to work on my projects during the free time at had at work. So I'll be slow to commit changes. |
Sure, take your time. |
I seem to have misremembered, what I did was I downloaded the source code and followed the guide here: |
O.k., great! |
Well, no success on compiling T/2 for now... But I could get Copacabana automated to build itself from the |
O.k., I have some news. |
Recently or, to be more specific, yesterday, I decided to make a build of Copacabana with LLVM/clang, and I would like to know if this project already runs on ARM and i{4,5,6}86.
I'm inclined to cooperate if needed, like I did in 2021 at the original Musl-LFS.
The text was updated successfully, but these errors were encountered: