Skip to content
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

clang as system compiler #146

Open
Althorion opened this issue Sep 16, 2018 · 10 comments
Open

clang as system compiler #146

Althorion opened this issue Sep 16, 2018 · 10 comments

Comments

@Althorion
Copy link
Contributor

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

@InBetweenNames
Copy link
Owner

InBetweenNames commented Sep 16, 2018 via email

@Supded
Copy link

Supded commented Sep 16, 2018

ThinLTO?

@InBetweenNames
Copy link
Owner

InBetweenNames commented Sep 16, 2018 via email

@Supded
Copy link

Supded commented Sep 17, 2018

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

@InBetweenNames
Copy link
Owner

InBetweenNames commented Sep 17, 2018 via email

@Supded
Copy link

Supded commented Sep 17, 2018

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

@Althorion
Copy link
Contributor Author

Althorion commented Sep 18, 2018

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).

@darkbasic
Copy link
Contributor

darkbasic commented Sep 18, 2018

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)

@Althorion
Copy link
Contributor Author

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.

@InBetweenNames
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants