Skip to content

Commit d1f35aa

Browse files
committed
introduce executable specific linker flags
Add PY_CORE_EXE_LDFLAGS and EXE_LDFLAGS which stores executable specific LDFLAGS, replacing PY_CORE_LDFLAGS for building executable targets. If PY_CORE_EXE_LDFLAGS / EXE_LDFLAGS is not provided, then it defaults to the value of PY_CORE_LDFLAGS which is the existing behaviour. If both flags are supplied, and there is a need to distinguish between executable and shared specific LDFLAGS, in particular, PY_CORE_LDFLAGS should contain the shared specific LDFLAGS.
1 parent 180b3eb commit d1f35aa

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

Lib/_osx_support.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
1818
'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
1919
'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
20-
'PY_CORE_CFLAGS', 'PY_CORE_LDFLAGS')
20+
'PY_CORE_CFLAGS', 'PY_CORE_LDFLAGS',
21+
'PY_CORE_EXE_LDFLAGS')
2122

2223
# configuration variables that may contain compiler calls
2324
_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')

Lib/test/pythoninfo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ def collect_sysconfig(info_add):
524524
'PY_CFLAGS',
525525
'PY_CFLAGS_NODIST',
526526
'PY_CORE_LDFLAGS',
527+
'PY_CORE_EXE_LDFLAGS',
527528
'PY_LDFLAGS',
528529
'PY_LDFLAGS_NODIST',
529530
'PY_STDMODULE_CFLAGS',

Lib/test/test__osx_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def setUp(self):
2525
'CFLAGS', 'LDFLAGS', 'CPPFLAGS',
2626
'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'CC',
2727
'CXX', 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
28-
'PY_CORE_CFLAGS', 'PY_CORE_LDFLAGS'
28+
'PY_CORE_CFLAGS', 'PY_CORE_LDFLAGS', 'PY_CORE_EXE_LDFLAGS'
2929
)
3030

3131
def add_expected_saved_initial_values(self, config_vars, expected_vars):

Makefile.pre.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ PY_STDMODULE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFOR
123123
PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN
124124
PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
125125
# Linker flags used for building the interpreter object files
126+
# In particular, EXE_LDFLAGS is an extra flag to provide fine grain distinction between
127+
# LDFLAGS used to build executables and shared targets.
126128
PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
129+
CONFIGURE_EXE_LDFLAGS=@EXE_LDFLAGS@
130+
PY_CORE_EXE_LDFLAGS:= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) $(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS))
127131
# Strict or non-strict aliasing flags used to compile dtoa.c, see above
128132
CFLAGS_ALIASING=@CFLAGS_ALIASING@
129133

@@ -982,7 +986,7 @@ clinic-tests: check-clean-src $(srcdir)/Lib/test/clinic.test.c
982986

983987
# Build the interpreter
984988
$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS)
985-
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
989+
$(LINKCC) $(PY_CORE_EXE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
986990

987991
platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt
988992
$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
@@ -1628,7 +1632,7 @@ regen-re: $(BUILDPYTHON)
16281632
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/generate_re_casefix.py $(srcdir)/Lib/re/_casefix.py
16291633

16301634
Programs/_testembed: Programs/_testembed.o $(LINK_PYTHON_DEPS)
1631-
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
1635+
$(LINKCC) $(PY_CORE_EXE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
16321636

16331637
############################################################################
16341638
# "Bootstrap Python" used to run Programs/_freeze_module.py

configure

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,7 @@ AS_CASE([$enable_wasm_dynamic_linking],
24012401
AC_SUBST([BASECFLAGS])
24022402
AC_SUBST([CFLAGS_NODIST])
24032403
AC_SUBST([LDFLAGS_NODIST])
2404+
AC_SUBST([EXE_LDFLAGS])
24042405
AC_SUBST([LDFLAGS_NOLTO])
24052406
AC_SUBST([WASM_ASSETS_DIR])
24062407
AC_SUBST([WASM_STDLIB])

0 commit comments

Comments
 (0)