Skip to content

Commit 89965f1

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 9296a4a commit 89965f1

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
@@ -288,6 +288,8 @@ LIBRARY_DEPS= @LIBRARY_DEPS@
288288
LINK_PYTHON_DEPS=@LINK_PYTHON_DEPS@
289289
PY_ENABLE_SHARED= @PY_ENABLE_SHARED@
290290
STATIC_LIBPYTHON= @STATIC_LIBPYTHON@
291+
ABI3DLLLIBRARY= libpython3.dll
292+
ABI3LDLIBRARY= libpython3.dll.a
291293

292294

293295
LIBS= @LIBS@
@@ -710,7 +712,7 @@ list-targets:
710712

711713
.PHONY: build_all
712714
build_all: check-clean-src check-app-store-compliance $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform sharedmods \
713-
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil
715+
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil $(ABI3DLLLIBRARY) $(ABI3LDLIBRARY)
714716

715717
.PHONY: build_wasm
716718
build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
@@ -899,6 +901,9 @@ pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc
899901
python_nt.o: $(srcdir)/PC/python_nt.rc
900902
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
901903

904+
python3dll_nt.o: $(srcdir)/PC/python_nt.rc
905+
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(ABI3DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@
906+
902907
venvlauncher.o: $(srcdir)/PC/pylauncher.rc
903908
$(WINDRES) $(RCFLAGS) -DPY_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.rc $@
904909

@@ -1024,6 +1029,10 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o
10241029
else true; \
10251030
fi
10261031

1032+
$(ABI3DLLLIBRARY) $(ABI3LDLIBRARY): python3dll_nt.o $(srcdir)/PC/launcher.c
1033+
$(LDSHARED) -DPYTHON_DLL_NAME=\"$(DLLLIBRARY)\" $(srcdir)/PC/python3dll.c -Wl,--out-implib=$(ABI3LDLIBRARY) -o $(ABI3DLLLIBRARY) python3dll_nt.o \
1034+
$(LDFLAGS_NODIST);
1035+
10271036
# wasm32-emscripten browser build
10281037
# wasm assets directory is relative to current build dir, e.g. "./usr/local".
10291038
# --preload-file turns a relative asset path into an absolute path.
@@ -2268,6 +2277,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
22682277
if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
22692278
if test -n "$(DLLLIBRARY)" ; then \
22702279
$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
2280+
$(INSTALL_SHARED) $(ABI3DLLLIBRARY) $(DESTDIR)$(BINDIR); \
22712281
else \
22722282
$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
22732283
if test $(LDLIBRARY) != $(INSTSONAME); then \
@@ -2751,6 +2761,7 @@ libainstall: all scripts
27512761
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
27522762
if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \
27532763
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
2764+
$(INSTALL_DATA) $(ABI3LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \
27542765
else \
27552766
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
27562767
fi; \
@@ -3059,7 +3070,7 @@ clean: clean-retain-profile clean-bolt
30593070

30603071
.PHONY: clobber
30613072
clobber: clean
3062-
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
3073+
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY)$(ABI3LDLIBRARY) $(ABI3DLLLIBRARY) \
30633074
tags TAGS \
30643075
config.cache config.log pyconfig.h Modules/config.c
30653076
-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)