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

Skip to content

Commit 4ee893f

Browse files
author
Andrew MacIntyre
committed
More pre-2.3 build tweaks for the OS/2 EMX port:
- separate the building of the core from the wrapper executables and the external modules (.PYDs), based on the Py_BUILD_CORE define; - clean up the generated import library definiton (.DEF file) to remove references to a number of non-static symbols that aren't part of the Python API and which shouldn't be exported by the core DLL; - compile the release build with -fomit-frame-pointer, for a small performance gain; - make "make clean" remove byte compiled Python library files.
1 parent f9ce67d commit 4ee893f

3 files changed

Lines changed: 473 additions & 263 deletions

File tree

PC/os2emx/Makefile

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,18 @@ ARFLAGS= crs
8383
IMPLIB= emximp
8484
EXPLIB= emxexp
8585
EXEOPT= emxbind
86+
PY_DEF= -DPy_BUILD_CORE
8687

8788

8889
# adjust C compiler settings based on build options
8990
ifeq ($(MODE),debug)
9091
CFLAGS+= -g -O
9192
LDFLAGS+= -g
9293
else
93-
CFLAGS+= -s -O2
94+
CFLAGS+= -s -O2 -fomit-frame-pointer
9495
LDFLAGS+= -s
9596
endif
97+
CFLAGS+= $(PY_DEF)
9698
ifeq ($(ASSERTIONS),no)
9799
CFLAGS+= -DNDEBUG
98100
endif
@@ -474,12 +476,16 @@ EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
474476

475477
# Targets
476478
all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
477-
$(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
479+
python_noncore
480+
481+
python_noncore:
482+
make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
478483

479484
clean:
480485
rm -f $(OUT)*
481486
rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
482487
$(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT)
488+
find ../../Lib -name "*.py[co]" -exec rm {} ";"
483489

484490
lx:
485491
@echo Packing everything with lxLite...
@@ -498,14 +504,39 @@ $(PYTHON.LIB): $(OBJ.LIB)
498504
rm.exe -f $@
499505
$(AR) $(ARFLAGS) $@ $^
500506

507+
# the Python core DLL .def file needs to have a number of non-static
508+
# symbols that aren't part of the Python C API removed (commented out)
509+
# from the DLL export list.
501510
$(PYTHON.DEF): $(PYTHON.LIB)
502511
@echo Creating .DEF file: $@
503512
@echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
504513
@echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
505514
@echo PROTMODE >>$@
506515
@echo DATA MULTIPLE NONSHARED >>$@
507516
@echo EXPORTS >>$@
508-
$(EXPLIB) -u $(PYTHON.LIB) >>$@
517+
$(EXPLIB) -u $(PYTHON.LIB) |\
518+
sed -e "/ .init.*/s/^ /; /" \
519+
-e "/ .pcre_.*/s/^ /; /" \
520+
-e "/ .array_methods/s/^ /; /" \
521+
-e "/ .fast_save_leave/s/^ /; /" \
522+
-e "/ .dlopen/s/^ /; /" \
523+
-e "/ .dlsym/s/^ /; /" \
524+
-e "/ .dlclose/s/^ /; /" \
525+
-e "/ .dlerror/s/^ /; /" \
526+
-e "/ .cycle_type/s/^ /; /" \
527+
-e "/ .dropwhile_type/s/^ /; /" \
528+
-e "/ .takewhile_type/s/^ /; /" \
529+
-e "/ .islice_type/s/^ /; /" \
530+
-e "/ .starmap_type/s/^ /; /" \
531+
-e "/ .imap_type/s/^ /; /" \
532+
-e "/ .chain_type/s/^ /; /" \
533+
-e "/ .ifilter_type/s/^ /; /" \
534+
-e "/ .ifilterfalse_type/s/^ /; /" \
535+
-e "/ .count_type/s/^ /; /" \
536+
-e "/ .izip_type/s/^ /; /" \
537+
-e "/ .repeat_type/s/^ /; /" \
538+
-e "/ ._Py_re_.*/s/^ /; /" \
539+
-e "/ ._Py_MD5.*/s/^ /; /" >>$@
509540

510541
$(PYTHON.IMPLIB): $(PYTHON.DEF)
511542
$(IMPLIB) -o $@ $^
@@ -627,7 +658,7 @@ readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
627658

628659
#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
629660
_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
630-
$(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
661+
$(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
631662
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
632663

633664
zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)

PC/os2emx/pyconfig.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
/*#define Py_DEBUG 1*/
2727
#endif
2828

29+
/* if building an extension or wrapper executable,
30+
* mark Python API symbols "extern" so that symbols
31+
* imported from the Python core DLL aren't duplicated.
32+
*/
33+
#ifdef Py_BUILD_CORE
34+
# define PyAPI_FUNC(RTYPE) RTYPE
35+
#else
36+
# define PyAPI_FUNC(RTYPE) extern RTYPE
37+
#endif
38+
#define PyAPI_DATA(RTYPE) extern RTYPE
39+
#define PyMODINIT_FUNC void
40+
2941
/* Use OS/2 flavour of threads */
3042
#define WITH_THREAD 1
3143
#define OS2_THREADS 1

0 commit comments

Comments
 (0)