From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C6789158086 for ; Sun, 17 Oct 2021 05:24:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B781EE087A; Sun, 17 Oct 2021 05:24:47 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 83C62E087A for ; Sun, 17 Oct 2021 05:24:47 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CA0AD34341A for ; Sun, 17 Oct 2021 05:24:45 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3FC9A14C for ; Sun, 17 Oct 2021 05:24:44 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1634448272.c309652d566cedeb0c93c8b1a08569f54545d354.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/ocaml/, dev-lang/ocaml/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-lang/ocaml/files/ocaml-4.11.2-glibc-2.34.patch dev-lang/ocaml/ocaml-4.11.2-r2.ebuild X-VCS-Directories: dev-lang/ocaml/ dev-lang/ocaml/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: c309652d566cedeb0c93c8b1a08569f54545d354 X-VCS-Branch: master Date: Sun, 17 Oct 2021 05:24:44 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6454a796-7b25-4dc4-b23b-b05da3ebfe95 X-Archives-Hash: 0a473446dae1620ae37c8505ac71e89c commit: c309652d566cedeb0c93c8b1a08569f54545d354 Author: Sam James gentoo org> AuthorDate: Sun Oct 17 05:16:49 2021 +0000 Commit: Sam James gentoo org> CommitDate: Sun Oct 17 05:24:32 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c309652d dev-lang/ocaml: fix build with glibc-2.34 in 4.11.2 Closes: https://bugs.gentoo.org/804498 Signed-off-by: Sam James gentoo.org> dev-lang/ocaml/files/ocaml-4.11.2-glibc-2.34.patch | 91 ++++++++++++++++++++++ dev-lang/ocaml/ocaml-4.11.2-r2.ebuild | 4 + 2 files changed, 95 insertions(+) diff --git a/dev-lang/ocaml/files/ocaml-4.11.2-glibc-2.34.patch b/dev-lang/ocaml/files/ocaml-4.11.2-glibc-2.34.patch new file mode 100644 index 00000000000..22cbb806e6e --- /dev/null +++ b/dev-lang/ocaml/files/ocaml-4.11.2-glibc-2.34.patch @@ -0,0 +1,91 @@ +https://gitlab.com/redhat/centos-stream/rpms/ocaml/-/raw/c9s/0006-Dynamically-allocate-the-alternate-signal-stack-1026.patch +https://bugs.gentoo.org/804498 + +From 24a9db7784ddfcf0af2d2be2f51616ed960ae7e8 Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Fri, 5 Mar 2021 19:14:07 +0100 +Subject: [PATCH 6/6] 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 +@@ -82,7 +82,7 @@ void caml_set_action_pending (void); + value caml_do_pending_actions_exn (void); + value caml_process_pending_actions_with_root (value extra_root); // raises + int caml_set_signal_action(int signo, int action); +-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 +@@ -86,4 +86,4 @@ int caml_set_signal_action(int signo, int action) + return 0; + } + +-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 +@@ -195,8 +195,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 +@@ -282,28 +280,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 + } + +-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.11.2-r2.ebuild b/dev-lang/ocaml/ocaml-4.11.2-r2.ebuild index 2d52afb654e..51cc9f56afa 100644 --- a/dev-lang/ocaml/ocaml-4.11.2-r2.ebuild +++ b/dev-lang/ocaml/ocaml-4.11.2-r2.ebuild @@ -21,6 +21,10 @@ BDEPEND="${RDEPEND} PDEPEND="emacs? ( app-emacs/ocaml-mode ) xemacs? ( app-xemacs/ocaml )" +PATCHES=( + "${FILESDIR}"/${PN}-4.11.2-glibc-2.34.patch +) + src_prepare() { default