LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   LFS with clang / LLVM (https://www.linuxquestions.org/questions/linux-from-scratch-13/lfs-with-clang-llvm-4175720639/)

jr_bob_dobbs 01-07-2023 09:14 PM

LFS with clang / LLVM
 
Years ago I read about someone building an LFS system using LLVM / clang instead of gcc. I assumed at the time that it was BS.

Recently I was trying out OpenBSD and typed "ls -l $(which cc)" and to my surprise, cc was a link to clang, not to gcc. Surprise! Maybe that compiler is now polished enough.

LLVM is mentioned in the BLFS book, but so far as I was able to find, only so much as to describe how to compile LLVM.

It would be interesting to build an LFS system without gcc at all, just to see if it is possible. Has anyone done this already?

Thank you.

anak_bawang 01-08-2023 11:18 PM

Hi,

Maybe it was my old post.

Just Sharing: LFS + BLFS compiled mostly with clang
https://www.linuxquestions.org/quest...ng-4175619942/

As title said, mostly using clang.
Can not compile kernel using clang. Still using gcc.

Maybe you can try compile BSD kernel using clang, but it will be BSD From Scratch.

Notes :
1. When I posted it, it was LFS 8.0 & 8.1
2. Never used this method for LFS 9 and 10
3. Many errors when trying this method for LFS 11, so I put it off for a while.

jr_bob_dobbs 01-09-2023 08:04 PM

Thank you for the reply. It is good to hear from someone who has tried this.

Quote:

Originally Posted by anak_bawang (Post 6403192)
Hi,

Maybe it was my old post.

It was actually a post on 4chan, which is part of the reason I suspected its veracity. ;) I am embarrassed that I did not see your post here. :(

EDIT: I am even more embarrassed, because I saw that I'd posted reply on your thread back in 2017 and then entirely forgot. I am an idiot.

An update: I found a page on compiling the Linux kernel with LLVM, on the actual kernel.org web site. Whoa. Here is the ink. It seems a bit terse, though?

Maybe it *is* possible now?

anak_bawang 01-09-2023 09:02 PM

Quote:

Originally Posted by jr_bob_dobbs (Post 6403394)
An update: I found a page on compiling the Linux kernel with LLVM, on the actual kernel.org web site. Whoa. Here is the ink. It seems a bit terse, though?
Maybe it *is* possible now?

Thanks for the link.

I guess it will only work for latest kernel. Version 6 and later.

I've tried compile kernel version 5 with clang, but it did not work.

But I will try it later, because I'm very busy right now.

hazel 01-10-2023 06:21 AM

istr reading somewhere that Linus uses clang.

jr_bob_dobbs 04-24-2023 05:00 PM

So I ended up using regular GCC for my LFS 11.2 install. It had been long enough since 8.1 that I wanted to refresh my memory before going to new territory, compiler-wise.

When I progressed to BLFS 11.2, I discovered that several (many?) packages now can only be compiled with clang, indicating to me that it is most likely feature complete? Neat!

HolyFenrir 04-06-2024 04:00 AM

Linux Kernel
 
The Linux kernel can be built now with Clang. This should clear away any major hurdle to building a modern LFS system with it.

https://docs.kernel.org/kbuild/llvm.html


All times are GMT -5. The time now is 01:35 AM.