commit:     979add2eb4a279abf853ee1278e4b3e39974601c
Author:     Violet Purcell <vimproved <AT> inventati <DOT> org>
AuthorDate: Fri Sep  8 23:17:47 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep 10 07:06:25 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=979add2e

sys-devel/clang-common: Don't pass link args to clang-cpp

Passing link args to clang-cpp via configuration file causes it to break
when invoked directly, which is done in some configure scripts (such as
x11-libs/libX11).

Signed-off-by: Violet Purcell <vimproved <AT> inventati.org>
Closes: https://github.com/gentoo/gentoo/pull/32480
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../clang-common/clang-common-17.0.0.9999.ebuild   | 22 +++++++++++++++++++++-
 .../clang-common/clang-common-17.0.0_rc4-r1.ebuild | 22 +++++++++++++++++++++-
 .../clang-common/clang-common-18.0.0.9999.ebuild   | 22 +++++++++++++++++++++-
 .../clang-common-18.0.0_pre20230906-r1.ebuild      | 22 +++++++++++++++++++++-
 4 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild 
b/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild
index 5e56c5f7b4e6..430e91d98aee 100644
--- a/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild
+++ b/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild
@@ -67,13 +67,19 @@ doclang_cfg() {
        local triple="${1}"
 
        local tool
-       for tool in ${triple}-clang{,++,-cpp}; do
+       for tool in ${triple}-clang{,++}; do
                newins - "${tool}.cfg" <<-EOF
                        # This configuration file is used by ${tool} driver.
                        @gentoo-common.cfg
+                       @gentoo-common-ld.cfg
                EOF
        done
 
+       newins - "${triple}-clang-cpp.cfg" <<-EOF
+               # This configuration file is used by the ${triple}-clang-cpp 
driver.
+               @gentoo-common.cfg
+       EOF
+
        # Install symlinks for triples with other vendor strings since some
        # programs insist on mangling the triple.
        local vendor
@@ -115,6 +121,13 @@ src_install() {
                -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h"
        EOF
 
+       # clang-cpp does not like link args being passed to it when directly
+       # invoked, so use a separate configuration file.
+       newins - gentoo-common-ld.cfg <<-EOF
+               # This file contains flags common to clang and clang++
+               @gentoo-hardened-ld.cfg
+       EOF
+
        # Baseline hardening (bug #851111)
        newins - gentoo-hardened.cfg <<-EOF
                # Some of these options are added unconditionally, regardless of
@@ -123,7 +136,11 @@ src_install() {
                -fstack-protector-strong
                -fPIE
                -include "${EPREFIX}/usr/include/gentoo/fortify.h"
+       EOF
 
+       newins - gentoo-hardened-ld.cfg <<-EOF
+               # Some of these options are added unconditionally, regardless of
+               # USE=hardened, for parity with sys-devel/gcc.
                -Wl,-z,relro
        EOF
 
@@ -170,7 +187,10 @@ src_install() {
                        # 
https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode
                        # 
https://libcxx.llvm.org/Hardening.html#using-hardened-mode
                        -D_LIBCPP_ENABLE_HARDENED_MODE=1
+               EOF
 
+               cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die
+                       # Options below are conditional on USE=hardened.
                        -Wl,-z,now
                EOF
        fi

diff --git a/sys-devel/clang-common/clang-common-17.0.0_rc4-r1.ebuild 
b/sys-devel/clang-common/clang-common-17.0.0_rc4-r1.ebuild
index 5e56c5f7b4e6..430e91d98aee 100644
--- a/sys-devel/clang-common/clang-common-17.0.0_rc4-r1.ebuild
+++ b/sys-devel/clang-common/clang-common-17.0.0_rc4-r1.ebuild
@@ -67,13 +67,19 @@ doclang_cfg() {
        local triple="${1}"
 
        local tool
-       for tool in ${triple}-clang{,++,-cpp}; do
+       for tool in ${triple}-clang{,++}; do
                newins - "${tool}.cfg" <<-EOF
                        # This configuration file is used by ${tool} driver.
                        @gentoo-common.cfg
+                       @gentoo-common-ld.cfg
                EOF
        done
 
+       newins - "${triple}-clang-cpp.cfg" <<-EOF
+               # This configuration file is used by the ${triple}-clang-cpp 
driver.
+               @gentoo-common.cfg
+       EOF
+
        # Install symlinks for triples with other vendor strings since some
        # programs insist on mangling the triple.
        local vendor
@@ -115,6 +121,13 @@ src_install() {
                -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h"
        EOF
 
+       # clang-cpp does not like link args being passed to it when directly
+       # invoked, so use a separate configuration file.
+       newins - gentoo-common-ld.cfg <<-EOF
+               # This file contains flags common to clang and clang++
+               @gentoo-hardened-ld.cfg
+       EOF
+
        # Baseline hardening (bug #851111)
        newins - gentoo-hardened.cfg <<-EOF
                # Some of these options are added unconditionally, regardless of
@@ -123,7 +136,11 @@ src_install() {
                -fstack-protector-strong
                -fPIE
                -include "${EPREFIX}/usr/include/gentoo/fortify.h"
+       EOF
 
+       newins - gentoo-hardened-ld.cfg <<-EOF
+               # Some of these options are added unconditionally, regardless of
+               # USE=hardened, for parity with sys-devel/gcc.
                -Wl,-z,relro
        EOF
 
@@ -170,7 +187,10 @@ src_install() {
                        # 
https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode
                        # 
https://libcxx.llvm.org/Hardening.html#using-hardened-mode
                        -D_LIBCPP_ENABLE_HARDENED_MODE=1
+               EOF
 
+               cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die
+                       # Options below are conditional on USE=hardened.
                        -Wl,-z,now
                EOF
        fi

diff --git a/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild 
b/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild
index 5e56c5f7b4e6..430e91d98aee 100644
--- a/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild
+++ b/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild
@@ -67,13 +67,19 @@ doclang_cfg() {
        local triple="${1}"
 
        local tool
-       for tool in ${triple}-clang{,++,-cpp}; do
+       for tool in ${triple}-clang{,++}; do
                newins - "${tool}.cfg" <<-EOF
                        # This configuration file is used by ${tool} driver.
                        @gentoo-common.cfg
+                       @gentoo-common-ld.cfg
                EOF
        done
 
+       newins - "${triple}-clang-cpp.cfg" <<-EOF
+               # This configuration file is used by the ${triple}-clang-cpp 
driver.
+               @gentoo-common.cfg
+       EOF
+
        # Install symlinks for triples with other vendor strings since some
        # programs insist on mangling the triple.
        local vendor
@@ -115,6 +121,13 @@ src_install() {
                -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h"
        EOF
 
+       # clang-cpp does not like link args being passed to it when directly
+       # invoked, so use a separate configuration file.
+       newins - gentoo-common-ld.cfg <<-EOF
+               # This file contains flags common to clang and clang++
+               @gentoo-hardened-ld.cfg
+       EOF
+
        # Baseline hardening (bug #851111)
        newins - gentoo-hardened.cfg <<-EOF
                # Some of these options are added unconditionally, regardless of
@@ -123,7 +136,11 @@ src_install() {
                -fstack-protector-strong
                -fPIE
                -include "${EPREFIX}/usr/include/gentoo/fortify.h"
+       EOF
 
+       newins - gentoo-hardened-ld.cfg <<-EOF
+               # Some of these options are added unconditionally, regardless of
+               # USE=hardened, for parity with sys-devel/gcc.
                -Wl,-z,relro
        EOF
 
@@ -170,7 +187,10 @@ src_install() {
                        # 
https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode
                        # 
https://libcxx.llvm.org/Hardening.html#using-hardened-mode
                        -D_LIBCPP_ENABLE_HARDENED_MODE=1
+               EOF
 
+               cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die
+                       # Options below are conditional on USE=hardened.
                        -Wl,-z,now
                EOF
        fi

diff --git a/sys-devel/clang-common/clang-common-18.0.0_pre20230906-r1.ebuild 
b/sys-devel/clang-common/clang-common-18.0.0_pre20230906-r1.ebuild
index 5e56c5f7b4e6..430e91d98aee 100644
--- a/sys-devel/clang-common/clang-common-18.0.0_pre20230906-r1.ebuild
+++ b/sys-devel/clang-common/clang-common-18.0.0_pre20230906-r1.ebuild
@@ -67,13 +67,19 @@ doclang_cfg() {
        local triple="${1}"
 
        local tool
-       for tool in ${triple}-clang{,++,-cpp}; do
+       for tool in ${triple}-clang{,++}; do
                newins - "${tool}.cfg" <<-EOF
                        # This configuration file is used by ${tool} driver.
                        @gentoo-common.cfg
+                       @gentoo-common-ld.cfg
                EOF
        done
 
+       newins - "${triple}-clang-cpp.cfg" <<-EOF
+               # This configuration file is used by the ${triple}-clang-cpp 
driver.
+               @gentoo-common.cfg
+       EOF
+
        # Install symlinks for triples with other vendor strings since some
        # programs insist on mangling the triple.
        local vendor
@@ -115,6 +121,13 @@ src_install() {
                -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h"
        EOF
 
+       # clang-cpp does not like link args being passed to it when directly
+       # invoked, so use a separate configuration file.
+       newins - gentoo-common-ld.cfg <<-EOF
+               # This file contains flags common to clang and clang++
+               @gentoo-hardened-ld.cfg
+       EOF
+
        # Baseline hardening (bug #851111)
        newins - gentoo-hardened.cfg <<-EOF
                # Some of these options are added unconditionally, regardless of
@@ -123,7 +136,11 @@ src_install() {
                -fstack-protector-strong
                -fPIE
                -include "${EPREFIX}/usr/include/gentoo/fortify.h"
+       EOF
 
+       newins - gentoo-hardened-ld.cfg <<-EOF
+               # Some of these options are added unconditionally, regardless of
+               # USE=hardened, for parity with sys-devel/gcc.
                -Wl,-z,relro
        EOF
 
@@ -170,7 +187,10 @@ src_install() {
                        # 
https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode
                        # 
https://libcxx.llvm.org/Hardening.html#using-hardened-mode
                        -D_LIBCPP_ENABLE_HARDENED_MODE=1
+               EOF
 
+               cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die
+                       # Options below are conditional on USE=hardened.
                        -Wl,-z,now
                EOF
        fi

Reply via email to