Skip to content

Commit

Permalink
gh-94404: makesetup: use correct CFLAGS and macOS workaround (GH-94405)
Browse files Browse the repository at this point in the history
``makesetup`` now works around an issue with sed on macOS and uses correct
CFLAGS for object files that end up in a shared extension.
(cherry picked from commit 5150cbc)

Co-authored-by: Christian Heimes <christian@python.org>
  • Loading branch information
miss-islington and tiran authored Jun 29, 2022
1 parent 3b4f5ed commit aaa85b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``makesetup`` now works around an issue with sed on macOS and uses correct
CFLAGS for object files that end up in a shared extension.
16 changes: 11 additions & 5 deletions Modules/makesetup
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /bin/sh
set -e

# Convert templates into Makefile and config.c, based on the module
# definitions found in the file Setup.
Expand Down Expand Up @@ -260,7 +261,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
*) src='$(srcdir)/'"$srcdir/$src";;
esac
case $doconfig in
no) cc="$cc \$(CCSHARED) \$(PY_CFLAGS_NODIST) \$(PY_CPPFLAGS)";;
no) cc="$cc \$(PY_STDMODULE_CFLAGS) \$(CCSHARED)";;
*)
cc="$cc \$(PY_BUILTIN_MODULE_CFLAGS)";;
esac
Expand Down Expand Up @@ -322,8 +323,13 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |

case $makepre in
-) ;;
*) sedf="@sed.in.$$"
trap 'rm -f $sedf' 0 1 2 3
*)
# macOS' sed has issues with 'a' command. Use 'r' command with an
# external replacement file instead.
sedf="@sed.in.$$"
sedr="@sed.replace.$$"
trap 'rm -f $sedf $sedr' 0 1 2 3
echo "$NL$NL$DEFS" | sed 's/\\$//' > $sedr
echo "1i\\" >$sedf
str="# Generated automatically from $makepre by makesetup."
echo "$str" >>$sedf
Expand All @@ -332,10 +338,10 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
echo "s%_MODDISABLED_NAMES_%$DISABLED%" >>$sedf
echo "s%_MODOBJS_%$OBJS%" >>$sedf
echo "s%_MODLIBS_%$LIBS%" >>$sedf
echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf
echo "/Definitions added by makesetup/r $sedr" >>$sedf
sed -f $sedf $makepre >Makefile
cat $rulesf >>Makefile
rm -f $sedf
rm -f $sedf $sedr
;;
esac

Expand Down

0 comments on commit aaa85b5

Please sign in to comment.