Skip to content

Commit 7b54d2d

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 python#147
1 parent ce18846 commit 7b54d2d

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@
@@ -601,7 +603,7 @@ LIBEXPAT_HEADERS= \
601603
# Default target
602604
all: @DEF_MAKE_ALL_RULE@
603605
build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform oldsharedmods sharedmods \
604-
gdbhooks Programs/_testembed python-config
606+
gdbhooks Programs/_testembed python-config $(ABI3DLLLIBRARY) $(ABI3LDLIBRARY)
605607
build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config
606608

607609
# Check that the source is clean when building out of source.
@@ -728,6 +730,9 @@ pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc
728730
python_nt.o: $(srcdir)/PC/python_nt.rc
729731
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
730732

733+
python3dll_nt.o: $(srcdir)/PC/python_nt.rc
734+
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(ABI3DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
735+
731736
venvlauncher.o: $(srcdir)/PC/pylauncher.rc
732737
$(WINDRES) $(RCFLAGS) -DPY_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.rc $@
733738

@@ -856,6 +861,10 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o
856861
else true; \
857862
fi
858863

864+
$(ABI3DLLLIBRARY) $(ABI3LDLIBRARY): python3dll_nt.o $(srcdir)/PC/launcher.c
865+
$(LDSHARED) -DPYTHON_DLL_NAME=\"$(DLLLIBRARY)\" $(srcdir)/PC/python3dll.c -Wl,--out-implib=$(ABI3LDLIBRARY) -o $(ABI3DLLLIBRARY) python3dll_nt.o \
866+
$(LDFLAGS_NODIST);
867+
859868
# wasm32-emscripten browser build
860869
# wasm assets directory is relative to current build dir, e.g. "./usr/local".
861870
# --preload-file turns a relative asset path into an absolute path.
@@ -1867,6 +1876,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
18671876
if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
18681877
if test -n "$(DLLLIBRARY)" ; then \
18691878
$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
1879+
$(INSTALL_SHARED) $(ABI3DLLLIBRARY) $(DESTDIR)$(BINDIR); \
18701880
else \
18711881
$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
18721882
if test $(LDLIBRARY) != $(INSTSONAME); then \
@@ -2301,6 +2311,7 @@ libainstall: all python-config
23012311
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
23022312
if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \
23032313
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
2314+
$(INSTALL_DATA) $(ABI3LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
23042315
else \
23052316
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
23062317
fi; \
@@ -2550,7 +2561,7 @@ clean: clean-retain-profile
25502561
fi
25512562

25522563
clobber: clean
2553-
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
2564+
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY)$(ABI3LDLIBRARY) $(ABI3DLLLIBRARY) \
25542565
tags TAGS \
25552566
config.cache config.log pyconfig.h Modules/config.c
25562567
-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)