summaryrefslogtreecommitdiff
path: root/Ports/python3
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-02-01 19:45:12 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-02 16:53:06 +0100
commit404dab5383c5b4ac86b0c18432877cba386f3f26 (patch)
tree5b9f2a175f2c52b70f672c321703bf40e1481731 /Ports/python3
parent92ca22a5e102752775713426cb6f4fd36ef5106d (diff)
downloadserenity-404dab5383c5b4ac86b0c18432877cba386f3f26.zip
Ports: Build most python3 extension modules statically
Attempting to import C-extensions (lib-dynload/*.so) currently asserts in the dynamic loader - let's just build them statically instead for the time being. This makes a large number of modules available for use and the port a lot more functional! :^)
Diffstat (limited to 'Ports/python3')
-rw-r--r--Ports/python3/.gitignore2
-rw-r--r--Ports/python3/Setup.local76
-rwxr-xr-xPorts/python3/package.sh4
3 files changed, 82 insertions, 0 deletions
diff --git a/Ports/python3/.gitignore b/Ports/python3/.gitignore
new file mode 100644
index 0000000000..737b04ddc7
--- /dev/null
+++ b/Ports/python3/.gitignore
@@ -0,0 +1,2 @@
+!version.sh
+!Setup.local
diff --git a/Ports/python3/Setup.local b/Ports/python3/Setup.local
new file mode 100644
index 0000000000..0c94060ed6
--- /dev/null
+++ b/Ports/python3/Setup.local
@@ -0,0 +1,76 @@
+# Build most modules that are usually built as shared objects statically as importing such modules
+# currently asserts in the dynamic loader (may or may not be related to https://github.com/SerenityOS/serenity/issues/4642):
+#
+# ASSERTION FAILED: flags & RTLD_GLOBAL
+# ../Userland/Libraries/LibELF/DynamicLoader.cpp:171 (as of 2020-02-01 at least)
+#
+# This means we otherwise couldn't import any of these nor anything that imports them, which is quite limiting.
+#
+# The list is mostly copied from Modules/Setup, with some minor tweaks (include paths, added a bunch of other modules).
+# As a result of static linking, a build failure in any of these modules will fail the build of Python itself,
+# instead of just not building that specific .so - obviously. If this stops working, tweak the list accordingly.
+#
+# Some stuff is neither under *static* nor *disabled*, so lib-dynload isn't entirely empty - mostly _test* modules though.
+#
+# Python itself is still linked dynamically, which works fine - it's just module imports that blow up.
+# This file can simply be removed, along with post_configure() in package.sh, once the issue mentioned above is resolved.
+
+*static*
+
+_asyncio _asynciomodule.c
+_bisect _bisectmodule.c
+_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
+_codecs_cn cjkcodecs/_codecs_cn.c
+_codecs_hk cjkcodecs/_codecs_hk.c
+_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
+_codecs_jp cjkcodecs/_codecs_jp.c
+_codecs_kr cjkcodecs/_codecs_kr.c
+_codecs_tw cjkcodecs/_codecs_tw.c
+_contextvars _contextvarsmodule.c
+_crypt _cryptmodule.c
+_csv _csv.c
+_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/cfield.c _ctypes/malloc_closure.c _ctypes/stgdict.c -I$(SERENITY_ROOT)/Build/Root/usr/local/include $(SERENITY_ROOT)/Build/Root/usr/local/lib/libffi.a
+_datetime _datetimemodule.c
+_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c
+_heapq _heapqmodule.c
+_json -I$(srcdir)/Include/internal -DPy_BUILD_CORE_BUILTIN _json.c
+_md5 md5module.c
+_multibytecodec cjkcodecs/multibytecodec.c
+_opcode _opcode.c
+_pickle _pickle.c
+_posixsubprocess _posixsubprocess.c
+_queue _queuemodule.c
+_random _randommodule.c -DPy_BUILD_CORE_MODULE
+_sha1 sha1module.c
+_sha256 sha256module.c -DPy_BUILD_CORE_BUILTIN
+_sha3 _sha3/sha3module.c
+_sha512 sha512module.c -DPy_BUILD_CORE_BUILTIN
+_statistics _statisticsmodule.c
+_struct _struct.c
+_weakref _weakref.c
+_xxsubinterpreters _xxsubinterpretersmodule.c
+_zoneinfo _zoneinfo.c
+array arraymodule.c
+audioop audioop.c
+binascii binascii.c
+cmath cmathmodule.c _math.c -DPy_BUILD_CORE_MODULE
+fcntl fcntlmodule.c
+grp grpmodule.c
+math mathmodule.c _math.c -DPy_BUILD_CORE_MODULE
+parser parsermodule.c
+pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY -DUSE_PYEXPAT_CAPI
+select selectmodule.c
+syslog syslogmodule.c
+unicodedata unicodedata.c
+xxlimited xxlimited.c
+xxsubtype xxsubtype.c
+
+*disabled*
+# Not building, patch Python some more or fix LibC...
+_decimal _socket mmap resource spwd termios
+
+# Linker errors
+_lsprof _multiprocessing
+
+# Lots and lots of linker errors, although these flags should be correct:
+_curses _cursesmodule.c -I$(SERENITY_ROOT)/Build/Root/usr/local/include/ncurses -L$(SERENITY_ROOT)/Build/Root/usr/local/lib -lncurses -ltermcap
diff --git a/Ports/python3/package.sh b/Ports/python3/package.sh
index 71fc877b7d..638d9bd56f 100755
--- a/Ports/python3/package.sh
+++ b/Ports/python3/package.sh
@@ -25,6 +25,10 @@ configopts="--build=${BUILD} --without-ensurepip ac_cv_file__dev_ptmx=no ac_cv_f
export BLDSHARED="${CC} -shared"
+post_configure() {
+ run cp "${SERENITY_ROOT}/Ports/${port}/Setup.local" "Modules/Setup.local"
+}
+
if [ -x "$(command -v python3)" ]; then
# Check if major and minor version of python3 are matching
if ! python3 -c "import sys; major, minor, _ = map(int, '${PYTHON_VERSION}'.split('.')); sys.exit(not (sys.version_info.major == major and sys.version_info.minor == minor))"; then