Skip to content

Commit 5150cbc

Browse files
authored
gh-94404: makesetup: use correct CFLAGS and macOS workaround (GH-94405)
``makesetup`` now works around an issue with sed on macOS and uses correct CFLAGS for object files that end up in a shared extension.
1 parent 79ac8c1 commit 5150cbc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``makesetup`` now works around an issue with sed on macOS and uses correct
2+
CFLAGS for object files that end up in a shared extension.

Modules/makesetup

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#! /bin/sh
2+
set -e
23

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

323324
case $makepre in
324325
-) ;;
325-
*) sedf="@sed.in.$$"
326-
trap 'rm -f $sedf' 0 1 2 3
326+
*)
327+
# macOS' sed has issues with 'a' command. Use 'r' command with an
328+
# external replacement file instead.
329+
sedf="@sed.in.$$"
330+
sedr="@sed.replace.$$"
331+
trap 'rm -f $sedf $sedr' 0 1 2 3
332+
echo "$NL$NL$DEFS" | sed 's/\\$//' > $sedr
327333
echo "1i\\" >$sedf
328334
str="# Generated automatically from $makepre by makesetup."
329335
echo "$str" >>$sedf
@@ -332,10 +338,10 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
332338
echo "s%_MODDISABLED_NAMES_%$DISABLED%" >>$sedf
333339
echo "s%_MODOBJS_%$OBJS%" >>$sedf
334340
echo "s%_MODLIBS_%$LIBS%" >>$sedf
335-
echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf
341+
echo "/Definitions added by makesetup/r $sedr" >>$sedf
336342
sed -f $sedf $makepre >Makefile
337343
cat $rulesf >>Makefile
338-
rm -f $sedf
344+
rm -f $sedf $sedr
339345
;;
340346
esac
341347

0 commit comments

Comments
 (0)