mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:18:14 +00:00
Ports: Remove obsolete patches for Python
This enables shared library support for Python and removes a few patches which are not necessary anymore now that we have dlfcn support.
This commit is contained in:
parent
f40ee1b03f
commit
adaf2b347c
7 changed files with 31 additions and 130 deletions
|
@ -1,77 +0,0 @@
|
||||||
# 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 -lcrypt -lcore
|
|
||||||
_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_BUILD_DIR)/Root/usr/local/include $(SERENITY_BUILD_DIR)/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
|
|
||||||
zlib zlibmodule.c -I$(SERENITY_BUILD_DIR)/Root/usr/local/include -L$(SERENITY_BUILD_DIR)/Root/usr/local/lib -lz
|
|
||||||
|
|
||||||
*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_BUILD_DIR)/Root/usr/local/include/ncurses -L$(SERENITY_BUILD_DIR)/Root/usr/local/lib -lncurses -ltermcap
|
|
|
@ -26,10 +26,6 @@ pre_configure() {
|
||||||
configopts="${configopts} --build=${build}"
|
configopts="${configopts} --build=${build}"
|
||||||
}
|
}
|
||||||
|
|
||||||
post_configure() {
|
|
||||||
run cp "${SERENITY_SOURCE_DIR}/Ports/${port}/Setup.local" "Modules/Setup.local"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Note: The showproperty command is used when linting ports, we don't actually need python at this time.
|
# Note: The showproperty command is used when linting ports, we don't actually need python at this time.
|
||||||
if [ "$1" != "showproperty" ]; then
|
if [ "$1" != "showproperty" ]; then
|
||||||
if [ -x "$(command -v python3)" ]; then
|
if [ -x "$(command -v python3)" ]; then
|
||||||
|
|
|
@ -16,16 +16,6 @@ Disables check for `RLIMIT_CORE` and subsequent `setrlimit()` call. Would be ena
|
||||||
|
|
||||||
As usual, make the `configure` script recognize Serenity.
|
As usual, make the `configure` script recognize Serenity.
|
||||||
|
|
||||||
## `fix-hidden-symbol-referenced-by-dso.patch`
|
|
||||||
|
|
||||||
Fix a weird build issue of `python` and other provided binaries by marking the `main()` functions `Py_EXPORTED_SYMBOL`.
|
|
||||||
|
|
||||||
```text
|
|
||||||
hidden symbol `main' in Programs/python.o is referenced by DSO
|
|
||||||
```
|
|
||||||
|
|
||||||
Not sure what the proper fix for this is, but it works fine.
|
|
||||||
|
|
||||||
## `remove-setlocale-from-preconfig.patch`
|
## `remove-setlocale-from-preconfig.patch`
|
||||||
|
|
||||||
Our stub implementation of `setlocale()` always returns `nullptr`, which the interpreter considers critical enough to exit right away.
|
Our stub implementation of `setlocale()` always returns `nullptr`, which the interpreter considers critical enough to exit right away.
|
||||||
|
@ -33,7 +23,3 @@ Our stub implementation of `setlocale()` always returns `nullptr`, which the int
|
||||||
## `tweak-unsupported-printf-format-specifiers.patch`
|
## `tweak-unsupported-printf-format-specifiers.patch`
|
||||||
|
|
||||||
Replace uses of `%.Ns` with `%s` as the former is not supported by our `printf` implementation yet and would result in empty strings. It uses `snprintf` already, so this is safe.
|
Replace uses of `%.Ns` with `%s` as the former is not supported by our `printf` implementation yet and would result in empty strings. It uses `snprintf` already, so this is safe.
|
||||||
|
|
||||||
## `use-rtld-lazy-for-dlopenflags.patch`
|
|
||||||
|
|
||||||
We have `RTLD_NOW` defined but don't actually support it, so use the provided `RTLD_LAZY` fallback. Doesn't help the dynamic library module import assertion though.
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
# in the case statement below.
|
# in the case statement below.
|
||||||
case "$host" in
|
case "$host" in
|
||||||
+ *-*-serenity*)
|
+ *-*-serenity*)
|
||||||
+ ac_sys_system=Serenity
|
+ ac_sys_system=SerenityOS
|
||||||
+ ;;
|
+ ;;
|
||||||
*-*-linux-android*)
|
*-*-linux-android*)
|
||||||
ac_sys_system=Linux-android
|
ac_sys_system=Linux-android
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
# in the case statement below.
|
# in the case statement below.
|
||||||
case "$host" in
|
case "$host" in
|
||||||
+ *-*-serenity*)
|
+ *-*-serenity*)
|
||||||
+ ac_sys_system=Serenity
|
+ ac_sys_system=SerenityOS
|
||||||
+ ;;
|
+ ;;
|
||||||
*-*-linux-android*)
|
*-*-linux-android*)
|
||||||
ac_sys_system=Linux-android
|
ac_sys_system=Linux-android
|
||||||
|
@ -53,3 +53,14 @@
|
||||||
*-*-linux*)
|
*-*-linux*)
|
||||||
case "$host_cpu" in
|
case "$host_cpu" in
|
||||||
arm*)
|
arm*)
|
||||||
|
diff -Naur Python-3.9.4/configure Python-3.9.4.serenity/configure
|
||||||
|
--- Python-3.9.4/configure 2021-04-24 14:50:59.083484421 +0200
|
||||||
|
+++ Python-3.9.4.serenity/configure 2021-04-24 15:50:26.821359967 +0200
|
||||||
|
@@ -9647,6 +9647,7 @@
|
||||||
|
# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
|
||||||
|
Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";;
|
||||||
|
Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
|
||||||
|
+ SerenityOS*) LINKFORSHARED="-Xlinker -export-dynamic";;
|
||||||
|
# -u libsys_s pulls in all symbols in libsys
|
||||||
|
Darwin/*)
|
||||||
|
LINKFORSHARED="$extra_undefs -framework CoreFoundation"
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
--- Python-3.9.4/Programs/python.c 2021-02-21 20:22:43.960024172 +0100
|
|
||||||
+++ Python-3.9.4/Programs/python.c 2021-02-21 20:35:13.268988119 +0100
|
|
||||||
@@ -9,7 +9,7 @@
|
|
||||||
return Py_Main(argc, argv);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
-int
|
|
||||||
+Py_EXPORTED_SYMBOL int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
return Py_BytesMain(argc, argv);
|
|
||||||
--- Python-3.9.4/Programs/_testembed.c 2021-02-21 20:22:43.959024178 +0100
|
|
||||||
+++ Python-3.9.4/Programs/_testembed.c 2021-02-21 20:35:13.270988109 +0100
|
|
||||||
@@ -1711,7 +1711,7 @@
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
-int main(int argc, char *argv[])
|
|
||||||
+Py_EXPORTED_SYMBOL int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
if (argc > 1) {
|
|
||||||
for (struct TestCase *tc = TestCases; tc && tc->name; tc++) {
|
|
|
@ -20,3 +20,21 @@
|
||||||
DATE, TIME);
|
DATE, TIME);
|
||||||
return buildinfo;
|
return buildinfo;
|
||||||
}
|
}
|
||||||
|
diff -Naur Python-3.9.4/Python/dynload_shlib.c Python-3.9.4.serenity/Python/dynload_shlib.c
|
||||||
|
--- Python-3.9.4/Python/dynload_shlib.c 2021-04-04 14:56:53.000000000 +0200
|
||||||
|
+++ Python-3.9.4.serenity/Python/dynload_shlib.c 2021-04-24 15:57:27.419824682 +0200
|
||||||
|
@@ -69,12 +69,12 @@
|
||||||
|
|
||||||
|
if (strchr(pathname, '/') == NULL) {
|
||||||
|
/* Prefix bare filename with "./" */
|
||||||
|
- PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname);
|
||||||
|
+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%s", pathname);
|
||||||
|
pathname = pathbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyOS_snprintf(funcname, sizeof(funcname),
|
||||||
|
- LEAD_UNDERSCORE "%.20s_%.200s", prefix, shortname);
|
||||||
|
+ LEAD_UNDERSCORE "%s_%s", prefix, shortname);
|
||||||
|
|
||||||
|
if (fp != NULL) {
|
||||||
|
int i;
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
--- Python-3.9.4/Python/pystate.c 2021-02-21 20:22:44.083023482 +0100
|
|
||||||
+++ Python-3.9.4/Python/pystate.c 2021-02-21 20:30:13.907513469 +0100
|
|
||||||
@@ -223,7 +223,7 @@
|
|
||||||
|
|
||||||
interp->eval_frame = _PyEval_EvalFrameDefault;
|
|
||||||
#ifdef HAVE_DLOPEN
|
|
||||||
-#if HAVE_DECL_RTLD_NOW
|
|
||||||
+#if defined(HAVE_DECL_RTLD_NOW) && !defined(__serenity__)
|
|
||||||
interp->dlopenflags = RTLD_NOW;
|
|
||||||
#else
|
|
||||||
interp->dlopenflags = RTLD_LAZY;
|
|
Loading…
Add table
Add a link
Reference in a new issue