From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/ocaml/, dev-lang/ocaml/files/
Date: Sat, 9 Oct 2021 05:56:06 +0000 (UTC) [thread overview]
Message-ID: <1633758951.474a14bc9ede109fb7a8033667f42b6f63720962.sam@gentoo> (raw)
commit: 474a14bc9ede109fb7a8033667f42b6f63720962
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 9 05:54:21 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Oct 9 05:55:51 2021 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=474a14bc
dev-lang/ocaml: fix build with glibc 2.34
Closes: https://bugs.gentoo.org/816765
Signed-off-by: Sam James <sam <AT> gentoo.org>
dev-lang/ocaml/files/ocaml-4.12.0-glibc-2.34.patch | 91 ++++++++++++++++++++++
dev-lang/ocaml/ocaml-4.12.0-r2.ebuild | 4 +
dev-lang/ocaml/ocaml-4.12.1.ebuild | 4 +
3 files changed, 99 insertions(+)
diff --git a/dev-lang/ocaml/files/ocaml-4.12.0-glibc-2.34.patch b/dev-lang/ocaml/files/ocaml-4.12.0-glibc-2.34.patch
new file mode 100644
index 00000000000..486b44846a8
--- /dev/null
+++ b/dev-lang/ocaml/files/ocaml-4.12.0-glibc-2.34.patch
@@ -0,0 +1,91 @@
+https://src.fedoraproject.org/rpms/ocaml/blob/129153b85109944bf0b2922949f77ef8f32b39a1/f/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch
+https://bugs.gentoo.org/816765
+
+From 3104d92743614f8f52039e0520116af4179880a5 Mon Sep 17 00:00:00 2001
+From: Xavier Leroy <xavierleroy@users.noreply.github.com>
+Date: Fri, 5 Mar 2021 19:14:07 +0100
+Subject: [PATCH 4/4] Dynamically allocate the alternate signal stack (#10266)
+
+In Glibc 2.34 and later, SIGSTKSZ may not be a compile-time constant.
+It is no longer possible to statically allocate the alternate signal
+stack for the main thread, as we've been doing for the last 25 years.
+
+This commit implements dynamic allocation of the alternate signal stack
+even for the main thread. It reuses the code already in place to allocate
+the alternate signal stack for other threads.
+
+Fixes: #10250.
+(cherry picked from commit fc9534746bf5d08a4c109f22e344cf49d5d46d54)
+--- a/runtime/caml/signals.h
++++ b/runtime/caml/signals.h
+@@ -87,7 +87,7 @@ value caml_do_pending_actions_exn (void);
+ value caml_process_pending_actions_with_root (value extra_root); // raises
+ value caml_process_pending_actions_with_root_exn (value extra_root);
+ int caml_set_signal_action(int signo, int action);
+-CAMLextern void caml_setup_stack_overflow_detection(void);
++CAMLextern int caml_setup_stack_overflow_detection(void);
+
+ CAMLextern void (*caml_enter_blocking_section_hook)(void);
+ CAMLextern void (*caml_leave_blocking_section_hook)(void);
+--- a/runtime/signals_byt.c
++++ b/runtime/signals_byt.c
+@@ -81,4 +81,4 @@ int caml_set_signal_action(int signo, int action)
+ return 0;
+ }
+
+-CAMLexport void caml_setup_stack_overflow_detection(void) {}
++CAMLexport int caml_setup_stack_overflow_detection(void) { return 0; }
+--- a/runtime/signals_nat.c
++++ b/runtime/signals_nat.c
+@@ -181,8 +181,6 @@ DECLARE_SIGNAL_HANDLER(trap_handler)
+ #error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined"
+ #endif
+
+-static char sig_alt_stack[SIGSTKSZ];
+-
+ /* Code compiled with ocamlopt never accesses more than
+ EXTRA_STACK bytes below the stack pointer. */
+ #define EXTRA_STACK 256
+@@ -276,28 +274,33 @@ void caml_init_signals(void)
+ #endif
+
+ #ifdef HAS_STACK_OVERFLOW_DETECTION
+- {
+- stack_t stk;
++ if (caml_setup_stack_overflow_detection() != -1) {
+ struct sigaction act;
+- stk.ss_sp = sig_alt_stack;
+- stk.ss_size = SIGSTKSZ;
+- stk.ss_flags = 0;
+ SET_SIGACT(act, segv_handler);
+ act.sa_flags |= SA_ONSTACK | SA_NODEFER;
+ sigemptyset(&act.sa_mask);
+- if (sigaltstack(&stk, NULL) == 0) { sigaction(SIGSEGV, &act, NULL); }
++ sigaction(SIGSEGV, &act, NULL);
+ }
+ #endif
+ }
+
+-CAMLexport void caml_setup_stack_overflow_detection(void)
++/* Allocate and select an alternate stack for handling signals,
++ especially SIGSEGV signals.
++ Each thread needs its own alternate stack.
++ The alternate stack used to be statically-allocated for the main thread,
++ but this is incompatible with Glibc 2.34 and newer, where SIGSTKSZ
++ may not be a compile-time constant (issue #10250). */
++
++CAMLexport int caml_setup_stack_overflow_detection(void)
+ {
+ #ifdef HAS_STACK_OVERFLOW_DETECTION
+ stack_t stk;
+ stk.ss_sp = malloc(SIGSTKSZ);
++ if (stk.ss_sp == NULL) return -1;
+ stk.ss_size = SIGSTKSZ;
+ stk.ss_flags = 0;
+- if (stk.ss_sp)
+- sigaltstack(&stk, NULL);
++ return sigaltstack(&stk, NULL);
++#else
++ return 0;
+ #endif
+ }
diff --git a/dev-lang/ocaml/ocaml-4.12.0-r2.ebuild b/dev-lang/ocaml/ocaml-4.12.0-r2.ebuild
index da99522c6e3..287a7f38e79 100644
--- a/dev-lang/ocaml/ocaml-4.12.0-r2.ebuild
+++ b/dev-lang/ocaml/ocaml-4.12.0-r2.ebuild
@@ -20,6 +20,10 @@ BDEPEND="${RDEPEND}
PDEPEND="emacs? ( app-emacs/ocaml-mode )
xemacs? ( app-xemacs/ocaml )"
+PATCHES=(
+ "${FILESDIR}"/${PN}-4.12.0-glibc-2.34.patch
+)
+
src_prepare() {
default
diff --git a/dev-lang/ocaml/ocaml-4.12.1.ebuild b/dev-lang/ocaml/ocaml-4.12.1.ebuild
index da99522c6e3..287a7f38e79 100644
--- a/dev-lang/ocaml/ocaml-4.12.1.ebuild
+++ b/dev-lang/ocaml/ocaml-4.12.1.ebuild
@@ -20,6 +20,10 @@ BDEPEND="${RDEPEND}
PDEPEND="emacs? ( app-emacs/ocaml-mode )
xemacs? ( app-xemacs/ocaml )"
+PATCHES=(
+ "${FILESDIR}"/${PN}-4.12.0-glibc-2.34.patch
+)
+
src_prepare() {
default
next reply other threads:[~2021-10-09 5:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-09 5:56 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-03-29 12:09 [gentoo-commits] repo/gentoo:master commit in: dev-lang/ocaml/, dev-lang/ocaml/files/ Mark Wright
2022-02-27 6:27 Sam James
2022-02-25 19:58 Alfredo Tupone
2022-02-22 0:56 Sam James
2022-02-22 0:41 Sam James
2022-01-22 20:25 Alfredo Tupone
2021-10-17 5:24 Sam James
2021-01-28 22:15 Alfredo Tupone
2017-01-25 16:56 Alexis Ballier
2015-11-10 12:08 Alexis Ballier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1633758951.474a14bc9ede109fb7a8033667f42b6f63720962.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox