commit:     c4563a5b5a22606b39f91153c9d78e2367de4dd7
Author:     Ian Jordan <immoloism <AT> gmail <DOT> com>
AuthorDate: Wed Feb  8 19:12:21 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 22 18:32:39 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c4563a5b

sys-devel/llvm sys-devel/clang: GCC -flto ICE mitigation

GCC causes an ICE in llvm/clang when compiled with LTO, this has been tested 
with
every version of GCC with each version of llvm/clang in tree but does not 
happened
when clang compiles itself with LTO.

This will stop many of the issues people face with using LTO systemwide on 
Gentoo
until this get fixed upstreamed but I left the bug itself on b.g.o so this 
tested
with each release and removed once finally solved.

It's unclear if this is a GCC bug or a LLVM one (GCC miscompilation,
UB in LLVM meaning "miscompiled" but it's LLVM's fault, or a bug in LLVM
itself which only shows up when built with GCC).

Bug: https://bugs.gentoo.org/873670
Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106943
Bug: https://github.com/llvm/llvm-project/issues/57740
Bug: https://github.com/llvm/llvm-project/issues/60877
Signed-off-by: Ian Jordan <immoloism <AT> gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/29496
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-devel/clang/clang-14.0.6-r1.ebuild          | 4 +++-
 sys-devel/clang/clang-15.0.7-r1.ebuild          | 4 +++-
 sys-devel/clang/clang-16.0.0.9999.ebuild        | 4 +++-
 sys-devel/clang/clang-16.0.0_rc2.ebuild         | 4 +++-
 sys-devel/clang/clang-17.0.0.9999.ebuild        | 4 +++-
 sys-devel/clang/clang-17.0.0_pre20230211.ebuild | 4 +++-
 sys-devel/clang/clang-17.0.0_pre20230218.ebuild | 4 +++-
 sys-devel/llvm/llvm-14.0.6-r2.ebuild            | 5 +++--
 sys-devel/llvm/llvm-15.0.7.ebuild               | 4 +++-
 sys-devel/llvm/llvm-16.0.0.9999.ebuild          | 4 +++-
 sys-devel/llvm/llvm-16.0.0_rc2.ebuild           | 4 +++-
 sys-devel/llvm/llvm-17.0.0.9999.ebuild          | 4 +++-
 sys-devel/llvm/llvm-17.0.0_pre20230211.ebuild   | 4 +++-
 sys-devel/llvm/llvm-17.0.0_pre20230218.ebuild   | 4 +++-
 14 files changed, 42 insertions(+), 15 deletions(-)

diff --git a/sys-devel/clang/clang-14.0.6-r1.ebuild 
b/sys-devel/clang/clang-14.0.6-r1.ebuild
index 5cdb584470ac..417a3a40d87d 100644
--- a/sys-devel/clang/clang-14.0.6-r1.ebuild
+++ b/sys-devel/clang/clang-14.0.6-r1.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..10} )
 inherit cmake llvm llvm.org multilib multilib-minimal \
-       prefix python-single-r1 toolchain-funcs
+       prefix python-single-r1 toolchain-funcs flag-o-matic
 
 DESCRIPTION="C language family frontend for LLVM"
 HOMEPAGE="https://llvm.org/";
@@ -234,6 +234,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local llvm_version=$(llvm-config --version) || die
        local clang_version=$(ver_cut 1-3 "${llvm_version}")
 

diff --git a/sys-devel/clang/clang-15.0.7-r1.ebuild 
b/sys-devel/clang/clang-15.0.7-r1.ebuild
index 578c01ab0ea2..26eaebf4de2d 100644
--- a/sys-devel/clang/clang-15.0.7-r1.ebuild
+++ b/sys-devel/clang/clang-15.0.7-r1.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm llvm.org multilib multilib-minimal \
-       prefix python-single-r1 toolchain-funcs
+       prefix python-single-r1 toolchain-funcs flag-o-matic
 
 DESCRIPTION="C language family frontend for LLVM"
 HOMEPAGE="https://llvm.org/";
@@ -252,6 +252,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local mycmakeargs=(
                -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}")
                -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"

diff --git a/sys-devel/clang/clang-16.0.0.9999.ebuild 
b/sys-devel/clang/clang-16.0.0.9999.ebuild
index b45257440e78..6a4c9a3aefe0 100644
--- a/sys-devel/clang/clang-16.0.0.9999.ebuild
+++ b/sys-devel/clang/clang-16.0.0.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm llvm.org multilib multilib-minimal \
-       prefix python-single-r1 toolchain-funcs
+       prefix python-single-r1 toolchain-funcs flag-o-matic
 
 DESCRIPTION="C language family frontend for LLVM"
 HOMEPAGE="https://llvm.org/";
@@ -253,6 +253,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local mycmakeargs=(
                -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}")
                -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"

diff --git a/sys-devel/clang/clang-16.0.0_rc2.ebuild 
b/sys-devel/clang/clang-16.0.0_rc2.ebuild
index c89f4249a8ad..1ba28fce62a6 100644
--- a/sys-devel/clang/clang-16.0.0_rc2.ebuild
+++ b/sys-devel/clang/clang-16.0.0_rc2.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm llvm.org multilib multilib-minimal \
-       prefix python-single-r1 toolchain-funcs
+       prefix python-single-r1 toolchain-funcs flag-o-matic
 
 DESCRIPTION="C language family frontend for LLVM"
 HOMEPAGE="https://llvm.org/";
@@ -253,6 +253,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local mycmakeargs=(
                -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}")
                -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"

diff --git a/sys-devel/clang/clang-17.0.0.9999.ebuild 
b/sys-devel/clang/clang-17.0.0.9999.ebuild
index b45257440e78..6a4c9a3aefe0 100644
--- a/sys-devel/clang/clang-17.0.0.9999.ebuild
+++ b/sys-devel/clang/clang-17.0.0.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm llvm.org multilib multilib-minimal \
-       prefix python-single-r1 toolchain-funcs
+       prefix python-single-r1 toolchain-funcs flag-o-matic
 
 DESCRIPTION="C language family frontend for LLVM"
 HOMEPAGE="https://llvm.org/";
@@ -253,6 +253,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local mycmakeargs=(
                -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}")
                -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"

diff --git a/sys-devel/clang/clang-17.0.0_pre20230211.ebuild 
b/sys-devel/clang/clang-17.0.0_pre20230211.ebuild
index b45257440e78..6a4c9a3aefe0 100644
--- a/sys-devel/clang/clang-17.0.0_pre20230211.ebuild
+++ b/sys-devel/clang/clang-17.0.0_pre20230211.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm llvm.org multilib multilib-minimal \
-       prefix python-single-r1 toolchain-funcs
+       prefix python-single-r1 toolchain-funcs flag-o-matic
 
 DESCRIPTION="C language family frontend for LLVM"
 HOMEPAGE="https://llvm.org/";
@@ -253,6 +253,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local mycmakeargs=(
                -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}")
                -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"

diff --git a/sys-devel/clang/clang-17.0.0_pre20230218.ebuild 
b/sys-devel/clang/clang-17.0.0_pre20230218.ebuild
index b45257440e78..6a4c9a3aefe0 100644
--- a/sys-devel/clang/clang-17.0.0_pre20230218.ebuild
+++ b/sys-devel/clang/clang-17.0.0_pre20230218.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm llvm.org multilib multilib-minimal \
-       prefix python-single-r1 toolchain-funcs
+       prefix python-single-r1 toolchain-funcs flag-o-matic
 
 DESCRIPTION="C language family frontend for LLVM"
 HOMEPAGE="https://llvm.org/";
@@ -253,6 +253,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local mycmakeargs=(
                -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}")
                -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"

diff --git a/sys-devel/llvm/llvm-14.0.6-r2.ebuild 
b/sys-devel/llvm/llvm-14.0.6-r2.ebuild
index 4c18c1ba4aa7..dc3a35b256f4 100644
--- a/sys-devel/llvm/llvm-14.0.6-r2.ebuild
+++ b/sys-devel/llvm/llvm-14.0.6-r2.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..10} )
 inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
-       toolchain-funcs
+       toolchain-funcs flag-o-matic
 
 DESCRIPTION="Low Level Virtual Machine"
 HOMEPAGE="https://llvm.org/";
@@ -321,12 +321,13 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local ffi_cflags ffi_ldflags
        if use libffi; then
                ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)
                ffi_ldflags=$($(tc-getPKG_CONFIG) --libs-only-L libffi)
        fi
