Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 1: [PATCH 01/68] build: adapt Roots platform support to Core 30.3

cmake/introspection.cmake

Before: cmake/introspection.cmake · After: cmake/introspection.cmake

File metadata
index d22576339745fd4c221d12b32d3646ae741de6d8..5842cd581859faab7a7fd96ed2f14920ad2a31bb 100644

Download original patch · Release notes

Diff rows 1–170 of 170. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

cmake/introspection.cmake CHANGED
@@ -88,6 +88,35 @@ check_cxx_source_compiles("
88
88
  " HAVE_SOCKADDR_UN
89
89
  )
90
90
 
91
+ # Check for close_range().
92
+ # NOTE: At least FreeBSD supports the generic variant.
93
+ check_cxx_source_compiles("
94
+ // same as in src/util/subprocess.cpp
95
+ #include <limits.h>
96
+ #include <unistd.h>
97
+
98
+ int main()
99
+ {
100
+ return close_range(3, UINT_MAX, 0);
101
+ }
102
+ " HAVE_CLOSE_RANGE_GENERIC
103
+ )
104
+ if(NOT HAVE_CLOSE_RANGE_GENERIC)
105
+ check_cxx_source_compiles("
106
+ // same as in src/util/subprocess.cpp
107
+ #define _GNU_SOURCE
108
+ #include <linux/close_range.h>
109
+ #include <limits.h>
110
+ #include <unistd.h>
111
+
112
+ int main()
113
+ {
114
+ return close_range(3, UINT_MAX, 0);
115
+ }
116
+ " HAVE_CLOSE_RANGE_LINUX
117
+ )
118
+ endif()
119
+
91
120
  # Check for different ways of gathering OS randomness:
92
121
  # - Linux getrandom()
