-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-35257: Avoid leaking the linker flags into distutils. #10900
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
Changes from all commits
25eb0a1
1819b28
d7ebc21
d1655f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,10 @@ CONFIGURE_CFLAGS= @CFLAGS@ | |
# Use it when a compiler flag should _not_ be part of the distutils CFLAGS | ||
# once Python is installed (Issue #21121). | ||
CONFIGURE_CFLAGS_NODIST=@CFLAGS_NODIST@ | ||
# LDFLAGS_NODIST is used in the same manner as CFLAGS_NODIST. | ||
# Use it when a linker flag should _not_ be part of the distutils LDFLAGS | ||
# once Python is installed (bpo-35257) | ||
CONFIGURE_LDFLAGS_NODIST=@LDFLAGS_NODIST@ | ||
CONFIGURE_CPPFLAGS= @CPPFLAGS@ | ||
CONFIGURE_LDFLAGS= @LDFLAGS@ | ||
# Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the | ||
|
@@ -96,6 +100,7 @@ PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include | |
# environment variables | ||
PY_CPPFLAGS= $(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS) | ||
PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS) | ||
PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST) | ||
NO_AS_NEEDED= @NO_AS_NEEDED@ | ||
SGI_ABI= @SGI_ABI@ | ||
CCSHARED= @CCSHARED@ | ||
|
@@ -107,6 +112,8 @@ CFLAGSFORSHARED=@CFLAGSFORSHARED@ | |
PY_STDMODULE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) | ||
PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN | ||
PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE | ||
# Linker flags used for building the interpreter object files | ||
PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST) | ||
# Strict or non-strict aliasing flags used to compile dtoa.c, see above | ||
CFLAGS_ALIASING=@CFLAGS_ALIASING@ | ||
|
||
|
@@ -146,7 +153,7 @@ CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION) | |
SHLIB_SUFFIX= @SHLIB_SUFFIX@ | ||
EXT_SUFFIX= @EXT_SUFFIX@ | ||
LDSHARED= @LDSHARED@ $(PY_LDFLAGS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You would mind to add a comment explaining why PY_LDFLAGS (and not PY_LDFLAGS_NODIST) is used for LDSHARED? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have to dig in a bit more into the buildsystem to figure out how they are used as my approach was a bit of trial and error for LDSHARED and BLDSHARED. Will try to offer a more comprehensive explanation. |
||
BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS) | ||
BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS_NODIST) | ||
LDCXXSHARED= @LDCXXSHARED@ | ||
DESTSHARED= $(BINLIBDEST)/lib-dynload | ||
|
||
|
@@ -496,7 +503,7 @@ profile-run-stamp: | |
touch $@ | ||
|
||
build_all_generate_profile: | ||
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)" | ||
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)" | ||
|
||
run_profile_task: | ||
@ # FIXME: can't run for a cross build | ||
|
@@ -510,7 +517,7 @@ build_all_merge_profile: | |
profile-opt: profile-run-stamp | ||
@echo "Rebuilding with profile guided optimizations:" | ||
-rm -f profile-clean-stamp | ||
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_USE_FLAG)" LDFLAGS="$(LDFLAGS)" | ||
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_USE_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST)" | ||
|
||
# Compile and run with gcov | ||
.PHONY=coverage coverage-lcov coverage-report | ||
|
@@ -567,7 +574,7 @@ clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c | |
|
||
# Build the interpreter | ||
$(BUILDPYTHON): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) | ||
$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) | ||
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) | ||
|
||
platform: $(BUILDPYTHON) pybuilddir.txt | ||
$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform | ||
|
@@ -632,7 +639,7 @@ libpython3.so: libpython$(LDVERSION).so | |
$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^ | ||
|
||
libpython$(LDVERSION).dylib: $(LIBRARY_OBJS) | ||
$(CC) -dynamiclib -Wl,-single_module $(PY_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \ | ||
$(CC) -dynamiclib -Wl,-single_module $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \ | ||
|
||
|
||
libpython$(VERSION).sl: $(LIBRARY_OBJS) | ||
|
@@ -657,7 +664,7 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \ | |
$(LIBRARY) \ | ||
$(RESSRCDIR)/Info.plist | ||
$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION) | ||
$(CC) -o $(LDLIBRARY) $(PY_LDFLAGS) -dynamiclib \ | ||
$(CC) -o $(LDLIBRARY) $(PY_CORE_LDFLAGS) -dynamiclib \ | ||
-all_load $(LIBRARY) -Wl,-single_module \ | ||
-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \ | ||
-compatibility_version $(VERSION) \ | ||
|
@@ -698,15 +705,15 @@ Makefile Modules/config.c: Makefile.pre \ | |
|
||
|
||
Programs/_testembed: Programs/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) | ||
$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) | ||
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) | ||
|
||
############################################################################ | ||
# Importlib | ||
|
||
Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile | ||
|
||
Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) | ||
$(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) | ||
$(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) | ||
|
||
.PHONY: regen-importlib | ||
regen-importlib: Programs/_freeze_importlib | ||
|
@@ -794,7 +801,7 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile | |
$(IO_OBJS): $(IO_H) | ||
|
||
$(PGEN): $(PGENOBJS) | ||
$(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) | ||
$(CC) $(OPT) $(PY_CORE_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) | ||
|
||
.PHONY: regen-grammar | ||
regen-grammar: $(PGEN) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Avoid leaking the linker flags from Link Time Optimizations (LTO) | ||
into distutils when compiling C extensions. |
Uh oh!
There was an error while loading. Please reload this page.