-
        local libdir=$(get_libdir)
        local mycmakeargs=(
                # disable appending VCS revision to the version to improve

diff --git a/sys-devel/llvm/llvm-15.0.7.ebuild 
b/sys-devel/llvm/llvm-15.0.7.ebuild
index 1b490e20948d..0608b0a4de25 100644
--- a/sys-devel/llvm/llvm-15.0.7.ebuild
+++ b/sys-devel/llvm/llvm-15.0.7.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
-       toolchain-funcs
+       toolchain-funcs flag-o-matic
 
 DESCRIPTION="Low Level Virtual Machine"
 HOMEPAGE="https://llvm.org/";
@@ -323,6 +323,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local ffi_cflags ffi_ldflags
        if use libffi; then
                ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)

diff --git a/sys-devel/llvm/llvm-16.0.0.9999.ebuild 
b/sys-devel/llvm/llvm-16.0.0.9999.ebuild
index d4655d4dc33f..af0cdcdc6249 100644
--- a/sys-devel/llvm/llvm-16.0.0.9999.ebuild
+++ b/sys-devel/llvm/llvm-16.0.0.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
-       toolchain-funcs
+       toolchain-funcs flag-o-matic
 
 DESCRIPTION="Low Level Virtual Machine"
 HOMEPAGE="https://llvm.org/";
@@ -325,6 +325,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local ffi_cflags ffi_ldflags
        if use libffi; then
                ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)

diff --git a/sys-devel/llvm/llvm-16.0.0_rc2.ebuild 
b/sys-devel/llvm/llvm-16.0.0_rc2.ebuild
index 21023c3bf7e4..92aec87031e0 100644
--- a/sys-devel/llvm/llvm-16.0.0_rc2.ebuild
+++ b/sys-devel/llvm/llvm-16.0.0_rc2.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
-       toolchain-funcs
+       toolchain-funcs flag-o-matic
 
 DESCRIPTION="Low Level Virtual Machine"
 HOMEPAGE="https://llvm.org/";
@@ -325,6 +325,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local ffi_cflags ffi_ldflags
        if use libffi; then
                ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)

diff --git a/sys-devel/llvm/llvm-17.0.0.9999.ebuild 
b/sys-devel/llvm/llvm-17.0.0.9999.ebuild
index d4655d4dc33f..af0cdcdc6249 100644
--- a/sys-devel/llvm/llvm-17.0.0.9999.ebuild
+++ b/sys-devel/llvm/llvm-17.0.0.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
-       toolchain-funcs
+       toolchain-funcs flag-o-matic
 
 DESCRIPTION="Low Level Virtual Machine"
 HOMEPAGE="https://llvm.org/";
@@ -325,6 +325,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local ffi_cflags ffi_ldflags
        if use libffi; then
                ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)

diff --git a/sys-devel/llvm/llvm-17.0.0_pre20230211.ebuild 
b/sys-devel/llvm/llvm-17.0.0_pre20230211.ebuild
index d4655d4dc33f..af0cdcdc6249 100644
--- a/sys-devel/llvm/llvm-17.0.0_pre20230211.ebuild
+++ b/sys-devel/llvm/llvm-17.0.0_pre20230211.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
-       toolchain-funcs
+       toolchain-funcs flag-o-matic
 
 DESCRIPTION="Low Level Virtual Machine"
 HOMEPAGE="https://llvm.org/";
@@ -325,6 +325,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local ffi_cflags ffi_ldflags
        if use libffi; then
                ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)

diff --git a/sys-devel/llvm/llvm-17.0.0_pre20230218.ebuild 
b/sys-devel/llvm/llvm-17.0.0_pre20230218.ebuild
index d4655d4dc33f..af0cdcdc6249 100644
--- a/sys-devel/llvm/llvm-17.0.0_pre20230218.ebuild
+++ b/sys-devel/llvm/llvm-17.0.0_pre20230218.ebuild
@@ -5,7 +5,7 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{9..11} )
 inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
-       toolchain-funcs
+       toolchain-funcs flag-o-matic
 
 DESCRIPTION="Low Level Virtual Machine"
 HOMEPAGE="https://llvm.org/";
@@ -325,6 +325,8 @@ get_distribution_components() {
 }
 
 multilib_src_configure() {
+       tcc-is-gcc && filter-lto # GCC miscompiles LLVM, bug #873670
+
        local ffi_cflags ffi_ldflags
        if use libffi; then
                ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)

Reply via email to