Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-94404: makesetup: use correct CFLAGS and macOS workaround #94405

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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