[PATCH] D130836: [cmake] Add LoongArch to config.guess

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 31 03:52:40 PDT 2022


xen0n created this revision.
Herald added subscribers: luke957, luismarques, s.egerton, PkmX, simoncook, arichardson, mgorny.
Herald added a project: All.
xen0n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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 implements the same logic 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. libc detection is also done differently (the code is copied from
RISC-V as it's the same).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130836

Files:
  llvm/cmake/config.guess


Index: llvm/cmake/config.guess
===================================================================
--- llvm/cmake/config.guess
+++ llvm/cmake/config.guess
@@ -922,6 +922,30 @@
     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 ;;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130836.448848.patch
Type: text/x-patch
Size: 1000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220731/73cf51e7/attachment.bin>


More information about the llvm-commits mailing list