push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
{
lib,
stdenv,
fetchurl,
fetchpatch,
ncurses,
libX11,
}:
let
useX11 = !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isMips;
useNativeCompilers = !stdenv.hostPlatform.isMips;
inherit (lib) optional optionals optionalString;
in
stdenv.mkDerivation rec {
pname = "ocaml";
version = "4.00.1";
src = fetchurl {
url = "https://caml.inria.fr/pub/distrib/ocaml-4.00/${pname}-${version}.tar.bz2";
sha256 = "33c3f4acff51685f5bfd7c260f066645e767d4e865877bf1613c176a77799951";
};
# Compatibility with Glibc 2.34
patches = [
(fetchpatch {
url = "https://github.com/ocaml/ocaml/commit/60b0cdaf2519d881947af4175ac4c6ff68901be3.patch";
sha256 = "sha256:07g9q9sjk4xsbqix7jxggfp36v15pmqw4bms80g5car0hfbszirn";
})
];
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
prefixKey = "-prefix ";
configureFlags = [
"-no-tk"
]
++ optionals useX11 [
"-x11lib"
libX11
];
buildFlags = [
"world"
]
++ optionals useNativeCompilers [
"bootstrap"
"world.opt"
];
buildInputs = [ ncurses ] ++ optionals useX11 [ libX11 ];
installTargets = "install" + optionalString useNativeCompilers " installopt";
preConfigure = ''
CAT=$(type -tp cat)
sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
'';
postBuild = ''
mkdir -p $out/include
ln -sv $out/lib/ocaml/caml $out/include/caml
'';
passthru = {
nativeCompilers = useNativeCompilers;
};
meta = with lib; {
homepage = "http://caml.inria.fr/ocaml";
branch = "4.00";
license = with licenses; [
qpl # compiler
lgpl2 # library
];
description = "Most popular variant of the Caml language";
longDescription = ''
OCaml is the most popular variant of the Caml language. From a
language standpoint, it extends the core Caml language with a
fully-fledged object-oriented layer, as well as a powerful module
system, all connected by a sound, polymorphic type system featuring
type inference.
The OCaml system is an industrial-strength implementation of this
language, featuring a high-performance native-code compiler (ocamlopt)
for 9 processor architectures (IA32, PowerPC, AMD64, Alpha, Sparc,
Mips, IA64, HPPA, StrongArm), as well as a bytecode compiler (ocamlc)
and an interactive read-eval-print loop (ocaml) for quick development
and portability. The OCaml distribution includes a comprehensive
standard library, a replay debugger (ocamldebug), lexer (ocamllex) and
parser (ocamlyacc) generators, a pre-processor pretty-printer (camlp4)
and a documentation generator (ocamldoc).
'';
platforms = with platforms; linux;
};
}

View File

@@ -0,0 +1,21 @@
import ./generic.nix {
major_version = "4";
minor_version = "01";
patch_version = "0";
patches = [
./fix-clang-build-on-osx.diff
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/d111407bf4ff71171598d30825c8e59ed5f75fd6.patch";
sha256 = "sha256:08mpy7lsiwv8m5qrqc4xzyiv2hri5713gz2qs1nfz02hz1bd79mc";
}
];
sha256 = "03d7ida94s1gpr3gadf4jyhmh5rrszd5s4m4z59daaib25rvfyv7";
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,26 @@
import ./generic.nix {
major_version = "4";
minor_version = "02";
patch_version = "3";
patches = [
./ocamlbuild.patch
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/9de2b77472aee18a94b41cff70caee27fb901225.patch";
sha256 = "sha256:12sw512kpwk0xf2g6j0h5vqgd8xcmgrvgyilx6fxbd6bnfv1yib9";
}
# Compatibility with Binutils 2.29
{
url = "https://github.com/ocaml/ocaml/commit/bcc7a767279ff70518b3f4219cc0b9bffec7dd43.patch";
sha256 = "sha256-z3xrqN6bh/EW9dkPg6Hz8mT79DFm26yGRoPbE+RMYi0=";
}
];
sha256 = "1qwwvy8nzd87hk8rd9sm667nppakiapnx4ypdwcrlnav2dz6kil3";
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,25 @@
import ./generic.nix {
major_version = "4";
minor_version = "03";
patch_version = "0";
sha256 = "09p3iwwi55r6rbrpyp8f0wmkb0ppcgw67yxw6yfky60524wayp39";
patches = [
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/a8b2cc3b40f5269ce8525164ec2a63b35722b22b.patch";
sha256 = "sha256:1rrknmrk86xrj2k3hznnjk1gwnliyqh125zabg1hvy6dlvml9b0x";
}
# Compatibility with Binutils 2.29
{
url = "https://github.com/ocaml/ocaml/commit/c204f07bfb20174f9e1c9ff586fb7b2f42b8bf18.patch";
sha256 = "sha256-AAXyMZ7ujO67SGz+tGXKZkVcINAwvccHlFHmKnUt848=";
}
];
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,28 @@
import ./generic.nix {
major_version = "4";
minor_version = "04";
patch_version = "2";
sha256 = "0bhgjzi78l10824qga85nlh18jg9lb6aiamf9dah1cs6jhzfsn6i";
# If the executable is stripped it does not work
dontStrip = true;
patches = [
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/6bcff7e6ce1a43e088469278eb3a9341e6a2ca5b.patch";
sha256 = "sha256:1hd45f7mwwrrym2y4dbcwklpv0g94avbz7qrn81l7w8mrrj3bngi";
}
# Compatibility with Binutils 2.29
{
url = "https://github.com/ocaml/ocaml/commit/db11f141a0e35c7fbaec419a33c4c39d199e2635.patch";
sha256 = "sha256-oIwmbXOCzDGyASpbQ7hd7SCs4YHjd9hBBksJ74V3GiY=";
}
];
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,28 @@
import ./generic.nix {
major_version = "4";
minor_version = "05";
patch_version = "0";
sha256 = "1y9fw1ci9pwnbbrr9nwr8cq8vypcxwdf4akvxard3mxl2jx2g984";
# If the executable is stipped it does not work
dontStrip = true;
patches = [
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/50c2d1275e537906ea144bd557fde31e0bf16e5f.patch";
sha256 = "sha256:0ck9b2dpgg5k2p9ndbgniql24h35pn1bbpxjvk69j715lswzy4mh";
}
# Compatibility with Binutils 2.29
{
url = "https://github.com/ocaml/ocaml/commit/b00000c6679804731692362b0baac27fa3fddfd5.patch";
sha256 = "sha256-CuEXGK3EsOevyUrc9TmSZo9DVBwjunQX7mKnDVHFpkY=";
}
];
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,23 @@
import ./generic.nix {
major_version = "4";
minor_version = "06";
patch_version = "1";
sha256 = "1n3pygfssd6nkrq876wszm5nm3v4605q4k16a66h1nmq9wvf01vg";
# If the executable is stripped it does not work
dontStrip = true;
patches = [
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/137a4ad167f25fe1bee792977ed89f30d19bcd74.patch";
sha256 = "sha256:0izsf6rm3677vbbx0snkmn9pkfcsayrdwz3ipiml5wjiaysnchjz";
}
];
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,23 @@
import ./generic.nix {
major_version = "4";
minor_version = "07";
patch_version = "1";
sha256 = "1f07hgj5k45cylj1q3k5mk8yi02cwzx849b1fwnwia8xlcfqpr6z";
# If the executable is stripped it does not work
dontStrip = true;
patches = [
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/00b8c4d503732343d5d01761ad09650fe50ff3a0.patch";
sha256 = "sha256:02cfya5ff5szx0fsl5x8ax76jyrla9zmf3qxavf3adhwq5ssrfcv";
}
];
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,26 @@
import ./generic.nix {
major_version = "4";
minor_version = "08";
patch_version = "1";
sha256 = "18sycl3zmgb8ghpxymriy5d72gvw7m5ra65v51hcrmzzac21hkyd";
# If the executable is stripped it does not work
dontStrip = true;
# Breaks build with Clang
hardeningDisable = [ "strictoverflow" ];
patches = [
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/17df117b4939486d3285031900587afce5262c8c.patch";
sha256 = "sha256:1b3jc6sj2k23yvfwrv6nc1f4x2n2biqbhbbp74aqb6iyqyjsq35n";
}
];
# Workaround build failure on -fno-common toolchains like upstream
# gcc-10. Otherwise build fails as:
# ld: libcamlrun.a(startup.o):(.bss+0x800): multiple definition of
# `caml_code_fragments_table'; libcamlrun.a(backtrace.o):(.bss+0x20): first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";
}

View File

@@ -0,0 +1,16 @@
The 4.09.1 tarball appears to have been acidentally generated as a
development tarball, which causes configure to enable -Werror. This
means newer compilers will make the build fail.
diff a/configure b/configure
--- a/configure
+++ b/configure
@@ -12360,7 +12360,7 @@ case $ocaml_cv_cc_vendor in #(
msvc-*) :
outputobj=-Fo; CPP="cl -nologo -EP"; gcc_warnings="" ;; #(
*) :
- outputobj='-o $(EMPTY)'; case 4.09.1+dev1-2020-03-13 in #(
+ outputobj='-o $(EMPTY)'; case 4.09.1 in #(
*+dev*) :
gcc_warnings="-Wall -Werror" ;; #(
*) :

View File

@@ -0,0 +1,18 @@
import ./generic.nix {
major_version = "4";
minor_version = "09";
patch_version = "1";
sha256 = "1aq5505lpa39garky2icgfv4c7ylpx3j623cz9bsz5c466d2kqls";
# Breaks build with Clang
hardeningDisable = [ "strictoverflow" ];
patches = [
./4.09.1-Werror.patch
# Compatibility with Glibc 2.34
{
url = "https://github.com/ocaml/ocaml/commit/8eed2e441222588dc385a98ae8bd6f5820eb0223.patch";
sha256 = "sha256:1b3jc6sj2k23yvfwrv6nc1f4x2n2biqbhbbp74aqb6iyqyjsq35n";
}
];
}

View File

@@ -0,0 +1,9 @@
import ./generic.nix {
major_version = "4";
minor_version = "10";
patch_version = "2";
sha256 = "sha256-locUYQeCgtXbAiB32JveJchfteN2YStE+MN9ToTwAOM=";
patches = [
./glibc-2.34-for-ocaml-4.10-and-11.patch
];
}

View File

@@ -0,0 +1,9 @@
import ./generic.nix {
major_version = "4";
minor_version = "11";
patch_version = "2";
sha256 = "1m3wrgkkv3f77wvcymjm0i2srxzmx62y6jln3i0a2px07ng08l9z";
patches = [
./glibc-2.34-for-ocaml-4.10-and-11.patch
];
}

View File

@@ -0,0 +1,12 @@
import ./generic.nix {
major_version = "4";
minor_version = "12";
patch_version = "1";
sha256 = "1jbjjnmqq6ymsy81x188i256bz4z5jrz1pws8g1qf59c32ganjkf";
patches = [
{
url = "https://src.fedoraproject.org/rpms/ocaml/raw/129153b85109944bf0b2922949f77ef8f32b39a1/f/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch";
sha256 = "sha256-FdQ1HkMKHU9QvgLPUBvMdPiEa7w7IL3+1F3SLv63Gog=";
}
];
}

View File

@@ -0,0 +1,6 @@
import ./generic.nix {
major_version = "4";
minor_version = "13";
patch_version = "1";
sha256 = "sha256:1s7xwqidpjwfhnpfma4nb93gxfr7g9jfn03s1j03iyavmpgph7ck";
}

View File

@@ -0,0 +1,6 @@
import ./generic.nix {
major_version = "4";
minor_version = "14";
patch_version = "2";
sha256 = "sha256-eBn2hpPjKUb5M1jfRqjqb1FyImgfzG98uWIUIWz+x2Q=";
}

View File

@@ -0,0 +1,6 @@
import ./generic.nix {
major_version = "5";
minor_version = "0";
patch_version = "0";
sha256 = "sha256-yxfwpTTdSz/sk9ARsL4bpcYIfaAzz3iehaNLlkHsxl8=";
}

View File

@@ -0,0 +1,6 @@
import ./generic.nix {
major_version = "5";
minor_version = "1";
patch_version = "1";
sha256 = "sha256-jX6Yv9o76UBgK3o53PkSotL96reR7UDmKgmkzWfd7vE=";
}

View File

@@ -0,0 +1,6 @@
import ./generic.nix {
major_version = "5";
minor_version = "2";
patch_version = "1";
sha256 = "sha256-Bs2noj15wdOzazqnKDpe1YeY3dhx8sJpcSYR3Gn1c7I=";
}

View File

@@ -0,0 +1,6 @@
import ./generic.nix {
major_version = "5";
minor_version = "3";
patch_version = "0";
sha256 = "sha256-sCKTNtnr4K+QWVS80a5bKTMGu8sIwB6tA1ANnlvJAWQ=";
}

View File

@@ -0,0 +1,16 @@
# ocaml build system does not allow for parallel building of some
# top-level targets like 'world', 'bootstrap', 'world.opt' as
# then spawn '$(MAKE) all' subprocesses that conflict among each
# other. But we would still like to run each target in parallel
# individually. This file defines such entry points.
# Re-export all existing phases to make 'make install' work as is.
include Makefile
nixpkgs_world:
$(MAKE) world
nixpkgs_world_bootstrap_world_opt:
$(MAKE) world
$(MAKE) bootstrap
$(MAKE) world.opt

View File

@@ -0,0 +1,107 @@
{
lib,
stdenv,
fetchurl,
ncurses,
libX11,
xorgproto,
buildEnv,
useX11 ? stdenv.hostPlatform.isx86,
}:
let
x11deps = [
libX11
xorgproto
];
inherit (lib) optionals;
baseOcamlBranch = "4.14";
baseOcamlVersion = "${baseOcamlBranch}.1";
metaocamlPatch = "114";
in
stdenv.mkDerivation rec {
pname = "ber-metaocaml";
version = metaocamlPatch;
src = fetchurl {
url = "https://caml.inria.fr/pub/distrib/ocaml-${baseOcamlBranch}/ocaml-${baseOcamlVersion}.tar.gz";
sha256 = "sha256-GDl53JwJyw9YCiMraFMaCbAlqmKLjY1ydEnxRv1vX+4=";
};
metaocaml = fetchurl {
url = "http://okmij.org/ftp/ML/ber-metaocaml-${metaocamlPatch}.tar.gz";
sha256 = "sha256-vvq3xI4jSAsrXcDk97TPbFDYgO9NcQeN/yBcUbcb/y0=";
};
x11env = buildEnv {
name = "x11env";
paths = x11deps;
};
x11lib = "${x11env}/lib";
x11inc = "${x11env}/include";
prefixKey = "-prefix ";
configureFlags = optionals useX11 [ "--enable-flambda" ];
dontStrip = true;
buildInputs = [ ncurses ] ++ optionals useX11 x11deps;
postConfigure = ''
tar -xvzf $metaocaml
cd ${pname}-${version}
make patch
cd ..
'';
buildPhase = ''
make world
make bootstrap
make opt.opt
make -i install
make installopt
mkdir -p $out/include
ln -sv $out/lib/ocaml/caml $out/include/caml
cd ${pname}-${version}
make all
'';
installPhase = ''
make install
make install.opt
'';
checkPhase = ''
cd ${pname}-${version}
make test
make test-compile
make test-native
cd ..
'';
passthru = {
nativeCompilers = true;
};
meta = with lib; {
description = "Multi-Stage Programming extension for OCaml";
homepage = "https://okmij.org/ftp/ML/MetaOCaml.html";
license = with licenses; [
# compiler
qpl # library
lgpl2
];
maintainers = with maintainers; [ thoughtpolice ];
branch = baseOcamlBranch;
platforms = with platforms; linux ++ darwin;
broken = stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isMips;
longDescription = ''
A simple extension of OCaml with the primitive type of code values, and
three basic multi-stage expression forms: Brackets, Escape, and Run.
'';
};
}

View File

@@ -0,0 +1,20 @@
diff --git a/configure b/configure
index d45e88f..25d872b 100755
--- a/configure
+++ b/configure
@@ -322,7 +322,14 @@ case "$bytecc,$target" in
bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
mathlib="";;
*,*-*-darwin*)
- bytecccompopts="-fno-defer-pop $gcc_warnings"
+ # On recent version of OSX, gcc is a symlink to clang
+ if $bytecc --version | grep -q clang; then
+ # -fno-defer-pop is not supported by clang, and make recent
+ # versions of clang to fail
+ bytecccompopts="$gcc_warnings"
+ else
+ bytecccompopts="-fno-defer-pop $gcc_warnings"
+ fi
mathlib=""
mkexe="$mkexe -Wl,-no_compact_unwind"
# Tell gcc that we can use 32-bit code addresses for threaded code

View File

@@ -0,0 +1,226 @@
{
minor_version,
major_version,
patch_version,
patches ? [ ],
...
}@args:
let
versionNoPatch = "${toString major_version}.${toString minor_version}";
version = "${versionNoPatch}.${toString patch_version}";
safeX11 =
stdenv:
!(stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isMips || stdenv.hostPlatform.isStatic);
in
{
lib,
stdenv,
fetchurl,
ncurses,
binutils,
buildEnv,
libunwind,
fetchpatch,
libX11,
xorgproto,
useX11 ? safeX11 stdenv && lib.versionOlder version "4.09",
aflSupport ? false,
flambdaSupport ? false,
spaceTimeSupport ? false,
unsafeStringSupport ? false,
framePointerSupport ? false,
noNakedPointers ? false,
}:
assert useX11 -> safeX11 stdenv;
assert aflSupport -> lib.versionAtLeast version "4.05";
assert flambdaSupport -> lib.versionAtLeast version "4.03";
assert spaceTimeSupport -> lib.versionAtLeast version "4.04" && lib.versionOlder version "4.12";
assert unsafeStringSupport -> lib.versionAtLeast version "4.06" && lib.versionOlder version "5.0";
assert framePointerSupport -> lib.versionAtLeast version "4.01";
assert noNakedPointers -> lib.versionAtLeast version "4.02" && lib.versionOlder version "5.0";
let
src =
args.src or (fetchurl {
url =
args.url or "http://caml.inria.fr/pub/distrib/ocaml-${versionNoPatch}/ocaml-${version}.tar.xz";
inherit (args) sha256;
});
in
let
useNativeCompilers = !stdenv.hostPlatform.isMips && !stdenv.hostPlatform.isLoongArch64;
inherit (lib)
optional
optionals
optionalString
strings
concatStrings
;
pname = concatStrings [
"ocaml"
(optionalString aflSupport "+afl")
(optionalString spaceTimeSupport "+spacetime")
(optionalString flambdaSupport "+flambda")
(optionalString framePointerSupport "+fp")
];
in
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
// {
inherit pname version src;
patches = map fetchpatch' patches;
strictDeps = true;
prefixKey = "-prefix ";
configureFlags =
let
flags = new: old: if lib.versionAtLeast version "4.08" then new else old;
in
optionals useX11 (
flags
[ "--x-libraries=${x11lib}" "--x-includes=${x11inc}" ]
[ "-x11lib" x11lib "-x11include" x11inc ]
)
++ optional aflSupport (flags "--with-afl" "-afl-instrument")
++ optional flambdaSupport (flags "--enable-flambda" "-flambda")
++ optional spaceTimeSupport (flags "--enable-spacetime" "-spacetime")
++ optional framePointerSupport (flags "--enable-frame-pointers" "-with-frame-pointers")
++ optionals unsafeStringSupport [
"--disable-force-safe-string"
"DEFAULT_STRING=unsafe"
]
++ optional (stdenv.hostPlatform.isStatic && (lib.versionOlder version "4.08")) "-no-shared-libs"
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform && lib.versionOlder version "4.08") [
"-host ${stdenv.hostPlatform.config}"
"-target ${stdenv.targetPlatform.config}"
]
++ optional noNakedPointers (flags "--disable-naked-pointers" "-no-naked-pointers");
dontAddStaticConfigureFlags = lib.versionOlder version "4.08";
# on aarch64-darwin using --host and --target causes the build to invoke
# `aarch64-apple-darwin-clang` while using assembler. However, such binary
# does not exist. So, disable these configure flags on `aarch64-darwin`.
# See #144785 for details.
configurePlatforms =
lib.optionals
(
lib.versionAtLeast version "4.08"
&& !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
)
[
"host"
"target"
];
# x86_64-unknown-linux-musl-ld: -r and -pie may not be used together
hardeningDisable =
lib.optional (lib.versionAtLeast version "4.09" && stdenv.hostPlatform.isMusl) "pie"
++ lib.optional (lib.versionAtLeast version "5.0" && stdenv.cc.isClang) "strictoverflow"
++ lib.optionals (args ? hardeningDisable) args.hardeningDisable;
# Older versions have some race:
# cp: cannot stat 'boot/ocamlrun': No such file or directory
# make[2]: *** [Makefile:199: backup] Error 1
enableParallelBuilding = lib.versionAtLeast version "4.08";
# Workaround missing dependencies for install parallelism:
# install: target '...-ocaml-4.14.0/lib/ocaml/threads': No such file or directory
# make[1]: *** [Makefile:140: installopt] Error 1
enableParallelInstalling = false;
# Workaround lack of parallelism support among top-level targets:
# we place nixpkgs-specific targets to a separate file and set
# sequential order among them as a single rule.
makefile = ./Makefile.nixpkgs;
buildFlags =
if useNativeCompilers then
[
(if lib.versionOlder version "5.2" then "nixpkgs_world_bootstrap_world_opt" else "defaultentry")
]
else
[ "nixpkgs_world" ];
buildInputs =
optional (lib.versionOlder version "4.07") ncurses
++ optionals useX11 [
libX11
xorgproto
];
depsBuildBuild = lib.optionals (!stdenv.hostPlatform.isDarwin) [ binutils ];
propagatedBuildInputs = optional spaceTimeSupport libunwind;
installTargets = [ "install" ] ++ optional useNativeCompilers "installopt";
preConfigure =
optionalString (lib.versionOlder version "4.04") ''
CAT=$(type -tp cat)
sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
''
+ optionalString (stdenv.hostPlatform.isDarwin) ''
# Do what upstream does by default now: https://github.com/ocaml/ocaml/pull/10176
# This is required for aarch64-darwin, everything else works as is.
AS="${stdenv.cc}/bin/cc -c" ASPP="${stdenv.cc}/bin/cc -c"
''
+ optionalString (lib.versionOlder version "4.08" && stdenv.hostPlatform.isStatic) ''
configureFlagsArray+=("-cc" "$CC" "-as" "$AS" "-partialld" "$LD -r")
'';
postBuild = ''
mkdir -p $out/include
ln -sv $out/lib/ocaml/caml $out/include/caml
'';
passthru = {
nativeCompilers = useNativeCompilers;
};
meta = with lib; {
homepage = "https://ocaml.org/";
branch = versionNoPatch;
license = with licenses; [
qpl # compiler
lgpl2 # library
];
description = "OCaml is an industrial-strength programming language supporting functional, imperative and object-oriented styles";
longDescription = ''
OCaml is a general purpose programming language with an emphasis on expressiveness and safety. Developed for more than 20 years at Inria by a group of leading researchers, it has an advanced type system that helps catch your mistakes without getting in your way. It's used in environments where a single mistake can cost millions and speed matters, is supported by an active community, and has a rich set of libraries and development tools. It's widely used in teaching for its power and simplicity.
Strengths:
* A powerful type system, equipped with parametric polymorphism and type inference. For instance, the type of a collection can be parameterized by the type of its elements. This allows defining some operations over a collection independently of the type of its elements: sorting an array is one example. Furthermore, type inference allows defining such operations without having to explicitly provide the type of their parameters and result.
* User-definable algebraic data types and pattern-matching. New algebraic data types can be defined as combinations of records and sums. Functions that operate over such data structures can then be defined by pattern matching, a generalized form of the well-known switch statement, which offers a clean and elegant way of simultaneously examining and naming data.
* Automatic memory management, thanks to a fast, unobtrusive, incremental garbage collector.
* Separate compilation of standalone applications. Portable bytecode compilers allow creating stand-alone applications out of Caml Light or OCaml programs. A foreign function interface allows OCaml code to interoperate with C code when necessary. Interactive use of OCaml is also supported via a read-evaluate-print loop.
In addition, OCaml features:
* A sophisticated module system, which allows organizing modules hierarchically and parameterizing a module over a number of other modules.
* An expressive object-oriented layer, featuring multiple inheritance, parametric and virtual classes.
* Efficient native code compilers. In addition to its bytecode compiler, OCaml offers a compiler that produces efficient machine code for many architectures.
Learn more at: https://ocaml.org/learn/description.html
'';
platforms = with platforms; linux ++ darwin;
broken =
stdenv.hostPlatform.isAarch64
&& lib.versionOlder version (if stdenv.hostPlatform.isDarwin then "4.10" else "4.02");
};
}
)

View File

@@ -0,0 +1,37 @@
From dfb5e954a04f59b0456cc4c0ddf3acaf22e0ff07 Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones@redhat.com>
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 <rjones@redhat.com>
---
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. */

View File

@@ -0,0 +1,45 @@
Author: Vincent Laporte <Vincent.Laporte@gmail.com>
Date: Sun Feb 1 11:19:50 2015 +0100
ocamlbuild: use ocamlfind to discover camlp4 path
and default to `+camlp4`
diff --git a/ocamlbuild/ocaml_specific.ml b/ocamlbuild/ocaml_specific.ml
index b902810..a73b7a5 100644
--- a/ocamlbuild/ocaml_specific.ml
+++ b/ocamlbuild/ocaml_specific.ml
@@ -698,15 +698,25 @@ ocaml_lib ~extern:true ~tag_name:"use_toplevel" "toplevellib";;
ocaml_lib ~extern:true ~dir:"+ocamldoc" "ocamldoc";;
ocaml_lib ~extern:true ~dir:"+ocamlbuild" ~tag_name:"use_ocamlbuild" "ocamlbuildlib";;
-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4" "camlp4lib";;
-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_old_camlp4" "camlp4";;
-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4_full" "camlp4fulllib";;
+let camlp4dir =
+ Findlib.(
+ try
+ if sys_command "sh -c 'ocamlfind list >/dev/null' 2>/dev/null" != 0
+ then raise (Findlib_error Cannot_run_ocamlfind);
+ (query "camlp4").location
+ with Findlib_error _ ->
+ "+camlp4"
+ );;
+
+ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4" "camlp4lib";;
+ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_old_camlp4" "camlp4";;
+ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4_full" "camlp4fulllib";;
flag ["ocaml"; "compile"; "use_camlp4_full"]
- (S[A"-I"; A"+camlp4/Camlp4Parsers";
- A"-I"; A"+camlp4/Camlp4Printers";
- A"-I"; A"+camlp4/Camlp4Filters"]);;
-flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A"+camlp4/Camlp4Bin.cmo");;
-flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A"+camlp4/Camlp4Bin.cmx");;
+ (S[A"-I"; A(camlp4dir^"/Camlp4Parsers");
+ A"-I"; A(camlp4dir^"/Camlp4Printers");
+ A"-I"; A(camlp4dir^"/Camlp4Filters")]);;
+flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A(camlp4dir^"/Camlp4Bin.cmo"));;
+flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A(camlp4dir^"/Camlp4Bin.cmx"));;
flag ["ocaml"; "debug"; "compile"; "byte"] (A "-g");;
flag ["ocaml"; "debug"; "link"; "byte"; "program"] (A "-g");;