Skip to content

Commit 05b95c2

Browse files
committed
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 #147
1 parent 1716f39 commit 05b95c2

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
@@ -278,6 +278,8 @@ LIBRARY_DEPS= @LIBRARY_DEPS@
278278
LINK_PYTHON_DEPS=@LINK_PYTHON_DEPS@
279279
PY_ENABLE_SHARED= @PY_ENABLE_SHARED@
280280
STATIC_LIBPYTHON= @STATIC_LIBPYTHON@
281+
ABI3DLLLIBRARY= libpython3.dll
282+
ABI3LDLIBRARY= libpython3.dll.a
281283

282284

283285
LIBS= @LIBS@
@@ -600,7 +602,7 @@ LIBEXPAT_HEADERS= \
600602
# Default target
601603
all: @DEF_MAKE_ALL_RULE@
602604
build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform oldsharedmods sharedmods \
603-
gdbhooks Programs/_testembed python-config
605+
gdbhooks Programs/_testembed python-config $(ABI3DLLLIBRARY) $(ABI3LDLIBRARY)
604606
build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config
605607

606608
# Check that the source is clean when building out of source.
@@ -724,6 +726,9 @@ pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc
724726
python_nt.o: $(srcdir)/PC/python_nt.rc
725727
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
726728

729+
python3dll_nt.o: $(srcdir)/PC/python_nt.rc
730+
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(ABI3DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
731+
727732
venvlauncher.o: $(srcdir)/PC/pylauncher.rc
728733
$(WINDRES) $(RCFLAGS) -DPY_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.rc $@
729734

@@ -852,6 +857,10 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o
852857
else true; \
853858
fi
854859

860+
$(ABI3DLLLIBRARY) $(ABI3LDLIBRARY): python3dll_nt.o $(srcdir)/PC/launcher.c
861+
$(LDSHARED) -DPYTHON_DLL_NAME=\"$(DLLLIBRARY)\" $(srcdir)/PC/python3dll.c -Wl,--out-implib=$(ABI3LDLIBRARY) -o $(ABI3DLLLIBRARY) python3dll_nt.o \
862+
$(LDFLAGS_NODIST);
863+
855864
# wasm32-emscripten browser build
856865
# wasm assets directory is relative to current build dir, e.g. "./usr/local".
857866
# --preload-file turns a relative asset path into an absolute path.
@@ -1862,6 +1871,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
18621871
if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
18631872
if test -n "$(DLLLIBRARY)" ; then \
18641873
$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
1874+
$(INSTALL_SHARED) $(ABI3DLLLIBRARY) $(DESTDIR)$(BINDIR); \
18651875
else \
18661876
$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
18671877
if test $(LDLIBRARY) != $(INSTSONAME); then \
@@ -2280,6 +2290,7 @@ libainstall: all python-config
22802290
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
22812291
if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \
22822292
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
2293+
$(INSTALL_DATA) $(ABI3LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
22832294
else \
22842295
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
22852296
fi; \
@@ -2526,7 +2537,7 @@ clean: clean-retain-profile
25262537
fi
25272538

25282539
clobber: clean
2529-
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
2540+
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY)$(ABI3LDLIBRARY) $(ABI3DLLLIBRARY) \
25302541
tags TAGS \
25312542
config.cache config.log pyconfig.h Modules/config.c
25322543
-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)