Skip to content

Commit 940e0d5

Browse files
lazkanaveen521kk
authored andcommitted
Build and install libpython3.dll
This provides the limited ABI as a separate DLL, forwarding to the real one. This makes linking with "-lpython3" work. Fixes python#147
1 parent eb863f4 commit 940e0d5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Makefile.pre.in

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ LIBRARY_DEPS= @LIBRARY_DEPS@
273273
LINK_PYTHON_DEPS=@LINK_PYTHON_DEPS@
274274
PY_ENABLE_SHARED= @PY_ENABLE_SHARED@
275275
STATIC_LIBPYTHON= @STATIC_LIBPYTHON@
276+
ABI3DLLLIBRARY= libpython3.dll
277+
ABI3LDLIBRARY= libpython3.dll.a
276278

277279

278280
LIBS= @LIBS@
@@ -631,7 +633,7 @@ all: @DEF_MAKE_ALL_RULE@
631633

632634
.PHONY: build_all
633635
build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform sharedmods \
634-
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil
636+
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil $(ABI3DLLLIBRARY) $(ABI3LDLIBRARY)
635637

636638
.PHONY: build_wasm
637639
build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
@@ -804,6 +806,9 @@ pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc
804806
python_nt.o: $(srcdir)/PC/python_nt.rc
805807
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
806808

809+
python3dll_nt.o: $(srcdir)/PC/python_nt.rc
810+
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(ABI3DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
811+
807812
venvlauncher.o: $(srcdir)/PC/pylauncher.rc
808813
$(WINDRES) $(RCFLAGS) -DPY_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.rc $@
809814

@@ -917,6 +922,10 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o
917922
else true; \
918923
fi
919924

925+
$(ABI3DLLLIBRARY) $(ABI3LDLIBRARY): python3dll_nt.o $(srcdir)/PC/launcher.c
926+
$(LDSHARED) -DPYTHON_DLL_NAME=\"$(DLLLIBRARY)\" $(srcdir)/PC/python3dll.c -Wl,--out-implib=$(ABI3LDLIBRARY) -o $(ABI3DLLLIBRARY) python3dll_nt.o \
927+
$(LDFLAGS_NODIST);
928+
920929
# wasm32-emscripten browser build
921930
# wasm assets directory is relative to current build dir, e.g. "./usr/local".
922931
# --preload-file turns a relative asset path into an absolute path.
@@ -2025,6 +2034,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
20252034
if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
20262035
if test -n "$(DLLLIBRARY)" ; then \
20272036
$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
2037+
$(INSTALL_SHARED) $(ABI3DLLLIBRARY) $(DESTDIR)$(BINDIR); \
20282038
else \
20292039
$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
20302040
if test $(LDLIBRARY) != $(INSTSONAME); then \
@@ -2485,6 +2495,7 @@ libainstall: all scripts
24852495
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
24862496
if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \
24872497
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
2498+
$(INSTALL_DATA) $(ABI3LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
24882499
else \
24892500
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
24902501
fi; \
@@ -2734,7 +2745,7 @@ clean: clean-retain-profile clean-bolt
27342745

27352746
.PHONY: clobber
27362747
clobber: clean
2737-
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
2748+
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY)$(ABI3LDLIBRARY) $(ABI3DLLLIBRARY) \
27382749
tags TAGS \
27392750
config.cache config.log pyconfig.h Modules/config.c
27402751
-rm -rf build platform

PC/python3dll.c

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

0 commit comments

Comments
 (0)