[PATCH] D130820: [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:55:18 PDT 2022


xen0n updated this revision to Diff 448849.
xen0n added a comment.

Fix libc detection; the 2011 script is not initializing $LIBC beforehand.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130820/new/

https://reviews.llvm.org/D130820

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: D130820.448849.patch
Type: text/x-patch
Size: 1000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220731/a8ca9e3e/attachment.bin>


More information about the llvm-commits mailing list