Clang flags by Clear Linux

Hello, I want to squeeze out the maximum performance on my laptop with a Ryzen 5600H processor on Gentoo. I am impressed by Clear Linux, but philosophically, I am closer to Gentoo. I would like to transfer all the clang flags from Clear Linux. By default, I use clang, not gcc. Could you help me find all the flags that should be specified to achieve my goal in make.conf?

This is a good start :

   CFLAGS="-O3"
   CXXFLAGS="-O3"
   CFLAGS="-march=native"
   CXXFLAGS="-march=native"
   LDFLAGS="-flto"
   CFLAGS="${CFLAGS} -floop-interchange -floop-unroll-and-jam"
   CXXFLAGS="${CXXFLAGS} -floop-interchange -floop-unroll-and-jam"
   CFLAGS="${CFLAGS} -ffast-math"
   CXXFLAGS="${CXXFLAGS} -ffast-math"
   LDFLAGS="-fuse-ld=lld"
   CFLAGS="${CFLAGS} -mllvm -inline-threshold=1000"
   CXXFLAGS="${CXXFLAGS} -mllvm -inline-threshold=1000"

Hello, thanks for the assistance. Currently, I’ve found an old configuration file: “COMMON_FLAGS=”-march=native -mtune=native -O3 -pipe -flto -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector -Wformat и -Wformat-security -fasynchronous-unwind-tables -ftree-loop-distribute-patterns -fno-semantic-interposition >
CFLAGS=“${COMMON_FLAGS}”
CXXFLAGS=“${COMMON_FLAGS}”
FCFLAGS=“${COMMON_FLAGS}”
FFLAGS=“${COMMON_FLAGS}”
LDFLAGS=“-Wl,-O1,-fuse-ld=mold,–sort-common,–as-needed,-z,relro,-z,now”
RUSTFLAGS=“-C opt-level=3 -C target-cpu=native -C link-arg=-fuse-ld=mold”" Would it be a good idea to combine the flags you suggested with this one?

That would become :

COMMON_FLAGS="-march=native -mtune=native -O3 -pipe -flto -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector -Wformat -Wformat-security -fasynchronous-unwind-tables -ftree-loop-distribute-patterns -fno-semantic-interposition"
CFLAGS="${COMMON_FLAGS} -floop-interchange -floop-unroll-and-jam -ffast-math -mllvm -inline-threshold=1000"
CXXFLAGS="${COMMON_FLAGS} -floop-interchange -floop-unroll-and-jam -ffast-math -mllvm -inline-threshold=1000"
LDFLAGS="-Wl,-O1,-fuse-ld=mold,--sort-common,--as-needed,-z,relro,-z,now"

RUSTFLAGS="-C opt-level=3 -C target-cpu=native -C link-arg=-fuse-ld=mold"

And now for the mega question - Is it worth using clang by default in the system? :sweat_smile:

Benchmark and find out :wink:

I’ll trust you and ask if you should use clang by default to build the entire environment?)

Clear Linux has many optimized packages which can take advantage of it.

It should run really fast.

You may encounter compatibility issues with some packages designed to be compiled with GCC, so test for your particular usecase.

my use case is using the browser and steam hehe

What do you think of these flags for clang?: CFLAGS=“-march=native -mtune=native -O3 -fexceptions -fopenmp -falign-functions=32 -fno-math-errno -fno-trapping-math -fcf-protection=none -mharden-sls=none -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection”
CXXFLAGS=“$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS”