Skip to content

Commit e01ea42

Browse files
committed
Port configure.ac changes to configure.py.
1 parent fe8592d commit e01ea42

File tree

6 files changed

+69
-21
lines changed

6 files changed

+69
-21
lines changed

Tools/configure/conf_buildopts.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,14 @@ def setup_dtrace(v):
535535
def setup_perf_trampoline(v):
536536
"""Check and configure perf trampoline support."""
537537
pyconf.checking("perf trampoline")
538-
if v.PLATFORM_TRIPLET in (
539-
"x86_64-linux-gnu",
540-
"aarch64-linux-gnu",
541-
"darwin",
542-
):
538+
if v.PLATFORM_TRIPLET in ("x86_64-linux-gnu", "aarch64-linux-gnu"):
543539
perf_trampoline = True
540+
elif v.PLATFORM_TRIPLET == "darwin":
541+
target = v.get("MACOSX_DEPLOYMENT_TARGET", "")
542+
if pyconf.fnmatch_any(target, ["10.[0-9]", "10.1[0-1]"]):
543+
perf_trampoline = False
544+
else:
545+
perf_trampoline = True
544546
else:
545547
perf_trampoline = False
546548
pyconf.result(perf_trampoline)

Tools/configure/conf_compiler.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,37 @@ def check_stdatomic(v):
558558
"Has builtin __atomic_load_n() and __atomic_store_n() functions",
559559
)
560560

561+
# Check for __builtin_shufflevector with 128-bit vector support on an
562+
# architecture where it compiles to worthwhile native SIMD instructions.
563+
# Used for SIMD-accelerated bytes.hex() in Python/pystrhex.c.
564+
pyconf.checking("for __builtin_shufflevector")
565+
ac_cv_efficient_builtin_shufflevector = pyconf.link_check(
566+
source=(
567+
"#if !defined(__x86_64__) && !defined(__aarch64__) && \\\n"
568+
" !(defined(__arm__) && defined(__ARM_NEON))\n"
569+
'# error "128-bit vector SIMD not worthwhile on this architecture"\n'
570+
"#endif\n"
571+
"typedef unsigned char v16u8 __attribute__((vector_size(16)));\n"
572+
"int main(void) {\n"
573+
" v16u8 a = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};\n"
574+
" v16u8 b = {16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};\n"
575+
" v16u8 c = __builtin_shufflevector(a, b,\n"
576+
" 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23);\n"
577+
" (void)c;\n"
578+
" return 0;\n"
579+
"}\n"
580+
),
581+
cache_var="ac_cv_efficient_builtin_shufflevector",
582+
)
583+
pyconf.result(ac_cv_efficient_builtin_shufflevector)
584+
if ac_cv_efficient_builtin_shufflevector:
585+
pyconf.define(
586+
"HAVE_EFFICIENT_BUILTIN_SHUFFLEVECTOR",
587+
1,
588+
"Define if compiler supports __builtin_shufflevector with 128-bit "
589+
"vectors AND the target architecture has native SIMD",
590+
)
591+
561592

562593
def check_sizes(v):
563594
"""Check sizeof/alignof for fundamental types and pthread types."""

Tools/configure/conf_math.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,11 @@ def _define_float_little():
9090

9191

9292
def _define_float_unknown():
93-
if "arm" in pyconf.host_cpu:
94-
pyconf.define(
95-
"DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754",
96-
1,
97-
"Define if C doubles are 64-bit IEEE 754 binary format, "
98-
"stored in ARM mixed-endian order (byte order 45670123)",
99-
)
100-
else:
101-
pyconf.error(
102-
"Unknown float word ordering. You need to manually "
103-
"preset ax_cv_c_float_words_bigendian=no (or yes) "
104-
"according to your system."
105-
)
93+
pyconf.error(
94+
"Unknown float word ordering. You need to manually "
95+
"preset ax_cv_c_float_words_bigendian=no (or yes) "
96+
"according to your system."
97+
)
10698

10799

108100
def check_gcc_asm_and_floating_point(v):

Tools/configure/conf_optimization.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ def setup_pgo_flags(v):
230230
"build but could not be found."
231231
)
232232
elif v.ac_cv_cc_name == "gcc":
233-
v.PGO_PROF_GEN_FLAG = "-fprofile-generate"
233+
if pyconf.check_compile_flag("-fprofile-update=atomic"):
234+
v.PGO_PROF_GEN_FLAG = "-fprofile-generate -fprofile-update=atomic"
235+
else:
236+
v.PGO_PROF_GEN_FLAG = "-fprofile-generate"
234237
v.PGO_PROF_USE_FLAG = "-fprofile-use -fprofile-correction"
235238
v.LLVM_PROF_MERGER = "true"
236239
v.LLVM_PROF_FILE = ""

Tools/configure/conf_platform.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,6 @@ def check_headers(v):
927927
"shadow.h",
928928
"signal.h",
929929
"spawn.h",
930-
"stropts.h",
931930
"sys/audioio.h",
932931
"sys/bsdtty.h",
933932
"sys/devpoll.h",
@@ -975,6 +974,25 @@ def check_headers(v):
975974
"utime.h",
976975
"utmp.h",
977976
)
977+
# On Linux, stropts.h may be empty
978+
pyconf.checking("whether stropts.h has I_PUSH")
979+
has_i_push = pyconf.compile_check(
980+
preamble=(
981+
"#ifdef HAVE_SYS_TYPES_H\n"
982+
"# include <sys/types.h>\n"
983+
"#endif\n"
984+
"#include <stropts.h>\n"
985+
),
986+
body="(void)I_PUSH",
987+
)
988+
pyconf.result(has_i_push)
989+
if has_i_push:
990+
pyconf.define(
991+
"HAVE_STROPTS_H",
992+
1,
993+
"Define to 1 if you have the <stropts.h> header file.",
994+
)
995+
978996
# AC_HEADER_DIRENT: check for dirent.h
979997
pyconf.check_headers("dirent.h")
980998

Tools/configure/conf_wasm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def setup_wasm_flags(v):
8383
v.export("CFLAGS_NODIST")
8484
v.export("LDFLAGS_NODIST")
8585
v.export("LDFLAGS_NOLTO")
86+
v.export("EXE_LDFLAGS")
8687
v.export("LINKFORSHARED")
8788
v.export("WASM_ASSETS_DIR")
8889
v.export("WASM_STDLIB")
@@ -104,7 +105,8 @@ def _setup_emscripten_flags(v):
104105
)
105106
v.LINKFORSHARED += (
106107
" -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,"
107-
"_PyGILState_GetThisThreadState,__Py_DumpTraceback"
108+
"_PyGILState_GetThisThreadState,__Py_DumpTraceback,"
109+
"__PyEM_EMSCRIPTEN_TRAMPOLINE_OFFSET"
108110
)
109111
v.LINKFORSHARED += " -sSTACK_SIZE=5MB"
110112
v.LINKFORSHARED += " -sTEXTDECODER=2"

0 commit comments

Comments
 (0)