Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
gcc vs clang: why do you stay or switch?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3949

PostPosted: Sun Dec 01, 2024 10:34 am    Post subject: gcc vs clang: why do you stay or switch? Reply with quote

More and more topics have clang as an origin of issue.
Likely only because more and more users are switching. no judging on clang here.

I've just noticed stage3 has a LLVM version.

LTO kernel requires clang as gcc in this respect is simply not there.

IIUC clang is expected to compile faster in many cases which would be a time-saver when testing source packages or ebuilds.

As far as performance is concerned I know there are packages which do perform much faster when build with clang.
Defining such a list isn't a easy task. :)

There can be other reasons, unlisted there. :roll:

Anyone having switched at package level or globally to share reasons of choice, whatever their stage3 was?

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "


Last edited by CaptainBlood on Mon Dec 02, 2024 10:42 pm; edited 4 times in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3757
Location: Rasi, Finland

PostPosted: Sun Dec 01, 2024 11:19 am    Post subject: Reply with quote

I've used musl+llvm toolchain on amd64. And I'm about to set up one once again. Last time I ran it, it needed some extra work with some of the packages. And I needed to mask gcc.
I do run (not updated recently) glibc+llvm on my MacBook Air M2 which is arm64 obviously. I have hopes llvm could give better optimizations on Apple ARM since Apple itself uses llvm quite a lot. There hasn't been problems, but I don't use it very much because of the lack of memory (only 8G with no possibility to upgrade).
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2183

PostPosted: Sun Dec 01, 2024 12:21 pm    Post subject: Reply with quote

I switched to Clang 'cos it uses less space to compile qtwebengine, and hence can compile it faster. Having done that for qtwebengine, I thought I'd try it on more and more stuff until now it's my default*. My reason for that is Clang & LLVM are much newer than gcc, and (as Captain Blood mentioned, works better with LTO), and I assume large software suffers with age.
Also, AFAIK the only way to compile a kernel with LTO is with Clang.

* I say "default", as I have a package.env file for those where Clang breaks, but I know that the Gentoo devs also override the use of Clang for packages they know are broken, so I probably use Clang rather less often than I think!
_________________
Greybeard
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3949

PostPosted: Sun Dec 01, 2024 1:13 pm    Post subject: Reply with quote

Goverp wrote:
(as Captain Blood mentioned, works better with LTO)
Didn't said that, only mentioned clang dedicated kernel LTO feature.
Not saying that ain't true, I have no experience to share...

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
Spanik
Veteran
Veteran


Joined: 12 Dec 2003
Posts: 1006
Location: Belgium

PostPosted: Mon Dec 02, 2024 9:09 am    Post subject: Reply with quote

I have a couple of packages that I use clang because when compiling them with gcc I hit a hardware issue with the cpu (AMD Epyc). So more a workaround then anything else.
_________________
Expert in non-working solutions
Back to top
View user's profile Send private message
mirekm
Apprentice
Apprentice


Joined: 12 Feb 2004
Posts: 217
Location: Gliwice

PostPosted: Mon Dec 02, 2024 9:12 am    Post subject: Reply with quote

I stay on gcc. The main reason is security. For gcc there is hardened version.
The other thing is that clang allow bad quality code to work, and you will never know where is a hole allowing attack to your computer.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22764

PostPosted: Mon Dec 02, 2024 1:31 pm    Post subject: Reply with quote

Both gcc and clang allow bad quality code to compile, as long as the code is standards-compliant. It is fairly straightforward to write a program that both compilers will accept, but that has serious security problems when exposed to untrusted input. Therefore, I think it is not fair to blame clang for allowing bad quality code to work.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3949

PostPosted: Mon Dec 02, 2024 10:32 pm    Post subject: Reply with quote

mirekm wrote:
I stay on gcc. The main reason is security. For gcc there is hardened version.

So IIUC ebuild hardened kernel is currently gcc only, right?

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum