Skip to content

Commit 15db13f

Browse files
committed
Review conf_math.py: fix __fpu_control order, libmpdec bug flags scope, and wchar.h double-define.
- check_math_library: move __fpu_control check before --with-libm/--with-libc to match configure.ac order (AC_CHECK_FUNC at line 6134, before AC_SUBST LIBM) - detect_libmpdec: have_ipa_pure_const_bug and have_glibc_memmove_bug CFLAGS appends were inside the bundled-only block; configure.ac applies them unconditionally regardless of with_system_libmpdec - check_wchar: use autodefine=False for check_header("wchar.h") to avoid double-defining HAVE_WCHAR_H (autodefine would define it with a generic description, then the explicit define overwrote it) Assisted-by: Claude
1 parent c6a88ab commit 15db13f

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

Tools/configure/conf_math.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ def check_math_library(v):
3131
# Math library: --with-libm and --with-libc
3232
# ---------------------------------------------------------------------------
3333

34+
# Linux: __fpu_control (AC_CHECK_FUNC with custom action → no HAVE_ define)
35+
pyconf.checking("for __fpu_control")
36+
found = pyconf.check_func("__fpu_control", autodefine=False)
37+
pyconf.result(found)
38+
if not found:
39+
pyconf.check_lib("ieee", "__fpu_control")
40+
3441
v.export("LIBM") # registered for Makefile substitution
3542
# Linux requires this for correct floating-point operations
36-
# (Note: AC_CHECK_FUNC with custom action, no HAVE_ define)
3743

3844
if v.ac_sys_system != "Darwin":
3945
v.LIBM = "-lm"
@@ -70,13 +76,6 @@ def check_math_library(v):
7076
else:
7177
pyconf.result(f'default LIBC="{v.LIBC}"')
7278

73-
# Linux: __fpu_control (AC_CHECK_FUNC with custom action → no HAVE_ define)
74-
pyconf.checking("for __fpu_control")
75-
found = pyconf.check_func("__fpu_control", autodefine=False)
76-
pyconf.result(found)
77-
if not found:
78-
pyconf.check_lib("ieee", "__fpu_control")
79-
8079

8180
def _define_float_big():
8281
pyconf.define(
@@ -295,7 +294,10 @@ def check_wchar(v):
295294

296295
# Check for wchar.h
297296
pyconf.checking("for wchar.h")
298-
has_wchar = pyconf.check_header("wchar.h")
297+
has_wchar = pyconf.check_header(
298+
"wchar.h",
299+
autodefine=False,
300+
)
299301
pyconf.result(has_wchar)
300302
if has_wchar:
301303
pyconf.define(
@@ -503,16 +505,16 @@ def detect_libmpdec(v):
503505
elif libmpdec_machine == "unknown":
504506
pyconf.fatal("_decimal: unsupported architecture")
505507

506-
if v.have_ipa_pure_const_bug:
507-
# Some versions of gcc miscompile inline asm:
508-
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
509-
# https://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
510-
v.LIBMPDEC_CFLAGS += " -fno-ipa-pure-const"
508+
if v.have_ipa_pure_const_bug:
509+
# Some versions of gcc miscompile inline asm:
510+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
511+
# https://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
512+
v.LIBMPDEC_CFLAGS += " -fno-ipa-pure-const"
511513

512-
if v.have_glibc_memmove_bug:
513-
# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
514-
# https://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
515-
v.LIBMPDEC_CFLAGS += " -U_FORTIFY_SOURCE"
514+
if v.have_glibc_memmove_bug:
515+
# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
516+
# https://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
517+
v.LIBMPDEC_CFLAGS += " -U_FORTIFY_SOURCE"
516518

517519
v.export("LIBMPDEC_CFLAGS")
518520
v.export("LIBMPDEC_LIBS")

0 commit comments

Comments
 (0)