Skip to content

Commit

Permalink
LoongArch: Fix multiarch tuple canonization
Browse files Browse the repository at this point in the history
Multiarch tuple will be coded in file or directory names in
multiarch-aware distros, so one ABI should have only one multiarch
tuple.  For example, "--target=loongarch64-linux-gnu --with-abi=lp64s"
and "--target=loongarch64-linux-gnusf" should both set multiarch tuple
to "loongarch64-linux-gnusf".  Before this commit,
"--target=loongarch64-linux-gnu --with-abi=lp64s --disable-multilib"
will produce wrong result (loongarch64-linux-gnu).

A recent LoongArch psABI revision mandates "loongarch64-linux-gnu" to be
used for -mabi=lp64d (instead of "loongarch64-linux-gnuf64") for some
non-technical reason [1].  Note that we cannot make
"loongarch64-linux-gnuf64" an alias for "loongarch64-linux-gnu" because
to implement such an alias, we must create thousands of symlinks in the
distro and doing so would be completely unpractical.  This commit also
aligns GCC with the revision.

Tested by building cross compilers with --enable-multiarch and multiple
combinations of --target=loongarch64-linux-gnu*, --with-abi=lp64{s,f,d},
and --{enable,disable}-multilib; and run "xgcc --print-multiarch" then
manually verify the result with eyesight.

[1]: loongson/LoongArch-Documentation#80

gcc/ChangeLog:

	* config.gcc (triplet_abi): Set its value based on $with_abi,
	instead of $target.
	(la_canonical_triplet): Set it after $triplet_abi is set
	correctly.
	* config/loongarch/t-linux (MULTILIB_OSDIRNAMES): Make the
	multiarch tuple for lp64d "loongarch64-linux-gnu" (without
	"f64" suffix).
  • Loading branch information
xry111 authored and CohenArthur committed Feb 23, 2023
1 parent bbd67cf commit 5f2d0f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions gcc/config.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -4936,20 +4936,16 @@ case "${target}" in
case ${target} in
loongarch64-*-*-*f64)
abi_pattern="lp64d"
triplet_abi="f64"
;;
loongarch64-*-*-*f32)
abi_pattern="lp64f"
triplet_abi="f32"
;;
loongarch64-*-*-*sf)
abi_pattern="lp64s"
triplet_abi="sf"
;;
loongarch64-*-*-*)
abi_pattern="lp64[dfs]"
abi_default="lp64d"
triplet_abi=""
;;
*)
echo "Unsupported target ${target}." 1>&2
Expand All @@ -4970,9 +4966,6 @@ case "${target}" in
;;
esac

la_canonical_triplet="loongarch64-${triplet_os}${triplet_abi}"


# Perform initial sanity checks on --with-* options.
case ${with_arch} in
"" | loongarch64 | la464) ;; # OK, append here.
Expand Down Expand Up @@ -5043,6 +5036,13 @@ case "${target}" in
;;
esac

case ${with_abi} in
"lp64d") triplet_abi="";;
"lp64f") triplet_abi="f32";;
"lp64s") triplet_abi="sf";;
esac
la_canonical_triplet="loongarch64-${triplet_os}${triplet_abi}"

# Set default value for with_abiext (internal)
case ${with_abiext} in
"")
Expand Down
2 changes: 1 addition & 1 deletion gcc/config/loongarch/t-linux
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),)

MULTILIB_OSDIRNAMES = \
mabi.lp64d=../lib64$\
$(call if_multiarch,:loongarch64-linux-gnuf64)
$(call if_multiarch,:loongarch64-linux-gnu)

MULTILIB_OSDIRNAMES += \
mabi.lp64f=../lib64/f32$\
Expand Down

0 comments on commit 5f2d0f3

Please sign in to comment.