1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:37:44 +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:
Gunnar Beutner 2021-04-24 20:33:16 +02:00 committed by Andreas Kling
parent f40ee1b03f
commit adaf2b347c
7 changed files with 31 additions and 130 deletions

View file

@ -16,16 +16,6 @@ Disables check for `RLIMIT_CORE` and subsequent `setrlimit()` call. Would be ena
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`
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`
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.

View file

@ -16,7 +16,7 @@
# in the case statement below.
case "$host" in
+ *-*-serenity*)
+ ac_sys_system=Serenity
+ ac_sys_system=SerenityOS
+ ;;
*-*-linux-android*)
ac_sys_system=Linux-android
@ -38,7 +38,7 @@
# in the case statement below.
case "$host" in
+ *-*-serenity*)
+ ac_sys_system=Serenity
+ ac_sys_system=SerenityOS
+ ;;
*-*-linux-android*)
ac_sys_system=Linux-android
@ -53,3 +53,14 @@
*-*-linux*)
case "$host_cpu" in
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"

View file

@ -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++) {

View file

@ -20,3 +20,21 @@
DATE, TIME);
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;

View file

@ -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;