llvm/D68899-de1c2877a9ff12899ef5...

53 lines
1.6 KiB
Diff

From de1c2877a9ff12899ef50e179ade748fba8ab0c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lu=C3=ADs=20Marques?= <luismarques@lowrisc.org>
Date: Fri, 14 Feb 2020 11:49:18 +0000
Subject: [PATCH] llvm/cmake/config.guess: add support for riscv32 and riscv64
Summary: LLVM configuration fails with 'unable to guess system type' on riscv64.
Add support for detecting riscv32 and riscv64 systems.
Patch by Gokturk Yuksek (gokturk)
Reviewers: erichkeane, rengolin, mgorny, aaron.ballman, beanz, luismarques
Reviewed By: luismarques
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68899
---
llvm/cmake/config.guess | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/llvm/cmake/config.guess b/llvm/cmake/config.guess
index ccb30f4e75e8..26d120601e49 100644
--- a/llvm/cmake/config.guess
+++ b/llvm/cmake/config.guess
@@ -973,6 +973,30 @@ EOF
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
+ riscv32:Linux:*:* | riscv64: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 ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit ;;