93
122
  check_cxx_source_compiles("
@@ -150,9 +179,16 @@ if(NOT MSVC)
150
179
 
151
180
  # Check for SSE4.1 intrinsics.
152
181
  set(SSE41_CXXFLAGS -msse4.1)
153
- check_cxx_source_compiles_with_flags("
182
+ check_cxx_source_compiles_with_flags([[
154
183
  #include <immintrin.h>
155
184
 
185
+ #if defined(__clang__)
186
+ #pragma clang attribute push(__attribute__((__target__("sse4.1"))), apply_to = function)
187
+ __attribute__((__target__("arch=skylake-avx512")))
188
+ #elif defined(__GNUC__)
189
+ #pragma GCC target ("sse4.1")
190
+ #endif
191
+
156
192
  int main()
157
193
  {
158
194
  __m128i a = _mm_set1_epi32(0);
@@ -160,29 +196,49 @@ if(NOT MSVC)
160
196
  __m128i r = _mm_blend_epi16(a, b, 0xFF);
161
197
  return _mm_extract_epi32(r, 3);
162
198
  }
163
- " HAVE_SSE41
199
+
200
+ #if defined(__clang__)
201
+ #pragma clang attribute pop
202
+ #endif
203
+ ]] HAVE_SSE41
164
204
  CXXFLAGS ${SSE41_CXXFLAGS}
165
205
  )
166
206
 
167
207
  # Check for AVX2 intrinsics.
168
208
  set(AVX2_CXXFLAGS -mavx -mavx2)
169
- check_cxx_source_compiles_with_flags("
209
+ check_cxx_source_compiles_with_flags([[
170
210
  #include <immintrin.h>
171
211
 
212
+ #if defined(__clang__)
213
+ #pragma clang attribute push(__attribute__((__target__("avx,avx2"))), apply_to = function)
214
+ #elif defined(__GNUC__)
215
+ #pragma GCC target ("avx,avx2")
216
+ #endif
217
+
172
218
  int main()
173
219
  {
174
220
  __m256i l = _mm256_set1_epi32(0);
175
221
  return _mm256_extract_epi32(l, 7);
176
222
  }
177
- " HAVE_AVX2
223
+
224
+ #if defined(__clang__)
225
+ #pragma clang attribute pop
226
+ #endif
227
+ ]] HAVE_AVX2
178
228
  CXXFLAGS ${AVX2_CXXFLAGS}
179
229
  )
180
230
 
181
231
  # Check for x86 SHA-NI intrinsics.
182
232
  set(X86_SHANI_CXXFLAGS -msse4 -msha)
183
- check_cxx_source_compiles_with_flags("
233
+ check_cxx_source_compiles_with_flags([[
184
234
  #include <immintrin.h>
185
235
 
236
+ #if defined(__clang__)
237
+ #pragma clang attribute push(__attribute__((__target__("sse4,sse4.1,sha"))), apply_to = function)
238
+ #elif defined(__GNUC__)
239
+ #pragma GCC target ("sse4,sse4.1,sha")
240
+ #endif
241
+
186
242
  int main()
187
243
  {
188
244
  __m128i i = _mm_set1_epi32(0);
@@ -190,15 +246,25 @@ if(NOT MSVC)
190
246
  __m128i k = _mm_set1_epi32(2);
191
247
  return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, j, k), 0);
192
248
  }
193
- " HAVE_X86_SHANI
249
+
250
+ #if defined(__clang__)
251
+ #pragma clang attribute pop
252
+ #endif
253
+ ]] HAVE_X86_SHANI
194
254
  CXXFLAGS ${X86_SHANI_CXXFLAGS}
195
255
  )
196
256
 
197
257
  # Check for ARMv8 SHA-NI intrinsics.
198
258
  set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto)
199
- check_cxx_source_compiles_with_flags("
259
+ check_cxx_source_compiles_with_flags([[
200
260
  #include <arm_neon.h>
201
261
 
262
+ #if defined(__clang__)
263
+ #pragma clang attribute push(__attribute__((__target__("armv8-a+crypto"))), apply_to = function)
264
+ #elif defined(__GNUC__)
265
+ #pragma GCC target ("armv8-a+crypto")
266
+ #endif
267
+
202
268
  int main()
203
269
  {
204
270
  uint32x4_t a, b, c;
@@ -207,7 +273,37 @@ if(NOT MSVC)
207
273
  vsha256su0q_u32(a, b);
208
274
  vsha256su1q_u32(a, b, c);
209
275
  }
210
- " HAVE_ARM_SHANI
276
+
277
+ #if defined(__clang__)
278
+ #pragma clang attribute pop
279
+ #endif
280
+ ]] HAVE_ARM_SHANI
211
281
  CXXFLAGS ${ARM_SHANI_CXXFLAGS}
212
282
  )
283
+ set(ENABLE_ARM_SHANI ${HAVE_ARM_SHANI})
284
+
285
+ # Check for POWER8 vector intrinsics.
286
+ function(check_power8_vector VAR)
287
+ check_cxx_source_compiles_with_flags([[
288
+ #include <altivec.h>
289
+ #include <stdint.h>
290
+
291
+ int main()
292
+ {
293
+ unsigned char src[16];
294
+ __builtin_crypto_vshasigmaw((__vector uint32_t)vec_vsx_ld(0, src), 1, 0xf);
295
+ return 0;
296
+ }
297
+ ]] ${VAR}
298
+ CXXFLAGS ${POWER8_CXXFLAGS}
299
+ )
300
+ endfunction()
301
+ set(POWER8_CXXFLAGS -mpower8-vector)
302
+ check_power8_vector(HAVE_POWER8_VECTOR)
303
+ set(ENABLE_POWER8 ${HAVE_POWER8_VECTOR})
304
+ if(NOT HAVE_POWER8_VECTOR)
305
+ set(POWER8_CXXFLAGS -mcpu=power8)
306
+ check_power8_vector(HAVE_MCPU_POWER8_FOR_VECTOR)
307
+ set(ENABLE_POWER8 ${HAVE_MCPU_POWER8_FOR_VECTOR})
308
+ endif()
213
309
  endif()