Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoongArch: prevent building duplicate "default" multilib. #70

Open
wants to merge 1 commit into
base: loongarch-12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion config-ml.in
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,20 @@ 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`
ml_subdir="/${with_multisubdir}"
ml_builddotdot=
;;
msp430-*-*)
if [ x$enable_no_exceptions = xno ]
then
Expand Down Expand Up @@ -509,7 +523,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 \
Expand Down Expand Up @@ -595,6 +609,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.
Expand Down Expand Up @@ -654,6 +674,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.

Expand Down
17 changes: 17 additions & 0 deletions gcc/config/loongarch/t-loongarch
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ $(LA_STR_H): \
$(srcdir)/config/loongarch/genopts/genstr.sh \
$(srcdir)/config/loongarch/genopts/loongarch-strings
$(SHELL) $< header > $@


# Post-processing on multilib.h: remove "." if multilib is enabled
$(foreach abi_base, lp64d lp64f lp64s, \
$(if $(filter DEFAULT_ABI_BASE=$\
ABI_BASE_$(shell echo $(abi_base) | tr 'a-z' 'A-Z'), $(tm_defines)), \
$(eval la_default_multisubdir := base/$(abi_base)) \
)\
)

ifeq ($(filter __DISABLE_MULTILIB,$(tm_defines)),)
.PHONY: filter-ml-dot
multilib.h: filter-ml-dot
filter-ml-dot: s-mlib
sed -e '/"$(subst /,\/,$(la_default_multisubdir)):/ {h; s@ m@ !m@p; g}' \
-e '/\s*". [^";]*;"/ d' -i multilib.h
endif
16 changes: 16 additions & 0 deletions libgcc/config/loongarch/t-loongarch
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ softfp_truncations :=
softfp_exclude_libgcc2 := n

LIB2ADD_ST += $(srcdir)/config/loongarch/lib2funcs.c

# 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