public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v1 1/6] LoongArch: a symmetric multilib subdir layout
@ 2023-08-14  3:57 Yang Yujie
  2023-08-14  3:57 ` [PATCH v1 2/6] LoongArch: improved target configuration interface Yang Yujie
                   ` (5 more replies)
  0 siblings, 6 replies; 27+ messages in thread
From: Yang Yujie @ 2023-08-14  3:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: xry111, xuchenghua, panchenghui, chenglulu, Yang Yujie

Multilib in gcc is asymmetric. i.e. a "default" / "toplevel"
library variant is always built and installed, and:

 * it is installed directly under the gcc libdir (with no suffix);
 * it is selected / searched / linked against when the gcc driver
   does not receive any option from MULTILIB_OPTIONS.

Meanwhile, multilib options from MULTILIB_OPTIONS may add suffixes
(--print-multi-lib) to this base directory and find compatible
library variants there.

However, for LoongArch, we do not want such a "toplevel" library
installation since the default ABI may change.  We expect all
multilib variants of libraries to be installed to their designated
ABI-specific subdirs (e.g. base/lp64d) of the GCC libdir, so that
the default ABI can be configured arbitrarily (with --with-abi)
while the gcc libdir layout stays consistent.  This could be
helpful for the distribution packaging of GCC libraries.

This patch achieves this by overriding ${with_multisubdir} of
the "toplevel" library and disabling the duplicate "multilib"
variant (which exists because LA's driver always generates a
normalized "-mabi=" option from self_spec even if it is not
given on the command line, causing the semantics of "toplevel"
library to be duplicate with a non-toplevel one).

Other architectures stay unaffected as long as they do not override
${with_multisubdir} in config-ml.in.

ChangeLog:

        * config-ml.in: add loongarch support.  Allow overriding
        toplevel multisubdir.

libgcc/ChangeLog:

        * config/loongarch/t-loongarch: make symlinks of toplevel
        libgcc.a under gcc/ for passing regression tests.
---
 config-ml.in                        | 39 ++++++++++++++++++++++++++++-
 libgcc/config/loongarch/t-loongarch | 16 ++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/config-ml.in b/config-ml.in
index 68854a4f16c..914cafb4b50 100644
--- a/config-ml.in
+++ b/config-ml.in
@@ -383,6 +383,18 @@ mips*-*-*)
 	  done
 	fi
 	;;
+loongarch*-*-*)
+	old_multidirs="${multidirs}"
+	multidirs=""
+	for x in ${old_multidirs}; do
+	  case "$x" in
+	    `${CC-gcc} --print-multi-directory`) : ;;
+	    *) multidirs="${multidirs} ${x}" ;;
+	  esac
+	done
+
+	with_multisubdir=`${CC-gcc} --print-multi-directory`
+	;;
 msp430-*-*)
 	if [ x$enable_no_exceptions = xno ]
 	then
@@ -509,7 +521,7 @@ multi-do:
 	  compiler="$(CC)"; \
 	  for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
 	    dir=`echo $$i | sed -e 's/;.*$$//'`; \
-	    if [ "$${dir}" = "." ]; then \
+	    if [ "$${dir}" = "." ] || [ "/$${dir}" = "$(MULTISUBDIR)" ]; then \
 	      true; \
 	    else \
 	      if [ -d ../$${dir}/$${lib} ]; then \
@@ -595,6 +607,12 @@ if [ -z "${with_multisubdir}" ]; then
   ml_subdir=
   ml_builddotdot=
   : # ml_srcdotdot= # already set
+elif [ "${ml_toplevel_p}" = yes ]; then
+  : # When ml_* is set by ${host}.
+  ml_subdir="/${with_multisubdir}"
+  ml_builddotdot=
+  ml_builddotdot_link=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
+  : # ml_srcdotdot= # already set
 else
   ml_subdir="/${with_multisubdir}"
   # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
@@ -654,6 +672,25 @@ mv Makefile.tem ${Makefile}
 
 if [ "${ml_toplevel_p}" = yes ]; then
 
