summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc/0038-libatomic-libgomp-libitc-Fix-bootstrap-PR70454.patch
blob: 65c3e398fe21be1758d25a6f81738352cc20c627 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
From eb5a17c7b8ed676d83ce4dd0e9623e2ee0191f91 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Fri, 15 Jan 2021 13:12:59 +0100
Subject: [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454]

The recent changes to error on mixing -march=i386 and -fcf-protection broke
bootstrap.  This patch changes lib{atomic,gomp,itm} configury, so that it
only adds -march=i486 to flags if really needed (i.e. when 486 or later isn't
on by default already).  Similarly, it will not use ifuncs if -mcx16
(or -march=i686 for 32-bit) is on by default.

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR target/70454
libatomic/
	* configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
	be added through preprocessor check on
	__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.  Determine if try_ifunc is needed
	based on preprocessor check on __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
	or __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8.
libgomp/
	* configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
	be added through preprocessor check on
	__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.
libitm/
	* configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
	be added through preprocessor check on
	__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.

Upstream-Status: Backport [master post 10.x release]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 libatomic/configure.tgt | 56 +++++++++++++++++++++++------------------
 libgomp/configure.tgt   | 35 +++++++++++---------------
 libitm/configure.tgt    | 37 +++++++++++++--------------
 3 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index 5dd0926d207..6ea082a29bc 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -81,32 +81,40 @@ case "${target_cpu}" in
 	ARCH=sparc
 	;;
 
-  i[3456]86)
-	case " ${CC} ${CFLAGS} " in
-	  *" -m64 "*|*" -mx32 "*)
-	    ;;
-	  *)
-	    if test -z "$with_arch"; then
-	      XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
-	      XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-	    fi
-	esac
-	ARCH=x86
-	# ??? Detect when -march=i686 is already enabled.
-	try_ifunc=yes
-	;;
-  x86_64)
-	case " ${CC} ${CFLAGS} " in
-	  *" -m32 "*)
+  i[3456]86 | x86_64)
+	cat > conftestx.c <<EOF
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#error need -march=i486
+#endif
+EOF
+	if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+	  :
+	else
+	  if test "${target_cpu}" = x86_64; then
 	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
-	    XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-	    ;;
-	  *)
-	    ;;
-	esac
+	  else
+	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+	  fi
+	  XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+	fi
+	cat > conftestx.c <<EOF
+#ifdef __x86_64__
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
+#error need -mcx16
+#endif
+#else
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+#error need -march=i686
+#endif
+#endif
+EOF
+	if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+	  try_ifunc=no
+	else
+	  try_ifunc=yes
+	fi
+	rm -f conftestx.c
 	ARCH=x86
-	# ??? Detect when -mcx16 is already enabled.
-	try_ifunc=yes
 	;;
 
   *)			ARCH="${target_cpu}" ;;
diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
index 4790a31e394..761ef2a7db2 100644
--- a/libgomp/configure.tgt
+++ b/libgomp/configure.tgt
@@ -70,28 +70,23 @@ if test x$enable_linux_futex = xyes; then
 	;;
 
     # Note that bare i386 is not included here.  We need cmpxchg.
-    i[456]86-*-linux*)
+    i[456]86-*-linux* | x86_64-*-linux*)
 	config_path="linux/x86 linux posix"
-	case " ${CC} ${CFLAGS} " in
-	  *" -m64 "*|*" -mx32 "*)
-	    ;;
-	  *)
-	    if test -z "$with_arch"; then
-	      XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
-	    fi
-	esac
-	;;
-
-    # Similar jiggery-pokery for x86_64 multilibs, except here we
-    # can't rely on the --with-arch configure option, since that
-    # applies to the 64-bit side.
-    x86_64-*-linux*)
-	config_path="linux/x86 linux posix"
-	case " ${CC} ${CFLAGS} " in
-	  *" -m32 "*)
+	cat > conftestx.c <<EOF
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#error need -march=i486
+#endif
+EOF
+	if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+	  :
+	else
+	  if test "${target_cpu}" = x86_64; then
 	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
-	    ;;
-	esac
+	  else
+	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+	  fi
+	fi
+	rm -f conftestx.c
 	;;
 
     # Note that sparcv7 and sparcv8 is not included here.  We need cas.
diff --git a/libitm/configure.tgt b/libitm/configure.tgt
index d1beb5c9ec8..608462e184e 100644
--- a/libitm/configure.tgt
+++ b/libitm/configure.tgt
@@ -59,16 +59,23 @@ case "${target_cpu}" in
 
   arm*)		ARCH=arm ;;
 
-  i[3456]86)
-	case " ${CC} ${CFLAGS} " in
-	  *" -m64 "*|*" -mx32 "*)
-	    ;;
-	  *)
-	    if test -z "$with_arch"; then
-	      XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
-	      XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-	    fi
-	esac
+  i[3456]86 | x86_64)
+	cat > conftestx.c <<EOF
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#error need -march=i486
+#endif
+EOF
+	if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+	  :
+	else
+	  if test "${target_cpu}" = x86_64; then
+	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
+	  else
+	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+	  fi
+	  XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+	fi
+	rm -f conftestx.c
 	XCFLAGS="${XCFLAGS} -mrtm"
 	ARCH=x86
 	;;
@@ -103,16 +110,6 @@ case "${target_cpu}" in
 	ARCH=sparc
 	;;
 
-  x86_64)
-	case " ${CC} ${CFLAGS} " in
-	  *" -m32 "*)
-	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
-	    XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-	    ;;
-	esac
-	XCFLAGS="${XCFLAGS} -mrtm"
-	ARCH=x86
-	;;
   s390|s390x)
 	XCFLAGS="${XCFLAGS} -mzarch -mhtm"
 	ARCH=s390