summaryrefslogtreecommitdiff
path: root/etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch
blob: ea62d6bcfe2e0d7d6230e6e5bd7f94dbbbfe2e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From 32088af3619e49aecec44260d594fdcf590bfe00 Mon Sep 17 00:00:00 2001
From: Oliver Reiche <oliver.reiche@huawei.com>
Date: Wed, 19 Jul 2023 11:55:37 +0200
Subject: [PATCH] config.guess: Detect glibc via __GLIBC__

Backport from GCC 11.1.0
  Git commit: 53a90650663e59948f86505660604b5769cf808c and
              74af13c174714dd3b9f1ded4b39955f003c16361

Co-authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
---
 config.guess | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/config.guess b/config.guess
index 081f4c8b7..3d378a144 100755
--- a/config.guess
+++ b/config.guess
@@ -144,9 +144,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
 case "$UNAME_SYSTEM" in
 Linux|GNU|GNU/*)
-	# If the system lacks a compiler, then just pick glibc.
-	# We could probably try harder.
-	LIBC=gnu
+	LIBC=unknown
 
 	eval $set_cc_for_build
 	cat <<-EOF > "$dummy.c"
@@ -155,17 +153,29 @@ Linux|GNU|GNU/*)
 	LIBC=uclibc
 	#elif defined(__dietlibc__)
 	LIBC=dietlibc
-	#else
+	#elif defined(__GLIBC__)
 	LIBC=gnu
+	#else
+	#include <stdarg.h>
+ 	/* First heuristic to detect musl libc.  */
+	#ifdef __DEFINED_va_list
+	LIBC=musl
+	#endif
 	#endif
 	EOF
-	eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+	eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
 
-	# If ldd exists, use it to detect musl libc.
-	if command -v ldd >/dev/null && \
-		ldd --version 2>&1 | grep -q ^musl
-	then
-	    LIBC=musl
+	# Second heuristic to detect musl libc.
+	if [ "$LIBC" = unknown ] &&
+	   command -v ldd >/dev/null &&
+	   ldd --version 2>&1 | grep -q ^musl; then
+		LIBC=musl
+	fi
+
+	# If the system lacks a compiler, then just pick glibc.
+	# We could probably try harder.
+	if [ "$LIBC" = unknown ]; then
+		LIBC=gnu
 	fi
 	;;
 esac
-- 
2.30.2