+# If multisubdir is set on the top level, create a symbolic link
+# to cope with in-tree regression tests (see dejagnu: libgloss.exp).
+
+if [ -n "${with_multisubdir}" ]; then
+  if [ "${ml_verbose}" = --verbose ]; then
+    echo "Creating multilib link (${with_multisubdir}) for the default library."
+    echo "pwd: `${PWDCMD-pwd}`"
+  fi
+
+  ml_origdir=`${PWDCMD-pwd}`
+  ml_libdir=`echo "$ml_origdir" | sed -e 's,^.*/,,'`
+  # cd to top-level-build-dir/${with_target_subdir}
+  cd ..
+
+  mkdir -p "${with_multisubdir}"
+  ln -sf "${ml_builddotdot_link}${ml_libdir}" "${with_multisubdir}/"
+  cd "${ml_origdir}"
+fi
+
 # We must freshly configure each subdirectory.  This bit of code is
 # actually partially stolen from the main configure script.  FIXME.
 
diff --git a/libgcc/config/loongarch/t-loongarch b/libgcc/config/loongarch/t-loongarch
index 2a7dbf6ca83..791a8c52f24 100644
--- a/libgcc/config/loongarch/t-loongarch
+++ b/libgcc/config/loongarch/t-loongarch
@@ -5,3 +5,19 @@ softfp_int_modes := si di
 softfp_extensions :=
 softfp_truncations :=
 softfp_exclude_libgcc2 := n
+
+# Since we employ a symmetric multilib layout, i.e. the default lib
+# always gets installed to its ${multisubdir} (see config-ml.in),
+# we need to copy it (again) into the GCC directory
+# (without the multilib suffix) in order to keep some regression
+# tests working (libstdc++), because "too many things knows
+# about the layout of the build tree" for now (libgcc/Makefile.in).
+
+# If we are on the top level (default library),
+# copy libgcc into gcc build directory.
+ifneq ($(MULTIDO),true)
+all: install-default-lib
+.PHONY: install-default-lib
+install-default-lib: libgcc.a
+	-$(LN_S) .$(MULTISUBDIR)/libgcc.a $(gcc_objdir)/libgcc.a
+endif
-- 
2.41.0


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-09-06  6:54 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14  3:57 [PATCH v1 1/6] LoongArch: a symmetric multilib subdir layout Yang Yujie
2023-08-14  3:57 ` [PATCH v1 2/6] LoongArch: improved target configuration interface Yang Yujie
2023-08-14  5:22   ` Xi Ruoyao
2023-08-15  1:12     ` Yujie Yang
2023-08-14  5:29   ` Xi Ruoyao
2023-08-14  5:58   ` Xi Ruoyao
2023-08-14  6:01     ` Xi Ruoyao
2023-08-14  8:44     ` Yujie Yang
2023-08-14  8:49       ` Xi Ruoyao
2023-08-14  8:57         ` Yujie Yang
2023-08-14  8:58           ` Xi Ruoyao
2023-09-06  6:43   ` Richard Sandiford
2023-09-06  6:54     ` Yang Yujie
2023-08-14  3:57 ` [PATCH v1 3/6] LoongArch: define preprocessing macros "__loongarch_{arch,tune}" Yang Yujie
2023-08-14  5:24   ` Xi Ruoyao
2023-08-14  3:57 ` [PATCH v1 4/6] LoongArch: use -mstrict-align by default when building libraries Yang Yujie
2023-08-14  5:18   ` Xi Ruoyao
2023-08-14  3:57 ` [PATCH v1 5/6] LoongArch: export headers for building GCC plugins Yang Yujie
2023-08-14  3:57 ` [PATCH v1 6/6] LoongArch: support loongarch*-elf target Yang Yujie
2023-08-14  5:38 ` [PATCH v1 1/6] LoongArch: a symmetric multilib subdir layout Xi Ruoyao
2023-08-14  5:40   ` Xi Ruoyao
2023-08-14  7:37   ` Yujie Yang
2023-08-14  7:48     ` Xi Ruoyao
2023-08-14 10:18       ` Yujie Yang
2023-08-14 11:16         ` Xi Ruoyao
2023-08-15  1:29           ` Xi Ruoyao
2023-08-15  2:32             ` Yujie Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).