mozconfig-v6.60.eclass: add USE=clang
authorThomas Deutschmann <whissi@gentoo.org>
Thu, 27 Sep 2018 14:51:52 +0000 (16:51 +0200)
committerThomas Deutschmann <whissi@gentoo.org>
Thu, 27 Sep 2018 16:19:09 +0000 (18:19 +0200)
See commit 59c9e92b639712d4c37ece540582db83afdc8608 for details.

Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
eclass/mozconfig-v6.60.eclass

index c124baef74e6abfd274a16939c666b621f105bef..a9b04fd7730b56b456b4ae453098ba55d7d27ca8 100644 (file)
@@ -75,7 +75,7 @@ inherit flag-o-matic toolchain-funcs mozcoreconf-v6
 # Set the variable to any value if the use flag should exist but not be default-enabled.
 
 # use-flags common among all mozilla ebuilds
-IUSE="${IUSE} dbus debug neon pulseaudio selinux startup-notification system-harfbuzz
+IUSE="${IUSE} clang dbus debug neon pulseaudio selinux startup-notification system-harfbuzz
  system-icu system-jpeg system-libevent system-sqlite system-libvpx"
 
 # some notes on deps:
@@ -155,6 +155,10 @@ DEPEND="app-arch/zip
        app-arch/unzip
        >=sys-devel/binutils-2.30
        sys-apps/findutils
+       clang? (
+               >=sys-devel/llvm-4.0.1[gold]
+               >=sys-devel/lld-4.0.1
+       )
        pulseaudio? ( media-sound/pulseaudio )
        elibc_glibc? (
                virtual/cargo
@@ -189,6 +193,20 @@ RDEPEND+="
 # }
 
 mozconfig_config() {
+       if use clang && ! tc-is-clang ; then
+               # Force clang
+               einfo "Enforcing the use of clang due to USE=clang ..."
+               CC=${CHOST}-clang
+               CXX=${CHOST}-clang++
+               strip-unsupported-flags
+       elif ! use clang && ! tc-is-gcc ; then
+               # Force gcc
+               einfo "Enforcing the use of gcc due to USE=-clang ..."
+               CC=${CHOST}-gcc
+               CXX=${CHOST}-gcc++
+               strip-unsupported-flags
+       fi
+
        # Migrated from mozcoreconf-2
        mozconfig_annotate 'system_libs' \
                --with-system-zlib \
@@ -200,11 +218,14 @@ mozconfig_config() {
        # Must pass release in order to properly select linker
        mozconfig_annotate 'Enable by Gentoo' --enable-release
 
-       # Must pass --enable-gold if using ld.gold
-       if tc-ld-is-gold ; then
-               mozconfig_annotate 'tc-ld-is-gold=true' --enable-gold
+       # Avoid auto-magic on linker
+       if use clang ; then
+               # This is upstream's default
+               mozconfig_annotate "forcing ld=lld due to USE=clang" --enable-linker=lld
+       elif tc-ld-is-gold ; then
+               mozconfig_annotate "linker is set to gold" --enable-linker=gold
        else
-               mozconfig_annotate 'tc-ld-is-gold=false' --disable-gold
+               mozconfig_annotate "linker is set to bfd" --enable-linker=bfd
        fi
 
        if has bindist ${IUSE}; then