Skip to content

Commit 017849d

Browse files
xry111chenglulu326
authored andcommitted
LoongArch: Fix multiarch tuple canonization
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).
1 parent a7d8c40 commit 017849d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

gcc/config.gcc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4889,20 +4889,16 @@ case "${target}" in
48894889
case ${target} in
48904890
loongarch64-*-*-*f64)
48914891
abi_pattern="lp64d"
4892-
triplet_abi="f64"
48934892
;;
48944893
loongarch64-*-*-*f32)
48954894
abi_pattern="lp64f"
4896-
triplet_abi="f32"
48974895
;;
48984896
loongarch64-*-*-*sf)
48994897
abi_pattern="lp64s"
4900-
triplet_abi="sf"
49014898
;;
49024899
loongarch64-*-*-*)
49034900
abi_pattern="lp64[dfs]"
49044901
abi_default="lp64d"
4905-
triplet_abi=""
49064902
;;
49074903
*)
49084904
echo "Unsupported target ${target}." 1>&2
@@ -4923,9 +4919,6 @@ case "${target}" in
49234919
;;
49244920
esac
49254921

4926-
la_canonical_triplet="loongarch64-${triplet_os}${triplet_abi}"
4927-
4928-
49294922
# Perform initial sanity checks on --with-* options.
49304923
case ${with_arch} in
49314924
"" | loongarch64 | la464) ;; # OK, append here.
@@ -4996,6 +4989,13 @@ case "${target}" in
49964989
;;
49974990
esac
49984991

4992+
case ${with_abi} in
4993+
"lp64d") triplet_abi="";;
4994+
"lp64f") triplet_abi="f32";;
4995+
"lp64s") triplet_abi="sf";;
4996+
esac
4997+
la_canonical_triplet="loongarch64-${triplet_os}${triplet_abi}"
4998+
49994999
# Set default value for with_abiext (internal)
50005000
case ${with_abiext} in
50015001
"")

gcc/config/loongarch/t-linux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),)
4040

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

4545
MULTILIB_OSDIRNAMES += \
4646
mabi.lp64f=../lib64/f32$\

0 commit comments

Comments
 (0)