Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3076559

Browse files
committed
This patch enables the building of Cygwin Python with a static core
which still supports shared extensions. It takes advantage the latest Cygwin binutils (i.e., 20030901-1) which can export symbols from executables: http://cygwin.com/ml/cygwin-announce/2003-09/msg00002.html Additionally, it finally lays to rest the following mailing list subthread: http://mail.python.org/pipermail/python-list/2002-May/102500.html I tested the patch under Red Hat Linux 8.0 too
1 parent 8ad1dd7 commit 3076559

4 files changed

Lines changed: 35 additions & 6 deletions

File tree

Include/pyport.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ extern double hypot(double, double);
421421
# define HAVE_DECLSPEC_DLL
422422
#endif
423423

424-
#if defined(Py_ENABLE_SHARED) /* only get special linkage if built as shared */
424+
/* only get special linkage if built as shared or platform is Cygwin */
425+
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
425426
# if defined(HAVE_DECLSPEC_DLL)
426427
# ifdef Py_BUILD_CORE
427428
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE

Makefile.pre.in

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,14 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
379379
$(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
380380
$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
381381

382-
# This rule builds the Cygwin Python DLL
383-
libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
384-
$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
385-
$(LIBS) $(MODLIBS) $(SYSLIBS)
382+
# This rule builds the Cygwin Python DLL and import library if configured
383+
# for a shared core library; otherwise, this rule is a noop.
384+
$(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
385+
if test -n "$(DLLLIBRARY)"; then \
386+
$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
387+
$(LIBS) $(MODLIBS) $(SYSLIBS); \
388+
else true; \
389+
fi
386390

387391

388392
oldsharedmods: $(SHAREDMODS)

configure

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# From configure.in Revision: 1.428 .
2+
# From configure.in Revision: 1.429 .
33
# Guess values for system-dependent variables and create Makefiles.
44
# Generated by GNU Autoconf 2.57 for python 2.4.
55
#
@@ -3619,6 +3619,13 @@ _ACEOF
36193619
BASECFLAGS="$BASECFLAGS -pic"
36203620
;;
36213621
esac
3622+
else # shared is disabled
3623+
case $ac_sys_system in
3624+
CYGWIN*)
3625+
BLDLIBRARY='$(LIBRARY)'
3626+
LDLIBRARY='libpython$(VERSION).dll.a'
3627+
;;
3628+
esac
36223629
fi
36233630

36243631
echo "$as_me:$LINENO: result: $LDLIBRARY" >&5
@@ -10192,6 +10199,11 @@ then
1019210199
LINKFORSHARED="-Xlinker --export-dynamic"
1019310200
fi;;
1019410201
esac;;
10202+
CYGWIN*)
10203+
if test $enable_shared = "no"
10204+
then
10205+
LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
10206+
fi;;
1019510207
esac
1019610208
fi
1019710209
echo "$as_me:$LINENO: result: $LINKFORSHARED" >&5

configure.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,13 @@ if test $enable_shared = "yes"; then
539539
BASECFLAGS="$BASECFLAGS -pic"
540540
;;
541541
esac
542+
else # shared is disabled
543+
case $ac_sys_system in
544+
CYGWIN*)
545+
BLDLIBRARY='$(LIBRARY)'
546+
LDLIBRARY='libpython$(VERSION).dll.a'
547+
;;
548+
esac
542549
fi
543550

544551
AC_MSG_RESULT($LDLIBRARY)
@@ -1371,6 +1378,11 @@ then
13711378
LINKFORSHARED="-Xlinker --export-dynamic"
13721379
fi;;
13731380
esac;;
1381+
CYGWIN*)
1382+
if test $enable_shared = "no"
1383+
then
1384+
LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1385+
fi;;
13741386
esac
13751387
fi
13761388
AC_MSG_RESULT($LINKFORSHARED)

0 commit comments

Comments
 (0)