[PATCH v1 1/6] LoongArch: a symmetric multilib subdir layout
Yang Yujie
yangyujie@loongson.cn
Mon Aug 14 03:57:02 GMT 2023
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
More information about the Gcc-patches
mailing list