gh-94404: Use module CFLAGS before PY_STDMODULE_CFLAGS (GH-94413)

``PY_STDMODULE_CFLAGS`` may contain include directories with system
headers. This can break compiling with built-in libmpdec.
This commit is contained in:
Christian Heimes 2022-06-29 15:44:14 +02:00 committed by GitHub
parent 655b3aa4c8
commit 6485c3c726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -829,7 +829,7 @@ python.worker.js: $(srcdir)/Tools/wasm/python.worker.js
##########################################################################
# Build static libmpdec.a
LIBMPDEC_CFLAGS=$(PY_STDMODULE_CFLAGS) $(CCSHARED) @LIBMPDEC_CFLAGS@
LIBMPDEC_CFLAGS=@LIBMPDEC_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
# for setup.py
DECIMAL_CFLAGS=@LIBMPDEC_CFLAGS@
@ -887,7 +887,7 @@ $(LIBMPDEC_A): $(LIBMPDEC_OBJS)
##########################################################################
# Build static libexpat.a
LIBEXPAT_CFLAGS=$(PY_STDMODULE_CFLAGS) $(CCSHARED) @LIBEXPAT_CFLAGS@
LIBEXPAT_CFLAGS=@LIBEXPAT_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
# for setup.py
EXPAT_CFLAGS=@LIBEXPAT_CFLAGS@

View File

@ -1,2 +1,3 @@
``makesetup`` now works around an issue with sed on macOS and uses correct
CFLAGS for object files that end up in a shared extension.
CFLAGS for object files that end up in a shared extension. Module CFLAGS
are used before PY_STDMODULE_CFLAGS to avoid clashes with system headers.

View File

@ -260,13 +260,14 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
\$*) ;;
*) src='$(srcdir)/'"$srcdir/$src";;
esac
# custom flags first, PY_STDMODULE_CFLAGS may contain -I with system libmpdec
case $doconfig in
no) cc="$cc \$(PY_STDMODULE_CFLAGS) \$(CCSHARED)";;
no) cc="$cc $cpps \$(PY_STDMODULE_CFLAGS) \$(CCSHARED)";;
*)
cc="$cc \$(PY_BUILTIN_MODULE_CFLAGS)";;
cc="$cc $cpps \$(PY_BUILTIN_MODULE_CFLAGS)";;
esac
# force rebuild when header file or module build flavor (static/shared) is changed
rule="$obj: $src \$(MODULE_${mods_upper}_DEPS) \$(PYTHON_HEADERS) Modules/config.c; $cc $cpps -c $src -o $obj"
rule="$obj: $src \$(MODULE_${mods_upper}_DEPS) \$(PYTHON_HEADERS) Modules/config.c; $cc -c $src -o $obj"
echo "$rule" >>$rulesf
done
case $doconfig in