diff --git a/pkgs/development/compilers/ocaml/4.10.nix b/pkgs/development/compilers/ocaml/4.10.nix index 78051040b57..48d01a5a8c8 100644 --- a/pkgs/development/compilers/ocaml/4.10.nix +++ b/pkgs/development/compilers/ocaml/4.10.nix @@ -3,4 +3,7 @@ import ./generic.nix { minor_version = "10"; patch_version = "2"; sha256 = "sha256-locUYQeCgtXbAiB32JveJchfteN2YStE+MN9ToTwAOM="; + patches = [ + ./glibc-2.34-for-ocaml-4.10-and-11.patch + ]; } diff --git a/pkgs/development/compilers/ocaml/4.11.nix b/pkgs/development/compilers/ocaml/4.11.nix index 3e5aefc11f1..6a2e4f61f80 100644 --- a/pkgs/development/compilers/ocaml/4.11.nix +++ b/pkgs/development/compilers/ocaml/4.11.nix @@ -3,4 +3,7 @@ import ./generic.nix { minor_version = "11"; patch_version = "2"; sha256 = "1m3wrgkkv3f77wvcymjm0i2srxzmx62y6jln3i0a2px07ng08l9z"; + patches = [ + ./glibc-2.34-for-ocaml-4.10-and-11.patch + ]; } diff --git a/pkgs/development/compilers/ocaml/generic.nix b/pkgs/development/compilers/ocaml/generic.nix index debc3d4272a..cd1bccd1800 100644 --- a/pkgs/development/compilers/ocaml/generic.nix +++ b/pkgs/development/compilers/ocaml/generic.nix @@ -35,6 +35,8 @@ let x11env = buildEnv { name = "x11env"; paths = [libX11 xorgproto]; }; x11lib = x11env + "/lib"; x11inc = x11env + "/include"; + + fetchpatch' = x: if builtins.isAttrs x then fetchpatch x else x; in stdenv.mkDerivation (args // { @@ -44,7 +46,7 @@ stdenv.mkDerivation (args // { inherit src; - patches = map fetchpatch patches; + patches = map fetchpatch' patches; strictDeps = true; diff --git a/pkgs/development/compilers/ocaml/glibc-2.34-for-ocaml-4.10-and-11.patch b/pkgs/development/compilers/ocaml/glibc-2.34-for-ocaml-4.10-and-11.patch new file mode 100644 index 00000000000..4ff9e6fddba --- /dev/null +++ b/pkgs/development/compilers/ocaml/glibc-2.34-for-ocaml-4.10-and-11.patch @@ -0,0 +1,37 @@ +From dfb5e954a04f59b0456cc4c0ddf3acaf22e0ff07 Mon Sep 17 00:00:00 2001 +From: Richard W.M. Jones +Date: Feb 28 2021 20:45:47 +0000 +Subject: Workaround for glibc non-constant SIGSTKSZ + + +https://github.com/ocaml/ocaml/issues/10250 + +Signed-off-by: Richard W.M. Jones + +--- + +diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c +index 8b64ab4..7f0a975 100644 +--- a/runtime/signals_nat.c ++++ b/runtime/signals_nat.c +@@ -181,7 +181,19 @@ DECLARE_SIGNAL_HANDLER(trap_handler) + #error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined" + #endif + ++#ifndef __GLIBC__ + static char sig_alt_stack[SIGSTKSZ]; ++#else ++/* glibc 2.34 has non-constant SIGSTKSZ */ ++static char *sig_alt_stack; ++ ++static void allocate_sig_alt_stack(void) __attribute__((constructor)); ++static void ++allocate_sig_alt_stack(void) ++{ ++ sig_alt_stack = malloc(SIGSTKSZ); ++} ++#endif + + /* Code compiled with ocamlopt never accesses more than + EXTRA_STACK bytes below the stack pointer. */ +