v29.4-roots.1 · Commit 1: [PATCH 01/13] build: port platform and dependency support
cmake/introspection.cmake
Before: cmake/introspection.cmake · After: cmake/introspection.cmake
File metadata
index d4ed4866b9c4d4501ff9c7c7f1edfc8a5e6dea78..0bb852fa175e73c376be8f4d5fe07f7c49d0e555 100644
Download original patch · Release notes
Diff rows 1–173 of 173. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
cmake/introspection.cmake
CHANGED
|
@@ -102,6 +102,35 @@ check_cxx_source_compiles("
|
|
| 102 |
" HAVE_SOCKADDR_UN
|
| 103 |
)
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
# Check for different ways of gathering OS randomness:
|
| 106 |
# - Linux getrandom()
|
| 107 |
check_cxx_source_compiles("
|
|
@@ -164,9 +193,16 @@ if(NOT MSVC)
|
|
| 164 |
|
| 165 |
# Check for SSE4.1 intrinsics.
|
| 166 |
set(SSE41_CXXFLAGS -msse4.1)
|
| 167 |
-
check_cxx_source_compiles_with_flags("
|
| 168 |
#include <immintrin.h>
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
int main()
|
| 171 |
{
|
| 172 |
__m128i a = _mm_set1_epi32(0);
|
|
@@ -174,31 +210,51 @@ if(NOT MSVC)
|
|
| 174 |
__m128i r = _mm_blend_epi16(a, b, 0xFF);
|
| 175 |
return _mm_extract_epi32(r, 3);
|
| 176 |
}
|
| 177 |
-
" HAVE_SSE41
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
CXXFLAGS ${SSE41_CXXFLAGS}
|
| 179 |
)
|
| 180 |
set(ENABLE_SSE41 ${HAVE_SSE41})
|
| 181 |
|
| 182 |
# Check for AVX2 intrinsics.
|
| 183 |
set(AVX2_CXXFLAGS -mavx -mavx2)
|
| 184 |
-
check_cxx_source_compiles_with_flags("
|
| 185 |
#include <immintrin.h>
|
| 186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
int main()
|
| 188 |
{
|
| 189 |
__m256i l = _mm256_set1_epi32(0);
|
| 190 |
return _mm256_extract_epi32(l, 7);
|
| 191 |
}
|
| 192 |
-
" HAVE_AVX2
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
CXXFLAGS ${AVX2_CXXFLAGS}
|
| 194 |
)
|
| 195 |
set(ENABLE_AVX2 ${HAVE_AVX2})
|
| 196 |
|
| 197 |
# Check for x86 SHA-NI intrinsics.
|
| 198 |
set(X86_SHANI_CXXFLAGS -msse4 -msha)
|
| 199 |
-
check_cxx_source_compiles_with_flags("
|
| 200 |
#include <immintrin.h>
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
int main()
|
| 203 |
{
|
| 204 |
__m128i i = _mm_set1_epi32(0);
|
|
@@ -206,16 +262,26 @@ if(NOT MSVC)
|
|
| 206 |
__m128i k = _mm_set1_epi32(2);
|
| 207 |
return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, j, k), 0);
|
| 208 |
}
|
| 209 |
-
" HAVE_X86_SHANI
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
CXXFLAGS ${X86_SHANI_CXXFLAGS}
|
| 211 |
)
|
| 212 |
set(ENABLE_X86_SHANI ${HAVE_X86_SHANI})
|
| 213 |
|
| 214 |
# Check for ARMv8 SHA-NI intrinsics.
|
| 215 |
set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto)
|
| 216 |
-
check_cxx_source_compiles_with_flags("
|
| 217 |
#include <arm_neon.h>
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
int main()
|
| 220 |
{
|
| 221 |
uint32x4_t a, b, c;
|
|
@@ -224,8 +290,37 @@ if(NOT MSVC)
|
|
| 224 |
vsha256su0q_u32(a, b);
|
| 225 |
vsha256su1q_u32(a, b, c);
|
| 226 |
}
|
| 227 |
-
" HAVE_ARM_SHANI
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
CXXFLAGS ${ARM_SHANI_CXXFLAGS}
|
| 229 |
)
|
| 230 |
set(ENABLE_ARM_SHANI ${HAVE_ARM_SHANI})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
endif()
|
|
|
|
| 102 |
" HAVE_SOCKADDR_UN
|
| 103 |
)
|
| 104 |
|
| 105 |
+
# Check for close_range().
|
| 106 |
+
# NOTE: At least FreeBSD supports the generic variant.
|
| 107 |
+
check_cxx_source_compiles("
|
| 108 |
+
// same as in src/util/subprocess.cpp
|
| 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_GENERIC
|
| 117 |
+
)
|
| 118 |
+
if(NOT HAVE_CLOSE_RANGE_GENERIC)
|
| 119 |
+
check_cxx_source_compiles("
|
| 120 |
+
// same as in src/util/subprocess.cpp
|
| 121 |
+
#define _GNU_SOURCE
|
| 122 |
+
#include <linux/close_range.h>
|
| 123 |
+
#include <limits.h>
|
| 124 |
+
#include <unistd.h>
|
| 125 |
+
|
| 126 |
+
int main()
|
| 127 |
+
{
|
| 128 |
+
return close_range(3, UINT_MAX, 0);
|
| 129 |
+
}
|
| 130 |
+
" HAVE_CLOSE_RANGE_LINUX
|
| 131 |
+
)
|
| 132 |
+
endif()
|
| 133 |
+
|
| 134 |
# Check for different ways of gathering OS randomness:
|
| 135 |
# - Linux getrandom()
|
| 136 |
check_cxx_source_compiles("
|
|
|
|
| 193 |
|
| 194 |
# Check for SSE4.1 intrinsics.
|
| 195 |
set(SSE41_CXXFLAGS -msse4.1)
|
| 196 |
+
check_cxx_source_compiles_with_flags([[
|
| 197 |
#include <immintrin.h>
|
| 198 |
|
| 199 |
+
#if defined(__clang__)
|
| 200 |
+
#pragma clang attribute push(__attribute__((__target__("sse4.1"))), apply_to = function)
|
| 201 |
+
__attribute__((__target__("arch=skylake-avx512")))
|
| 202 |
+
#elif defined(__GNUC__)
|
| 203 |
+
#pragma GCC target ("sse4.1")
|
| 204 |
+
#endif
|
| 205 |
+
|
| 206 |
int main()
|
| 207 |
{
|
| 208 |
__m128i a = _mm_set1_epi32(0);
|
|
|
|
| 210 |
__m128i r = _mm_blend_epi16(a, b, 0xFF);
|
| 211 |
return _mm_extract_epi32(r, 3);
|
| 212 |
}
|
| 213 |
+
|
| 214 |
+
#if defined(__clang__)
|
| 215 |
+
#pragma clang attribute pop
|
| 216 |
+
#endif
|
| 217 |
+
]] HAVE_SSE41
|
| 218 |
CXXFLAGS ${SSE41_CXXFLAGS}
|
| 219 |
)
|
| 220 |
set(ENABLE_SSE41 ${HAVE_SSE41})
|
| 221 |
|
| 222 |
# Check for AVX2 intrinsics.
|
| 223 |
set(AVX2_CXXFLAGS -mavx -mavx2)
|
| 224 |
+
check_cxx_source_compiles_with_flags([[
|
| 225 |
#include <immintrin.h>
|
| 226 |
|
| 227 |
+
#if defined(__clang__)
|
| 228 |
+
#pragma clang attribute push(__attribute__((__target__("avx,avx2"))), apply_to = function)
|
| 229 |
+
#elif defined(__GNUC__)
|
| 230 |
+
#pragma GCC target ("avx,avx2")
|
| 231 |
+
#endif
|
| 232 |
+
|
| 233 |
int main()
|
| 234 |
{
|
| 235 |
__m256i l = _mm256_set1_epi32(0);
|
| 236 |
return _mm256_extract_epi32(l, 7);
|
| 237 |
}
|
| 238 |
+
|
| 239 |
+
#if defined(__clang__)
|
| 240 |
+
#pragma clang attribute pop
|
| 241 |
+
#endif
|
| 242 |
+
]] HAVE_AVX2
|
| 243 |
CXXFLAGS ${AVX2_CXXFLAGS}
|
| 244 |
)
|
| 245 |
set(ENABLE_AVX2 ${HAVE_AVX2})
|
| 246 |
|
| 247 |
# Check for x86 SHA-NI intrinsics.
|
| 248 |
set(X86_SHANI_CXXFLAGS -msse4 -msha)
|
| 249 |
+
check_cxx_source_compiles_with_flags([[
|
| 250 |
#include <immintrin.h>
|
| 251 |
|
| 252 |
+
#if defined(__clang__)
|
| 253 |
+
#pragma clang attribute push(__attribute__((__target__("sse4,sse4.1,sha"))), apply_to = function)
|
| 254 |
+
#elif defined(__GNUC__)
|
| 255 |
+
#pragma GCC target ("sse4,sse4.1,sha")
|
| 256 |
+
#endif
|
| 257 |
+
|
| 258 |
int main()
|
| 259 |
{
|
| 260 |
__m128i i = _mm_set1_epi32(0);
|
|
|
|
| 262 |
__m128i k = _mm_set1_epi32(2);
|
| 263 |
return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, j, k), 0);
|
| 264 |
}
|
| 265 |
+
|
| 266 |
+
#if defined(__clang__)
|
| 267 |
+
#pragma clang attribute pop
|
| 268 |
+
#endif
|
| 269 |
+
]] HAVE_X86_SHANI
|
| 270 |
CXXFLAGS ${X86_SHANI_CXXFLAGS}
|
| 271 |
)
|
| 272 |
set(ENABLE_X86_SHANI ${HAVE_X86_SHANI})
|
| 273 |
|
| 274 |
# Check for ARMv8 SHA-NI intrinsics.
|
| 275 |
set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto)
|
| 276 |
+
check_cxx_source_compiles_with_flags([[
|
| 277 |
#include <arm_neon.h>
|
| 278 |
|
| 279 |
+
#if defined(__clang__)
|
| 280 |
+
#pragma clang attribute push(__attribute__((__target__("armv8-a+crypto"))), apply_to = function)
|
| 281 |
+
#elif defined(__GNUC__)
|
| 282 |
+
#pragma GCC target ("armv8-a+crypto")
|
| 283 |
+
#endif
|
| 284 |
+
|
| 285 |
int main()
|
| 286 |
{
|
| 287 |
uint32x4_t a, b, c;
|
|
|
|
| 290 |
vsha256su0q_u32(a, b);
|
| 291 |
vsha256su1q_u32(a, b, c);
|
| 292 |
}
|
| 293 |
+
|
| 294 |
+
#if defined(__clang__)
|
| 295 |
+
#pragma clang attribute pop
|
| 296 |
+
#endif
|
| 297 |
+
]] HAVE_ARM_SHANI
|
| 298 |
CXXFLAGS ${ARM_SHANI_CXXFLAGS}
|
| 299 |
)
|
| 300 |
set(ENABLE_ARM_SHANI ${HAVE_ARM_SHANI})
|
| 301 |
+
|
| 302 |
+
# Check for POWER8 vector intrinsics.
|
| 303 |
+
function(check_power8_vector VAR)
|
| 304 |
+
check_cxx_source_compiles_with_flags([[
|
| 305 |
+
#include <altivec.h>
|
| 306 |
+
#include <stdint.h>
|
| 307 |
+
|
| 308 |
+
int main()
|
| 309 |
+
{
|
| 310 |
+
unsigned char src[16];
|
| 311 |
+
__builtin_crypto_vshasigmaw((__vector uint32_t)vec_vsx_ld(0, src), 1, 0xf);
|
| 312 |
+
return 0;
|
| 313 |
+
}
|
| 314 |
+
]] ${VAR}
|
| 315 |
+
CXXFLAGS ${POWER8_CXXFLAGS}
|
| 316 |
+
)
|
| 317 |
+
endfunction()
|
| 318 |
+
set(POWER8_CXXFLAGS -mpower8-vector)
|
| 319 |
+
check_power8_vector(HAVE_POWER8_VECTOR)
|
| 320 |
+
set(ENABLE_POWER8 ${HAVE_POWER8_VECTOR})
|
| 321 |
+
if(NOT HAVE_POWER8_VECTOR)
|
| 322 |
+
set(POWER8_CXXFLAGS -mcpu=power8)
|
| 323 |
+
check_power8_vector(HAVE_MCPU_POWER8_FOR_VECTOR)
|
| 324 |
+
set(ENABLE_POWER8 ${HAVE_MCPU_POWER8_FOR_VECTOR})
|
| 325 |
+
endif()
|
| 326 |
endif()
|