commit:     3ba93fbb30984b59eb99883292f336e6a0b1ea8b
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  9 20:33:59 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Oct  9 20:55:26 2022 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=3ba93fbb

gcc-config: update /etc/clang/gentoo-gcc-install.cfg if exists

* Set '--gcc-install-dir' for Clang to direct it to the currently
  active GCC installation.

* Only write to /etc/clang/gentoo-gcc-install.cfg if it already exists
  to allow us to back out the change gracefully (by stopping installation
  in sys-devel/clang-common) as there's some concerns wrt sysroot compatibility.

Bug: https://github.com/llvm/llvm-project/issues/57570
Bug: https://bugs.gentoo.org/868639
Signed-off-by: Sam James <sam <AT> gentoo.org>

 gcc-config | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/gcc-config b/gcc-config
index dfc01d0..31a7f4a 100755
--- a/gcc-config
+++ b/gcc-config
@@ -783,6 +783,21 @@ switch_profile() {
                        find "${pkgconfdir}"/libgcj*.pc -xtype l -delete 
2>/dev/null
                done
 
+               # Only update the file if it already exists to allow us to
+               # walk it back if necessary by dropping it from clang-common.
+               # See bug #868639 for background.
+               if [[ -f "${EROOT}/etc/clang/gentoo-gcc-install.cfg" ]] ; then
+                       local gcc_lib_path="$(get_lib_path)"
+                       gcc_lib_path="${gcc_lib_path%%:*}"
+                       cat > "${EROOT}/etc/clang/gentoo-gcc-install.cfg.tmp" 
<<-EOF
+                               # This file is maintained by gcc-config.
+                               # It is used to specify the selected GCC 
installation.
+                               --gcc-install-dir="${gcc_lib_path}"
+                       EOF
+
+                       mv_if_diff 
"${EROOT}/etc/clang/gentoo-gcc-install.cfg.tmp" 
"${EROOT}/etc/clang/gentoo-gcc-install.cfg"
+               fi
+
                prefix_copy_gcc_libs
                handle_split_usr
                : $(( envd_changed += $? ))

Reply via email to