commit:     9981a41f95601118673e177101688eedfb4b8652
Author:     Violet Purcell <vimproved <AT> inventati <DOT> org>
AuthorDate: Fri Sep  8 23:10:40 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep 10 07:06:24 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9981a41f

sys-devel/clang-common: Install configuration files for extra triples

This commit makes clang-common install clang configuration files for the
gentoo, pc, and unknown vendors. Some software (eg rust) pass tuples
with vendors different from CHOST to clang, causing clang to not
properly use the configuration file.

Signed-off-by: Violet Purcell <vimproved <AT> inventati.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../clang-common/clang-common-17.0.0.9999.ebuild   | 35 +++++++++++++++++-----
 ...c4.ebuild => clang-common-17.0.0_rc4-r1.ebuild} | 35 +++++++++++++++++-----
 .../clang-common/clang-common-18.0.0.9999.ebuild   | 35 +++++++++++++++++-----
 ...d => clang-common-18.0.0_pre20230906-r1.ebuild} | 35 +++++++++++++++++-----
 4 files changed, 108 insertions(+), 32 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 8bca701cfc0b..5e56c5f7b4e6 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
@@ -63,6 +63,30 @@ pkg_pretend() {
        fi
 }
 
+doclang_cfg() {
+       local triple="${1}"
+
+       local tool
+       for tool in ${triple}-clang{,++,-cpp}; do
+               newins - "${tool}.cfg" <<-EOF
+                       # This configuration file is used by ${tool} driver.
+                       @gentoo-common.cfg
+               EOF
+       done
+
+       # Install symlinks for triples with other vendor strings since some
+       # programs insist on mangling the triple.
+       local vendor
+       for vendor in gentoo pc unknown; do
+               local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}"
+               for tool in clang{,++,-cpp}; do
+                       if [[ ! -f 
"${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then
+                               dosym "${triple}-${tool}.cfg" 
"/etc/clang/${vendor_triple}-${tool}.cfg"
+                       fi
+               done
+       done
+}
+
 src_install() {
        newbashcomp bash-autocomplete.sh clang
 
@@ -176,18 +200,13 @@ src_install() {
        # We only install config files for supported ABIs because unprefixed 
tools
        # might be used for crosscompilation where e.g. PIE may not be 
supported.
        # See bug #912237 and bug #901247.
+       doclang_cfg "${CHOST}"
+
        # Just ${CHOST} won't do due to bug #912685.
        local abi
        for abi in $(get_all_abis); do
                local abi_chost=$(get_abi_CHOST "${abi}")
-
-               local tool
-               for tool in ${abi_chost}-clang{,++,-cpp}; do
-                       newins - "${tool}.cfg" <<-EOF
-                               # This configuration file is used by ${tool} 
driver.
-                               @gentoo-common.cfg
-                       EOF
-               done
+               doclang_cfg "${abi_chost}"
        done
 }
 

diff --git a/sys-devel/clang-common/clang-common-17.0.0_rc4.ebuild 
b/sys-devel/clang-common/clang-common-17.0.0_rc4-r1.ebuild
similarity index 89%
rename from sys-devel/clang-common/clang-common-17.0.0_rc4.ebuild
rename to sys-devel/clang-common/clang-common-17.0.0_rc4-r1.ebuild
index 8bca701cfc0b..5e56c5f7b4e6 100644
--- a/sys-devel/clang-common/clang-common-17.0.0_rc4.ebuild
+++ b/sys-devel/clang-common/clang-common-17.0.0_rc4-r1.ebuild
@@ -63,6 +63,30 @@ pkg_pretend() {
        fi
 }
 
+doclang_cfg() {
+       local triple="${1}"
+
+       local tool
+       for tool in ${triple}-clang{,++,-cpp}; do
+               newins - "${tool}.cfg" <<-EOF
+                       # This configuration file is used by ${tool} driver.
+                       @gentoo-common.cfg
+               EOF
+       done
+
+       # Install symlinks for triples with other vendor strings since some
+       # programs insist on mangling the triple.
+       local vendor
+       for vendor in gentoo pc unknown; do
+               local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}"
+               for tool in clang{,++,-cpp}; do
+                       if [[ ! -f 
"${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then
+                               dosym "${triple}-${tool}.cfg" 
"/etc/clang/${vendor_triple}-${tool}.cfg"
+                       fi
+               done
+       done
+}
+
 src_install() {
        newbashcomp bash-autocomplete.sh clang
 
@@ -176,18 +200,13 @@ src_install() {
        # We only install config files for supported ABIs because unprefixed 
tools
        # might be used for crosscompilation where e.g. PIE may not be 
supported.
        # See bug #912237 and bug #901247.
+       doclang_cfg "${CHOST}"
+
        # Just ${CHOST} won't do due to bug #912685.
        local abi
        for abi in $(get_all_abis); do
                local abi_chost=$(get_abi_CHOST "${abi}")
-
-               local tool
-               for tool in ${abi_chost}-clang{,++,-cpp}; do
-                       newins - "${tool}.cfg" <<-EOF
-                               # This configuration file is used by ${tool} 
driver.
-                               @gentoo-common.cfg
-                       EOF
-               done
+               doclang_cfg "${abi_chost}"
        done
 }
 

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 8bca701cfc0b..5e56c5f7b4e6 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
@@ -63,6 +63,30 @@ pkg_pretend() {
        fi
 }
 
+doclang_cfg() {
+       local triple="${1}"
+
+       local tool
+       for tool in ${triple}-clang{,++,-cpp}; do
+               newins - "${tool}.cfg" <<-EOF
+                       # This configuration file is used by ${tool} driver.
+                       @gentoo-common.cfg
+               EOF
+       done
+
+       # Install symlinks for triples with other vendor strings since some
+       # programs insist on mangling the triple.
+       local vendor
+       for vendor in gentoo pc unknown; do
+               local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}"
+               for tool in clang{,++,-cpp}; do
+                       if [[ ! -f 
"${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then
+                               dosym "${triple}-${tool}.cfg" 
"/etc/clang/${vendor_triple}-${tool}.cfg"
+                       fi
+               done
+       done
+}
+
 src_install() {
        newbashcomp bash-autocomplete.sh clang
 
@@ -176,18 +200,13 @@ src_install() {
        # We only install config files for supported ABIs because unprefixed 
tools
        # might be used for crosscompilation where e.g. PIE may not be 
supported.
        # See bug #912237 and bug #901247.
+       doclang_cfg "${CHOST}"
+
        # Just ${CHOST} won't do due to bug #912685.
        local abi
        for abi in $(get_all_abis); do
                local abi_chost=$(get_abi_CHOST "${abi}")
-
-               local tool
-               for tool in ${abi_chost}-clang{,++,-cpp}; do
-                       newins - "${tool}.cfg" <<-EOF
-                               # This configuration file is used by ${tool} 
driver.
-                               @gentoo-common.cfg
-                       EOF
-               done
+               doclang_cfg "${abi_chost}"
        done
 }
 

diff --git a/sys-devel/clang-common/clang-common-18.0.0_pre20230906.ebuild 
b/sys-devel/clang-common/clang-common-18.0.0_pre20230906-r1.ebuild
similarity index 89%
rename from sys-devel/clang-common/clang-common-18.0.0_pre20230906.ebuild
rename to sys-devel/clang-common/clang-common-18.0.0_pre20230906-r1.ebuild
index 8bca701cfc0b..5e56c5f7b4e6 100644
--- a/sys-devel/clang-common/clang-common-18.0.0_pre20230906.ebuild
+++ b/sys-devel/clang-common/clang-common-18.0.0_pre20230906-r1.ebuild
@@ -63,6 +63,30 @@ pkg_pretend() {
        fi
 }
 
+doclang_cfg() {
+       local triple="${1}"
+
+       local tool
+       for tool in ${triple}-clang{,++,-cpp}; do
+               newins - "${tool}.cfg" <<-EOF
+                       # This configuration file is used by ${tool} driver.
+                       @gentoo-common.cfg
+               EOF
+       done
+
+       # Install symlinks for triples with other vendor strings since some
+       # programs insist on mangling the triple.
+       local vendor
+       for vendor in gentoo pc unknown; do
+               local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}"
+               for tool in clang{,++,-cpp}; do
+                       if [[ ! -f 
"${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then
+                               dosym "${triple}-${tool}.cfg" 
"/etc/clang/${vendor_triple}-${tool}.cfg"
+                       fi
+               done
+       done
+}
+
 src_install() {
        newbashcomp bash-autocomplete.sh clang
 
@@ -176,18 +200,13 @@ src_install() {
        # We only install config files for supported ABIs because unprefixed 
tools
        # might be used for crosscompilation where e.g. PIE may not be 
supported.
        # See bug #912237 and bug #901247.
+       doclang_cfg "${CHOST}"
+
        # Just ${CHOST} won't do due to bug #912685.
        local abi
        for abi in $(get_all_abis); do
                local abi_chost=$(get_abi_CHOST "${abi}")
-
-               local tool
-               for tool in ${abi_chost}-clang{,++,-cpp}; do
-                       newins - "${tool}.cfg" <<-EOF
-                               # This configuration file is used by ${tool} 
driver.
-                               @gentoo-common.cfg
-                       EOF
-               done
+               doclang_cfg "${abi_chost}"
        done
 }
 

Reply via email to