Gentoolto: clang as system compiler

Created on 16 Sep 2018  ·  10Comments  ·  Source: InBetweenNames/gentooLTO

I will be building Gentoo from scratch soon, and I though about trying to use clang + LTO. Will you be interested in my results?

Most helpful comment

So, for now I have successfully build the basic system, with following settings:

make.conf:

CBUILD="x86_64-pc-linux-gnu"
CHOST="x86_64-pc-linux-gnu"
CC="clang"
CXX="clang++"
CFLAGS="-march=native -O3 -pipe -flto=thin"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O3 -Wl,--as-needed"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"
STRIP_MASK="*.a"

USE="-pch bindist clang mmx sse sse2 pgo"
VIDEO_CARDS="amdgpu radeonsi"
INPUT_DEVICES="libinput"
LINGUAS="en en_GB"
L10N="en en-GB"

ACCEPT_KEYWORDS="~amd64"
ACCEPT_LICENSE="*"
ABI_X86="64 32"

MAKEOPTS="-j32 -l32"
EMERGE_DEFAULT_OPTS="--jobs=16  --load-average 32"
PORTAGE_NICENESS=19
PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"
FEATURES="cgroup parallel-install"

PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"

package.env:

# Clang without LTO
app-arch/bzip2 clang-no-lto
app-arch/unzip clang-no-lto
sys-libs/readline clang-no-lto
sys-libs/e2fsprogs-libs clang-no-lto
sys-fs/e2fsprogs clang-no-lto
sys-apps/less clang-no-lto
dev-libs/openssl clang-no-lto
net-firewall/iptables clang-no-lto
sys-apps/busybox clang-no-lto
dev-lang/perl clang-no-lto
dev-lang/python clang-no-lto
dev-libs/popt clang-no-lto
net-misc/openssh clang-no-lto
sys-devel/gettext clang-no-lto
app-crypt/rhash clang-no-lto
sys-apps/texinfo clang-no-lto
sys-libs/binutils-libs clang-no-lto
sys-apps/iproute2 clang-no-lto
sys-apps/pciutils clang-no-lto
app-admin/mcelog clang-no-lto
app-arch/zstd clang-no-lto
sys-fs/btrfs-progs clang-no-lto

# GCC
sys-devel/m4 gcc-standard
dev-libs/mpfr gcc-standard
dev-libs/libgcrypt gcc-standard
sys-libs/glibc gcc-standard
mail-mta/nullmailer gcc-standard

(clang-no-lto is, you’ve guessed it, Clang with -O3 and no LTO and gcc-standard is GCC with -O3 and no LTO—I’m not using LTO on GCC at all at the moment)

Plus, I’ve failed to build sys-apps/man-db on any settings, including GCC with -O0.

Tomorrow hopefully I’ll build the rest of my system (Plasma with systemd on 17.1 profile).

All 10 comments

Sure! You could post them on this issue if you'd like.

On Sun, Sep 16, 2018, 9:09 AM Althorion, notifications@github.com wrote:

I will be building Gentoo from scratch soon, and I though about trying
to use clang + LTO. Will you be interested in my results?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/InBetweenNames/gentooLTO/issues/146, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AHdVjKSaTsdZghe3WjJvcCIbxpKSX9Ojks5ubk2TgaJpZM4Wq1_K
.

ThinLTO?

Yup, same as GCC

On Sun, Sep 16, 2018, 5:32 PM Supded, notifications@github.com wrote:

ThinLTO?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/InBetweenNames/gentooLTO/issues/146#issuecomment-421837137,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHdVjP16VpYXIagg_XsYj6bgnMLWZ6DXks5ubsNxgaJpZM4Wq1_K
.

Ahh, I confused this with GCCs own nomenclature. Still, I think it's
interesting and worth trying.

On Mon, Sep 17, 2018, 1:44 AM Supded, notifications@github.com wrote:

