Skip to content

Commit

Permalink
gh-94404: Use module CFLAGS before PY_STDMODULE_CFLAGS (GH-94413)
Browse files Browse the repository at this point in the history
``PY_STDMODULE_CFLAGS`` may contain include directories with system
headers. This can break compiling with built-in libmpdec.
  • Loading branch information
tiran committed Jun 29, 2022
1 parent 655b3aa commit 6485c3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand Down Expand Up @@ -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@
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 4 additions & 3 deletions Modules/makesetup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6485c3c

Please sign in to comment.