[cmake] Add LoongArch to config.guess

Necessary for native builds on LoongArch. Only Linux is added for now,
matching upstream config.git changes.

Unfortunately, the upstream config.guess is GPLv3+ since 2012, and
LLVM is without autoconf support for a long time, so the script's
licensing exception no longer works and a bump could not be trivially
done.

This is the same as the [upstream commit adding LoongArch](https://git.savannah.gnu.org/gitweb/?p=config.git;a=commitdiff;h=c8ddc8472f8efcadafc1ef53ca1d863415fddd5f),
but rewritten to match the 2011 style that our script is holding on
to.

Differential Revision: https://reviews.llvm.org/D130820
This commit is contained in:
WANG Xuerui 2022-08-01 15:04:54 +08:00 committed by Weining Lu
parent 7b0f6378e2
commit e48a0df3fc
1 changed files with 24 additions and 0 deletions

View File

@ -922,6 +922,30 @@ EOF
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
# Do not check for __GLIBC__ because uclibc defines it too
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
# There is no features test macro for musl
# Follow the GNU's config.guess approach of
# checking the output of ldd
if command -v ldd >/dev/null && \
ldd --version 2>&1 | grep -q ^musl; then
LIBC=musl
fi
echo "${UNAME_MACHINE}-unknown-linux-${LIBC}"
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;