python-emscripten  Check-in [6319bb7bc7]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplify Python compilation a bit
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:6319bb7bc7b325b74b65eaccb3d6ca704f3cf4432329e13269814ec76b77d3cf
User & Date: Beuc 2020-05-08 16:26:47
Context
2020-05-08
16:44
Python3 initial support check-in: 58e7feba3b user: Beuc tags: trunk
16:26
Simplify Python compilation a bit check-in: 6319bb7bc7 user: Beuc tags: trunk
16:26
webprompt: fix native test check-in: 16267ba494 user: Beuc tags: trunk
Changes

Changes to 2.7.10/python.sh.

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
66
67
68
69
70
71
72
73
74
75




76
77

78
79
80
81
82
83

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
            ../configure \
                --prefix='' \
                --without-pymalloc
        fi

        make -j$(nproc)
        make install DESTDIR=$BUILD/hostpython

        # emcc should disregard '-fPIC' during non-SIDE_MODULE builds,
        # otherwise _sysconfigdata.build_time_vars['CCSHARED'] is the culprit:
        # sed -i -e 's/-fPIC//' $BUILD/hostpython/lib/python2.7/_sysconfigdata.py
    )

    # setuptools for 3rd-party module installers
    wget -c https://files.pythonhosted.org/packages/11/0a/7f13ef5cd932a107cd4c0f3ebc9d831d9b78e1a0e8c98a098ca17b1d7d97/setuptools-41.6.0.zip -P $CACHEROOT/
    cd $BUILD/hostpython/
    rm -rf setuptools-41.6.0/
    unzip $CACHEROOT/setuptools-41.6.0.zip
................................................................................
    cd $BUILD/Python-$VERSION/
    mkdir -p emscripten
    (
        cd emscripten/
        # OPT=-Oz: TODO
        # CONFIG_SITE: deals with cross-compilation https://bugs.python.org/msg136962
        # not needed as emcc has a single arch: BASECFLAGS=-m32 LDFLAGS=-m32
        # --without-threads: pthreads experimental as of 2019-11
        #   cf. https://emscripten.org/docs/porting/pthreads.html





        if [ ! -e config.status ]; then
            CONFIG_SITE=../config.site BASECFLAGS='-s USE_ZLIB=1' \

                emconfigure ../configure \
                --host=asmjs-unknown-emscripten --build=$(../config.guess) \
                --prefix='' \
                --without-threads --without-pymalloc --without-signal-module --disable-ipv6 \
                --disable-shared
        fi

        sed -i -e 's,^#define HAVE_GCC_ASM_FOR_X87.*,/* & */,' pyconfig.h

        # pgen native setup
        # note: need to build 'pgen' once before overwriting it with the native one
        # note: PGEN=../native/Parser/pgen doesn't work, make overwrites it
        emmake make Parser/pgen
        \cp --preserve=mode ../native/Parser/pgen Parser/
        # python native setup
        # note: PATH=... doesn't work, it breaks emcc's /usr/bin/env python
        # note: PYTHON_FOR_BUILD=../native/python neither, it's a more complex call
        #emmake env PATH=../../hostpython/bin:$PATH make -j$(nproc)
        sed -i -e 's,\(PYTHON_FOR_BUILD=.*\) python2.7,\1 $(abs_srcdir)/native/python,' Makefile

        # Modules/Setup.local
        echo '*static*' > Modules/Setup.local
        cat $SETUPLOCAL >> Modules/Setup.local
        # drop -I/-L/-lz, we USE_ZLIB=1 (keep it in SETUPLOCAL for mock)
        sed -i -e 's/^\(zlib zlibmodule.c\).*/\1/' Modules/Setup.local
    







<
<
<
<







 







|

<
>
>
>
>


>






>







<
<
<
<
<







43
44
45
46
47
48
49




50
51
52
53
54
55
56
..
62
63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91





92
93
94
95
96
97
98
            ../configure \
                --prefix='' \
                --without-pymalloc
        fi

        make -j$(nproc)
        make install DESTDIR=$BUILD/hostpython




    )

    # setuptools for 3rd-party module installers
    wget -c https://files.pythonhosted.org/packages/11/0a/7f13ef5cd932a107cd4c0f3ebc9d831d9b78e1a0e8c98a098ca17b1d7d97/setuptools-41.6.0.zip -P $CACHEROOT/
    cd $BUILD/hostpython/
    rm -rf setuptools-41.6.0/
    unzip $CACHEROOT/setuptools-41.6.0.zip
................................................................................
    cd $BUILD/Python-$VERSION/
    mkdir -p emscripten
    (
        cd emscripten/
        # OPT=-Oz: TODO
        # CONFIG_SITE: deals with cross-compilation https://bugs.python.org/msg136962
        # not needed as emcc has a single arch: BASECFLAGS=-m32 LDFLAGS=-m32
        # --without-threads: pthreads experimental as of 2020-05
        #   cf. https://emscripten.org/docs/porting/pthreads.html

        # --without-signal-module: no process signals in Emscripten
        # --without-pymalloc: ?
        # --disable-ipv6: browser-side networking
        # --disable-shared: compile statically for Emscripten perfs + incomplete PIC support
        if [ ! -e config.status ]; then
            CONFIG_SITE=../config.site BASECFLAGS='-s USE_ZLIB=1' \
                PYTHON_FOR_BUILD=$BUILD/Python-$VERSION/native/python \
                emconfigure ../configure \
                --host=asmjs-unknown-emscripten --build=$(../config.guess) \
                --prefix='' \
                --without-threads --without-pymalloc --without-signal-module --disable-ipv6 \
                --disable-shared
        fi
	# Fix bad detection
        sed -i -e 's,^#define HAVE_GCC_ASM_FOR_X87.*,/* & */,' pyconfig.h

        # pgen native setup
        # note: need to build 'pgen' once before overwriting it with the native one
        # note: PGEN=../native/Parser/pgen doesn't work, make overwrites it
        emmake make Parser/pgen
        \cp --preserve=mode ../native/Parser/pgen Parser/






        # Modules/Setup.local
        echo '*static*' > Modules/Setup.local
        cat $SETUPLOCAL >> Modules/Setup.local
        # drop -I/-L/-lz, we USE_ZLIB=1 (keep it in SETUPLOCAL for mock)
        sed -i -e 's/^\(zlib zlibmodule.c\).*/\1/' Modules/Setup.local