https://clang.llvm.org/docs/ThinLTO.html
Is it same? -flto=thin


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/InBetweenNames/gentooLTO/issues/146#issuecomment-421894757,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHdVjHflzt0VgJD6iO8fwxmsdptWfnrpks5ubzaugaJpZM4Wq1_K
.

I think, where must be a per compiler flags, ThinLTO for clang and LTO for gcc.

So, for now I have successfully build the basic system, with following settings:

make.conf:

CBUILD="x86_64-pc-linux-gnu"
CHOST="x86_64-pc-linux-gnu"
CC="clang"
CXX="clang++"
CFLAGS="-march=native -O3 -pipe -flto=thin"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O3 -Wl,--as-needed"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"
STRIP_MASK="*.a"

USE="-pch bindist clang mmx sse sse2 pgo"
VIDEO_CARDS="amdgpu radeonsi"
INPUT_DEVICES="libinput"
LINGUAS="en en_GB"
L10N="en en-GB"

ACCEPT_KEYWORDS="~amd64"
ACCEPT_LICENSE="*"
ABI_X86="64 32"

MAKEOPTS="-j32 -l32"
EMERGE_DEFAULT_OPTS="--jobs=16  --load-average 32"
PORTAGE_NICENESS=19
PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"
FEATURES="cgroup parallel-install"

PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"

package.env:

# Clang without LTO
app-arch/bzip2 clang-no-lto
app-arch/unzip clang-no-lto
sys-libs/readline clang-no-lto
sys-libs/e2fsprogs-libs clang-no-lto
sys-fs/e2fsprogs clang-no-lto
sys-apps/less clang-no-lto
dev-libs/openssl clang-no-lto
net-firewall/iptables clang-no-lto
sys-apps/busybox clang-no-lto
dev-lang/perl clang-no-lto
dev-lang/python clang-no-lto
dev-libs/popt clang-no-lto
net-misc/openssh clang-no-lto
sys-devel/gettext clang-no-lto
app-crypt/rhash clang-no-lto
sys-apps/texinfo clang-no-lto
sys-libs/binutils-libs clang-no-lto
sys-apps/iproute2 clang-no-lto
sys-apps/pciutils clang-no-lto
app-admin/mcelog clang-no-lto
app-arch/zstd clang-no-lto
sys-fs/btrfs-progs clang-no-lto

# GCC
sys-devel/m4 gcc-standard
dev-libs/mpfr gcc-standard
dev-libs/libgcrypt gcc-standard
sys-libs/glibc gcc-standard
mail-mta/nullmailer gcc-standard

(clang-no-lto is, you’ve guessed it, Clang with -O3 and no LTO and gcc-standard is GCC with -O3 and no LTO—I’m not using LTO on GCC at all at the moment)

Plus, I’ve failed to build sys-apps/man-db on any settings, including GCC with -O0.

Tomorrow hopefully I’ll build the rest of my system (Plasma with systemd on 17.1 profile).

It would be interesting to use gcc as the main compiler and use clang for packages like Firefox which fail when using GCC+LTO (but not with clang+LTO)

So, the short version: it cannot be reasonably done.

Longer version: I had to downgrade the binutils to get the system to even fully build (https://bugzilla.redhat.com/show_bug.cgi?id=1599521), and then I got caught up with a plethora of QObject::connect: signal not found bugs, which seem to be connected to https://bugreports.qt.io/browse/QTBUG-43556. Tracking down each and every one last place where things build fine, but are unresponsive doesn’t seem like a thing I have a time to do, so I’m giving up.

Ouch! Thanks for taking the time to try it out. It may be best that we recommend clang for specific packages only.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ElDavoo picture ElDavoo  ·  5Comments

javashin picture javashin  ·  4Comments

nvertigo picture nvertigo  ·  10Comments

jiblime picture jiblime  ·  3Comments

nivedita76 picture nivedita76  ·  17Comments