Skip to content

Instantly share code, notes, and snippets.

@gcarq
Last active February 21, 2022 19:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcarq/84edbb9dc1bf70c8ef53a9498ea78f3c to your computer and use it in GitHub Desktop.
Save gcarq/84edbb9dc1bf70c8ef53a9498ea78f3c to your computer and use it in GitHub Desktop.
Gentoo package.env for global clang-13
# Required to bootstrap LLVM and clang
sys-devel/llvm bootstrap-clang
sys-libs/libcxx bootstrap-clang
sys-libs/libcxxabi bootstrap-clang
sys-libs/compiler-rt bootstrap-clang
sys-libs/compiler-rt-sanitizers bootstrap-clang
sys-libs/llvm-libunwind bootstrap-clang
sys-devel/lld bootstrap-clang
sys-devel/clang bootstrap-clang
# Workarounds to make it work with clang 13.0.0
app-emulation/virtualbox-modules clang-kernel # needs special environment variables set
media-video/pipewire with-latomic # ld.lld: error: undefined symbol: __atomic_store_8 https://bugs.gentoo.org/802162
sys-fs/extundelete std-c++03 # error: non-constant-expression cannot be narrowed from type 'int' to 'ext2_ino_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
# Not compatible with clang 13.0.0
app-backup/borgbackup compiler-gcc # ld.lld: error: /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crti.o is incompatible with elf32-i386
app-doc/doxygen compiler-gcc # fatal error: 'utility' file not found #include <utility>
app-emulation/wine-staging compiler-gcc # configure: error: libopenal development files not found (or too old), OpenAL won't be supported.
app-emulation/virtualbox compiler-gcc # fatal error: 'syslimits.h' file not found
app-emulation/qemu compiler-gcc # ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T. You probably need to set PKG_CONFIG_LIBDIR to point to the right pkg-config files for your build target
cross-i686-w64-mingw32/binutils compiler-gcc # Not compatible with clang
cross-i686-w64-mingw32/gcc compiler-gcc # Not compatible with clang
cross-i686-w64-mingw32/mingw64-runtime compiler-gcc # Not compatible with clang
cross-x86_64-w64-mingw32/binutils compiler-gcc # Not compatible with clang
cross-x86_64-w64-mingw32/gcc compiler-gcc # Not compatible with clang
cross-x86_64-w64-mingw32/mingw64-runtime compiler-gcc # Not compatible with clang
dev-cpp/antlr-cpp compiler-gcc # fatal error: 'algorithm' file not found
dev-lang/ocaml compiler-gcc # llvm-ranlib: error: exactly one archive should be specified
dev-libs/elfutils compiler-gcc # configure: error: gcc with GNU99 support required. Work in progress: https://sourceware.org/pipermail/elfutils-devel/2021q3/004033.html
dev-libs/ell compiler-gcc # error: function definition is not allowed here. Gentoo bug: https://bugs.gentoo.org/792609
dev-libs/libixion compiler-gcc # model_context.cpp:20:39: error: unknown type name 'nullptr_t'; did you mean 'std::nullptr_t'?
media-video/transcode compiler-gcc # ERROR: option '--enable-iconv' failed: cannot find either iconv_open() or libiconv_open()
net-wireless/iwd compiler-gcc # error: function definition is not allowed here
net-misc/x11-ssh-askpass compiler-gcc # fatal error: ' X11 .rules' file not found
sys-boot/syslinux compiler-gcc # fatal error: 'stdarg.h' file not found
sys-devel/binutils compiler-gcc # Can result in a broken system
sys-devel/gcc compiler-gcc # Can result in a broken system
sys-libs/binutils-libs compiler-gcc # Can result in a broken system
sys-libs/glibc compiler-gcc # Can result in a broken system
sys-process/tini compiler-gcc # ld.lld: error: unable to find library -l:libunwind.a
@gcarq
Copy link
Author

gcarq commented Nov 12, 2021

$ cat env/compiler-gcc
CC="gcc"
CXX="g++"
AR="ar"
NM="nm"
RANLIB="ranlib"
LD="ld.bfd"

COMMON_FLAGS="-march=native -O3 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
RUSTFLAGS="${RUSTFLAGS} -Copt-level=3 -Ctarget-cpu=native"

LDFLAGS="-Wl,-O2"

@gcarq
Copy link
Author

gcarq commented Nov 12, 2021

$ cat env/bootstrap-clang 
# Purpose of this is to bootstrap the clang toolchain

CC="clang"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"

COMMON_FLAGS="-O3 -march=native -pipe"

CFLAGS="${COMMON_FLAGS} -flto=thin"
CXXFLAGS="${COMMON_FLAGS} -flto=thin"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
RUSTFLAGS="${RUSTFLAGS} -Ctarget-cpu=native"

LDFLAGS="-Wl,-O2 -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind"

@gcarq
Copy link
Author

gcarq commented Nov 12, 2021

$ cat env/clang-kernel 
LLVM=1
LLVM_IAS=1

@gcarq
Copy link
Author

gcarq commented Nov 12, 2021

$ cat env/with-latomic 
LDFLAGS="${LDFLAGS} -latomic"
$ cat env/std-c++03 
CXXFLAGS="${CXXFLAGS} -std=c++03"

@gcarq
Copy link
Author

gcarq commented Nov 12, 2021

$ cat make.conf
...
CC="clang"
CXX="clang++"

COMMON_FLAGS="-march=native -O3 -pipe"

CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
RUSTFLAGS="${RUSTFLAGS} -Copt-level=3 -Ctarget-cpu=native"

LDFLAGS="${LDFLAGS} -Wl,-O2 -unwindlib=libunwind -Wl,--as-needed"

AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"

CMAKE_MAKEFILE_GENERATOR=ninja
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment