summaryrefslogtreecommitdiff
path: root/dev-lang/ocaml
diff options
context:
space:
mode:
Diffstat (limited to 'dev-lang/ocaml')
-rw-r--r--dev-lang/ocaml/Manifest12
-rw-r--r--dev-lang/ocaml/files/ocaml-4.05.0-CVE-2018-9838.patch70
-rw-r--r--dev-lang/ocaml/ocaml-4.05.0-r5.ebuild (renamed from dev-lang/ocaml/ocaml-4.05.0-r3.ebuild)2
-rw-r--r--dev-lang/ocaml/ocaml-4.05.0-r6.ebuild143
-rw-r--r--dev-lang/ocaml/ocaml-4.09.0-r1.ebuild (renamed from dev-lang/ocaml/ocaml-4.09.0.ebuild)2
-rw-r--r--dev-lang/ocaml/ocaml-4.10.2-r1.ebuild (renamed from dev-lang/ocaml/ocaml-4.10.2.ebuild)2
-rw-r--r--dev-lang/ocaml/ocaml-4.11.2-r1.ebuild (renamed from dev-lang/ocaml/ocaml-4.11.2.ebuild)2
-rw-r--r--dev-lang/ocaml/ocaml-4.12.0-r1.ebuild93
8 files changed, 318 insertions, 8 deletions
diff --git a/dev-lang/ocaml/Manifest b/dev-lang/ocaml/Manifest
index 62e83d6f0579..1c05a579b356 100644
--- a/dev-lang/ocaml/Manifest
+++ b/dev-lang/ocaml/Manifest
@@ -1,4 +1,5 @@
AUX ocaml-4.04.2-tinfo.patch 506 BLAKE2B 889c964385442247a70b7205abc497a8d83ac9e3fcedebdb184c9ded8ae81d171656fbe0ade7e431990545c01287f3618e45c3d25e0f77a4e7682e9a21c3f76a SHA512 5bf7e13de2e4a513b5411c3dcaa204aeaff6975b978d68455e059177049c2a1d862b4d1a96f0a986112ea0d347306190c81da6ec4b1150f56a3addc8f3d9b777
+AUX ocaml-4.05.0-CVE-2018-9838.patch 2888 BLAKE2B 75fe491c1b12d9882c7b558efb3384a133c56bea0c85e97a6b46ec5b5f4050da4752228c795d937875645260b98ac9d203b9cdbf583ed36934a29faf4d47ecc3 SHA512 3da218dcea2c08ed97da805a2c1a1bc134a48b4425b4912283e353dde606ae99c95b86b59c6575b42961c9eb6903e09d60968c5a8db72a58510c4e3dcd13a5ef
AUX ocaml-4.05.0-gcc10.patch 1976 BLAKE2B cf1240a815d731e99862740ddf90f6a0ea1d078c9e4e1cef126eff4a7d80afbde73f45d360a26eaa14863cc35d2086d98d130251490959df4c361a51ced0557e SHA512 e55cb651431798294b21ee0ea8818d6c42f88c329b7a1985af9d460f2a5b3057f2ee229e72699f9660168202a0c78dcf89b8bfce2154ca3e141fe8fb5f861773
AUX ocaml-4.09.0-gcc-10.patch 571 BLAKE2B 990107a1d199d350a821596e7655566bb8eb71ee828eb0247bd25111760dd4dd6952a0bea6c29f69f6fa4ef8d02bd47166b5f2c4ced30ed830078b1555ca86eb SHA512 430774f62cea3f4ed06c9a1cbc73c68e3eab0d6fbebb5e62ea12a012cc2b25bb1a776ff08a7d532140bc2e12eae3e1a43605bf5708e1333b23a135b9801de084
AUX ocaml-rebuild.sh 1120 BLAKE2B 6f88a9f2b99fae7f89b884bb08d2c6ad6a0e14d4a8fd06d498037f78c5f6ef040428f9de224b5fe5df4ef64eaed419cda6d8715ea0c0a4c4dad60c5cf75a4147 SHA512 05a3e81e95533135d9895091c21621c73ae82851abd4889d64f035979eb25f8d90b60f469d7ef5e789fd1a4adffd6bbe255e6708c14c24a04f8a423507d19a40
@@ -7,9 +8,12 @@ DIST ocaml-4.05.0.tar.gz 4431750 BLAKE2B c2ab003a13e0a581ebd0e1c96eeb8a9baea9bfe
DIST ocaml-4.09.0.tar.gz 4838748 BLAKE2B 80f29d535c64bf2371b480217723ed20b2b21cfd93ce31366a7b91e7ddffdf68db4e88d085288b7e21efee567a13f42ecff24c3a0115507b006acf844239cefd SHA512 dc0271e591bf929b751705835790949a9d741e12d085c8b207c3689b5838a02ea8de80da8b2605d2e6744f2f541b0d1694ffafff9509e99ce01f3a391f6ef2ae
DIST ocaml-4.10.2.tar.gz 4933135 BLAKE2B ec5e92adb23c28a254247182c79ab555fd82603e02f24799049b8057abf869d18234302408c8ae89b9997a2b210ed6965e45c2c03e4f0cab34262ad3f6ebb528 SHA512 1dd827da07f01e815fd74dd7ee84db0900f24782f8f7fd426e2d71b9fb03c7b8045f22e018120a0446c362315751365d1bd8c1724edef2b182394e76eb0a07b2
DIST ocaml-4.11.2.tar.gz 5075323 BLAKE2B bdc503d9a8d0e39dd11060febcd0287657b460e50ed81e55578a3e778af990ca5d4ef9011753eee4e1a144da33eb76c95b1672dc99b76e65a2e107eee472fe06 SHA512 03d8a9f6e130142c121ff2eb3d54f584f1e7c8475f066a5803bb0edd2fa172ca06a56a3ec548b225f5c8b12112d7a68511b1e16f3ade075b5f02610d4247bbb3
+DIST ocaml-4.12.0.tar.gz 5179734 BLAKE2B 318be7e306157102d7ad22802db381dfa9c675e43325395695c3564e5ffee87d9b55d1152ea1603edb5ef715a28cbde85d835dbf1b5aface2dc415c67192c208 SHA512 951e44cdda613f9c6c5f988434c84249a2d63ba14e21938a9e74c174ebaf9d81a3160d1e5021d57fcd4882732ae6aefc05239ac38116f39ca83d53879d5d4eaf
DIST ocaml-patches-9.tar.bz2 1700 BLAKE2B 4e46b8fb490db28f815414e285f54e251394ea53e1d25c529bbea9f03e426fd19132b1e2c7c2be7d14983fceb4cad073d191b001f6da522fee4226371d4a2eca SHA512 cc19f9104fac69aecc5effa8cb772342e1fb61cdcd38ba0176efe04cf3d710b1c56d5178748f3bd29099af91fa684da432a8ef8d42de76dbd1b6954a255ea6c0
-EBUILD ocaml-4.05.0-r3.ebuild 4032 BLAKE2B e661b119edf65d14fd040274a9cf4d04600eedaf25990a9045898ff95d036510e15e966539ddd6f3a0c7336fe6a24d4c14ae7ca419dec5a1c9536b8b2dcd10c4 SHA512 07285302718df64b0a00678d931c222837b38d92850409e260591f24df1c031714c02d29e7854ae6ce374f843cf10061ec89705bd2a0f772eb04ca88dc7d71e1
-EBUILD ocaml-4.09.0.ebuild 2459 BLAKE2B 41e75a2bcde313c4205e9b5e1dcc704c1aed3fc02bac569b1ae764f6644bb0da02281fb96f4c8e3ad7ebacb5aea94ac328c444e8f228d90cfa1caa50b70b2d4d SHA512 04b7dd810ef40c89c41810725af3cc3702e8645e0b267357d747d9c5de053bbbc553c71e3ce7d1eb758566d9ff61e4eb4d09447e12302fce3fb9dccc01ba17f2
-EBUILD ocaml-4.10.2.ebuild 2417 BLAKE2B d10cc95f1518619bef972b5eb219f45de8d1143c97ff9cd01a9acf74190636ac3316835f7f26523d9388e5be0954c04c4aaea34f2ccf02b4e926fa6abccce842 SHA512 fa701247c912886020d2ff57f03bb94661954ae0f58f95b69f527c2f4efab10bb26fa51d402f7fd236f0932a986424cb72925586e82c41daabbc3cb628cd3541
-EBUILD ocaml-4.11.2.ebuild 2290 BLAKE2B 73ecfc03f0e61821174790f5d360b1cf392517c7c961f0625159c04febb1ffc43c3c6fa4e5705f2d1dbb1cf7e40d84c50782b63411ca2462348c151ae2734df9 SHA512 bcd82adcb04843f597e08efd7d5e904336f47f412d2360c89dd4c1e1802375c60de0fcd77f9edafbe9bdf61be2e65863e84f0cad74d424c52787694e64b21288
+EBUILD ocaml-4.05.0-r5.ebuild 4041 BLAKE2B 25bf09ea13c2775f6ae4524cdefd993d174afdabc32cdced62ce088bc081142679087efdaba6172237276bc4ca22b08ca364e7a0cf2990c6cfa3d56529b74f21 SHA512 3e83e03c64263c5eaac48e8a1e9fc95304e0c1b36726676d0b6a026eddaeab89532898dc54a587c961253f3ee9620e422af2441a659755494a4a23c3728a08b6
+EBUILD ocaml-4.05.0-r6.ebuild 4081 BLAKE2B c02f7a7ab92551db6740dedb3e971da64e1db65cb8fba285edad7c9f9370773592f70a6b1eda403ca8f170953f5e161a35f63d53e95cb21c1271432ff4d7a0f0 SHA512 ad670214e57abd7b8011fc5fb4642932903df4dcc51e39f932396d52dec73a57fb5e7d40088053190e5f2af3e806137208727dd065eb88685ba0d11488b4e101
+EBUILD ocaml-4.09.0-r1.ebuild 2468 BLAKE2B 5fb634c6306f0fd0117af7559f88cb23b969ae7197389280cc7796e1715aca270802ebff28c140b4b887ace8336494ff2656048bcb2e5911ceee58a5e3c9d048 SHA512 77cda9e58a54260e9f2f7736acf21ce32c09cb9d421c3c786c5b63aff8ac71903f90a2b1a0969800e485fcd4f610ace2ecabfee17f9805f60d6076688afe2f8b
+EBUILD ocaml-4.10.2-r1.ebuild 2426 BLAKE2B 05ce3cd3582c4a481b978da45595f20c1da6bda77fcdd28d10578d87e058692d24079f9ae22fa9f546ebf963193860d398986fd4f8c5829acabfcf5f15a2cc31 SHA512 f0db8d2e7c13fb67fa65342c290e6e84c2112ed0a0a12f58ec3fc0e4b94260089dc13e35fc24dd28ed5806389a96d33438668383d1481edae8c32a4b9a405a04
+EBUILD ocaml-4.11.2-r1.ebuild 2299 BLAKE2B 3871154a5ca7aacf906e54c153ba10dfad01f9b3d82525594ee1f63097c3096c56a9a8c46ab0ede781960fb0f5c1d8bb21fc8f2a59d4729447e4a105fd278fc1 SHA512 e0c621b850cbabe115968b369ff371daf3c38e1a9735cfaa7c85debd2f41f1cce0d0ab66acaadb72988f1749f362f2ba5edd91dbc3b4c1ad19204e9ba1015fc4
+EBUILD ocaml-4.12.0-r1.ebuild 2311 BLAKE2B 9d5515be76bf907b8f4014c870afc9cf77c44f06f8d89bd308327b407a37d56d7d04b27ddc6e8387b122f4968b357218633078c42770321b95c17acc9a3f9873 SHA512 9b704e8d1ae4444c3a5920cecaee9c6629055e691ecb26fe780872757dacb3d71b9d8a1386e96ae71fce9fc212d9d2256212d03634ad458222e1747cc8829283
MISC metadata.xml 775 BLAKE2B dfddcb1e262074326ede7fb648bb524404e86a302270b6bc9e502124689077cd54ebafbfca277d516d2763cd18580a09f749f45ca215c34c26c7ae1c56c2e841 SHA512 3551489dac19dddcf6490c74df4c8e2aa370565b207bcdee28a8160caab7394d8d770ed4408ce8db3d3c224b61439f29c4eae84180adf01a468e0ef515980818
diff --git a/dev-lang/ocaml/files/ocaml-4.05.0-CVE-2018-9838.patch b/dev-lang/ocaml/files/ocaml-4.05.0-CVE-2018-9838.patch
new file mode 100644
index 000000000000..cfe3ff636c25
--- /dev/null
+++ b/dev-lang/ocaml/files/ocaml-4.05.0-CVE-2018-9838.patch
@@ -0,0 +1,70 @@
+https://bugs.gentoo.org/755257
+
+Needed for both fixing the CVE + compatibility with Debian for e.g.
+Unison.
+
+From c6ca3afc78b75d7748e4e09e56c6b020418be06e Mon Sep 17 00:00:00 2001
+From: Stephane Glondu <steph@glondu.net>
+Date: Fri, 25 Jan 2019 14:34:23 +0100
+Subject: [PATCH] Fix integer overflows when unmarshaling a bigarray
+
+Malicious or corrupted marshaled data can result in a bigarray
+with impossibly large dimensions that cause overflow when computing
+the in-memory size of the bigarray. Disaster ensues when the data
+is read in a too small memory area. This commit checks for overflows
+when computing the in-memory size of the bigarray.
+
+This patch is based on one by Xavier Leroy and has been modified to
+use caml_ba_multov instead of caml_umul_overflow which is unavailable
+in OCaml 4.05.0.
+
+The original commit hash is 85162eee9d4072fa9c2f498f03cd94e357033eec.
+
+Origin: https://github.com/ocaml/ocaml/pull/1718
+Bug: https://github.com/ocaml/ocaml/issues/7765
+Bug-Debian: https://bugs.debian.org/895472
+Bug-CVE: CVE-2018-9838
+--- a/otherlibs/bigarray/bigarray_stubs.c
++++ b/otherlibs/bigarray/bigarray_stubs.c
+@@ -966,22 +966,34 @@ static void caml_ba_deserialize_longarray(void * dest, intnat num_elts)
+ uintnat caml_ba_deserialize(void * dst)
+ {
+ struct caml_ba_array * b = dst;
+- int i, elt_size;
+- uintnat num_elts;
++ int i;
++ uintnat num_elts, size;
++ int overflow;
+
+ /* Read back header information */
+ b->num_dims = caml_deserialize_uint_4();
++ if (b->num_dims < 0 || b->num_dims > CAML_BA_MAX_NUM_DIMS)
++ caml_deserialize_error("input_value: wrong number of bigarray dimensions");
+ b->flags = caml_deserialize_uint_4() | CAML_BA_MANAGED;
+ b->proxy = NULL;
+ for (i = 0; i < b->num_dims; i++) b->dim[i] = caml_deserialize_uint_4();
+- /* Compute total number of elements */
+- num_elts = caml_ba_num_elts(b);
+- /* Determine element size in bytes */
++ /* Compute total number of elements. Watch out for overflows (MPR#7765). */
++ num_elts = 1;
++ for (i = 0; i < b->num_dims; i++) {
++ overflow = 0;
++ num_elts = caml_ba_multov(num_elts, b->dim[i], &overflow);
++ if (overflow)
++ caml_deserialize_error("input_value: size overflow for bigarray");
++ }
++ /* Determine array size in bytes. Watch out for overflows (MPR#7765). */
+ if ((b->flags & CAML_BA_KIND_MASK) > CAML_BA_CHAR)
+ caml_deserialize_error("input_value: bad bigarray kind");
+- elt_size = caml_ba_element_size[b->flags & CAML_BA_KIND_MASK];
++ overflow = 0;
++ size = caml_ba_multov(num_elts, caml_ba_element_size[b->flags & CAML_BA_KIND_MASK], &overflow);
++ if (overflow)
++ caml_deserialize_error("input_value: size overflow for bigarray");
+ /* Allocate room for data */
+- b->data = malloc(elt_size * num_elts);
++ b->data = malloc(size);
+ if (b->data == NULL)
+ caml_deserialize_error("input_value: out of memory for bigarray");
+ /* Read data */
diff --git a/dev-lang/ocaml/ocaml-4.05.0-r3.ebuild b/dev-lang/ocaml/ocaml-4.05.0-r5.ebuild
index 69094b6cb10a..36adb282101c 100644
--- a/dev-lang/ocaml/ocaml-4.05.0-r3.ebuild
+++ b/dev-lang/ocaml/ocaml-4.05.0-r5.ebuild
@@ -15,7 +15,7 @@ SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.
LICENSE="QPL-1.0 LGPL-2"
# Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
# so here we go with the subslot.
-SLOT="0/${PV}"
+SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
IUSE="emacs flambda latex ncurses +ocamlopt spacetime X xemacs"
diff --git a/dev-lang/ocaml/ocaml-4.05.0-r6.ebuild b/dev-lang/ocaml/ocaml-4.05.0-r6.ebuild
new file mode 100644
index 000000000000..ae3120cad728
--- /dev/null
+++ b/dev-lang/ocaml/ocaml-4.05.0-r6.ebuild
@@ -0,0 +1,143 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit flag-o-matic multilib toolchain-funcs
+
+PATCHLEVEL="9"
+MY_P="${P/_/-}"
+DESCRIPTION="Type-inferring functional programming language descended from the ML family"
+HOMEPAGE="https://ocaml.org"
+SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.gz
+ mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2"
+
+LICENSE="QPL-1.0 LGPL-2"
+# Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
+# so here we go with the subslot.
+SLOT="0/$(ver_cut 1-2)"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
+IUSE="emacs flambda latex ncurses +ocamlopt spacetime X xemacs"
+
+RDEPEND="
+ sys-libs/binutils-libs:=
+ ncurses? ( sys-libs/ncurses:0= )
+ spacetime? ( sys-libs/libunwind:= )
+ X? ( x11-libs/libX11 )
+ !dev-ml/num"
+BDEPEND="${RDEPEND}
+ virtual/pkgconfig"
+PDEPEND="emacs? ( app-emacs/ocaml-mode )
+ xemacs? ( app-xemacs/ocaml )"
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-4.04.2-tinfo.patch #459512
+ "${FILESDIR}"/${P}-gcc10.patch
+ "${FILESDIR}"/${P}-CVE-2018-9838.patch
+)
+
+pkg_setup() {
+ # dev-lang/ocaml creates its own objects but calls gcc for linking, which will
+ # results in relocations if gcc wants to create a PIE executable
+ if gcc-specs-pie ; then
+ append-ldflags -nopie
+ ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
+ ewarn "We have appended -nopie to ocaml build options"
+ ewarn "because linking an executable with pie while the objects are not pic will not work"
+ fi
+}
+
+src_prepare() {
+ EPATCH_SUFFIX="patch" eapply "${WORKDIR}/patches"
+ default
+}
+
+src_configure() {
+ export LC_ALL=C
+ local myconf=""
+
+ # Causes build failures because it builds some programs with -pg,
+ # bug #270920
+ filter-flags -fomit-frame-pointer
+ # Bug #285993
+ filter-mfpmath sse
+
+ # -ggdb3 & co makes it behave weirdly, breaks sexplib
+ replace-flags -ggdb* -ggdb
+
+ # OCaml generates textrels on 32-bit arches
+ # We can't do anything about it, but disabling it means that tests
+ # for OCaml-based packages won't fail on unexpected output
+ # bug #773226
+ if use arm || use ppc || use x86 ; then
+ append-ldflags "-Wl,-z,notext"
+ fi
+
+ # It doesn't compile on alpha without this LDFLAGS
+ use alpha && append-ldflags "-Wl,--no-relax"
+
+ use ncurses || myconf="${myconf} -no-curses"
+ use X || myconf="${myconf} -no-graph"
+ use flambda && myconf="${myconf} -flambda"
+ use spacetime && myconf="${myconf} -spacetime"
+
+ # ocaml uses a home-brewn configure script, preventing it to use econf.
+ RAW_LDFLAGS="$(raw-ldflags)" ./configure \
+ --prefix "${EPREFIX}"/usr \
+ --bindir "${EPREFIX}"/usr/bin \
+ --target-bindir "${EPREFIX}"/usr/bin \
+ --libdir "${EPREFIX}"/usr/$(get_libdir)/ocaml \
+ --mandir "${EPREFIX}"/usr/share/man \
+ -target "${CHOST}" \
+ -host "${CBUILD}" \
+ -cc "$(tc-getCC)" \
+ -as "$(tc-getAS)" \
+ -aspp "$(tc-getCC) -c" \
+ -partialld "$(tc-getLD) -r" \
+ --with-pthread ${myconf} || die "configure failed!"
+
+ # http://caml.inria.fr/mantis/view.php?id=4698
+ export CCLINKFLAGS="${LDFLAGS}"
+}
+
+src_compile() {
+ emake world
+
+ # Native code generation can be disabled now
+ if use ocamlopt ; then
+ # bug #279968
+ emake opt
+ emake -j1 opt.opt
+ fi
+}
+
+src_test() {
+ if use ocamlopt ; then
+ emake -j1 tests
+ else
+ ewarn "${PN} was built without 'ocamlopt' USE flag; skipping tests."
+ fi
+}
+
+src_install() {
+ emake BINDIR="${ED}"/usr/bin \
+ LIBDIR="${ED}"/usr/$(get_libdir)/ocaml \
+ MANDIR="${ED}"/usr/share/man \
+ install
+
+ # Symlink the headers to the right place
+ dodir /usr/include
+ # Create symlink for header files
+ dosym "../$(get_libdir)/ocaml/caml" /usr/include/caml
+ dodoc Changes README.adoc
+ # Create envd entry for latex input files
+ if use latex ; then
+ echo "TEXINPUTS=\"${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:\"" > "${T}/99ocamldoc"
+ doenvd "${T}/99ocamldoc"
+ fi
+ # Install ocaml-rebuild portage set
+ insinto /usr/share/portage/config/sets
+ doins "${FILESDIR}/ocaml.conf"
+}
diff --git a/dev-lang/ocaml/ocaml-4.09.0.ebuild b/dev-lang/ocaml/ocaml-4.09.0-r1.ebuild
index f74988668b87..14dc7a908b0e 100644
--- a/dev-lang/ocaml/ocaml-4.09.0.ebuild
+++ b/dev-lang/ocaml/ocaml-4.09.0-r1.ebuild
@@ -10,7 +10,7 @@ SRC_URI="https://github.com/ocaml/ocaml/archive/${PV}.tar.gz -> ${P}.tar.gz"
DESCRIPTION="Programming language supporting functional, imperative & object-oriented styles"
LICENSE="LGPL-2.1"
-SLOT="0/${PV}"
+SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
IUSE="emacs flambda latex +ocamlopt spacetime xemacs"
diff --git a/dev-lang/ocaml/ocaml-4.10.2.ebuild b/dev-lang/ocaml/ocaml-4.10.2-r1.ebuild
index 208d8612d6a9..e1ca18aa9617 100644
--- a/dev-lang/ocaml/ocaml-4.10.2.ebuild
+++ b/dev-lang/ocaml/ocaml-4.10.2-r1.ebuild
@@ -10,7 +10,7 @@ SRC_URI="https://github.com/ocaml/ocaml/archive/${PV}.tar.gz -> ${P}.tar.gz"
DESCRIPTION="Programming language supporting functional, imperative & object-oriented styles"
LICENSE="LGPL-2.1"
-SLOT="0/${PV}"
+SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
IUSE="emacs flambda latex +ocamlopt spacetime xemacs"
diff --git a/dev-lang/ocaml/ocaml-4.11.2.ebuild b/dev-lang/ocaml/ocaml-4.11.2-r1.ebuild
index e3298bdfc899..f1ad43dbf997 100644
--- a/dev-lang/ocaml/ocaml-4.11.2.ebuild
+++ b/dev-lang/ocaml/ocaml-4.11.2-r1.ebuild
@@ -10,7 +10,7 @@ SRC_URI="https://github.com/ocaml/ocaml/archive/${PV}.tar.gz -> ${P}.tar.gz"
DESCRIPTION="Programming language supporting functional, imperative & object-oriented styles"
LICENSE="QPL-1.0 LGPL-2"
-SLOT="0/${PV}"
+SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
IUSE="emacs flambda latex +ocamlopt spacetime xemacs"
diff --git a/dev-lang/ocaml/ocaml-4.12.0-r1.ebuild b/dev-lang/ocaml/ocaml-4.12.0-r1.ebuild
new file mode 100644
index 000000000000..137a6160e458
--- /dev/null
+++ b/dev-lang/ocaml/ocaml-4.12.0-r1.ebuild
@@ -0,0 +1,93 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit flag-o-matic
+
+HOMEPAGE="https://ocaml.org/"
+SRC_URI="https://github.com/ocaml/ocaml/archive/${PV}.tar.gz -> ${P}.tar.gz"
+DESCRIPTION="Programming language supporting functional, imperative & object-oriented styles"
+
+LICENSE="QPL-1.0 LGPL-2"
+SLOT="0/$(ver_cut 1-2)"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
+IUSE="emacs flambda latex +ocamlopt xemacs"
+
+RDEPEND="sys-libs/binutils-libs:="
+BDEPEND="${RDEPEND}
+ virtual/pkgconfig"
+PDEPEND="emacs? ( app-emacs/ocaml-mode )
+ xemacs? ( app-xemacs/ocaml )"
+
+src_prepare() {
+ default
+
+ # OCaml generates textrels on 32-bit arches
+ # We can't do anything about it, but disabling it means that tests
+ # for OCaml-based packages won't fail on unexpected output
+ # bug #773226
+ #if use arm || use ppc || use x86 ; then
+ append-ldflags "-Wl,-z,notext"
+ #fi
+
+ # Upstream build ignores LDFLAGS in several places.
+ sed -i -e 's/\(^MKDLL=.*\)/\1 $(LDFLAGS)/' \
+ -e 's/\(^OC_CFLAGS=.*\)/\1 $(LDFLAGS)/' \
+ -e 's/\(^OC_LDFLAGS=.*\)/\1 $(LDFLAGS)/' \
+ Makefile.config.in || die "LDFLAGS fix failed"
+}
+
+src_configure() {
+ local opt=(
+ --bindir="${EPREFIX}/usr/bin"
+ --libdir="${EPREFIX}/usr/$(get_libdir)/ocaml"
+ --mandir="${EPREFIX}/usr/share/man"
+ --prefix="${EPREFIX}/usr"
+ $(use_enable flambda)
+ )
+
+ econf "${opt[@]}"
+}
+
+src_compile() {
+ env -u P emake world
+
+ if use ocamlopt ; then
+ env -u P emake opt
+ env -u P emake opt.opt
+ fi
+}
+
+src_test() {
+ emake -j
+
+ # OCaml tests only work when run sequentially
+ if use ocamlopt ; then
+ emake -j1 ocamltest.opt
+ else
+ emake -j1 ocamltest
+ #ewarn "${PN} was built without 'ocamlopt' USE flag; skipping tests."
+ fi
+
+ emake -j1 tests
+}
+
+src_install() {
+ default
+
+ dodir /usr/include
+ # Create symlink for header files
+ dosym "../$(get_libdir)/ocaml/caml" /usr/include/caml
+ dodoc Changes README.adoc
+
+ # Create envd entry for latex input files
+ if use latex ; then
+ echo "TEXINPUTS=\"${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:\"" > "${T}/99ocamldoc" || die
+ doenvd "${T}/99ocamldoc"
+ fi
+
+ # Install ocaml-rebuild portage set
+ insinto /usr/share/portage/config/sets
+ doins "${FILESDIR}/ocaml.conf"
+}