Gentoo Archives: gentoo-commits

From: Alfredo Tupone <tupone@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/ocaml/, dev-lang/ocaml/files/
Date: Thu, 28 Jan 2021 22:15:27
Message-Id: 1611872108.77fd8a0f1e7d400c8658105c0e0163ac49b6412b.tupone@gentoo
1 commit: 77fd8a0f1e7d400c8658105c0e0163ac49b6412b
2 Author: Alfredo Tupone <tupone <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jan 28 22:15:08 2021 +0000
4 Commit: Alfredo Tupone <tupone <AT> gentoo <DOT> org>
5 CommitDate: Thu Jan 28 22:15:08 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=77fd8a0f
7
8 dev-lang/ocaml: build with gcc-10
9
10 Bug: https://bugs.gentoo.org/735274
11 Package-Manager: Portage-3.0.13, Repoman-3.0.2
12 Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>
13
14 dev-lang/ocaml/files/ocaml-4.05.0-gcc10.patch | 59 ++++++++++++
15 dev-lang/ocaml/ocaml-4.05.0-r2.ebuild | 132 ++++++++++++++++++++++++++
16 2 files changed, 191 insertions(+)
17
18 diff --git a/dev-lang/ocaml/files/ocaml-4.05.0-gcc10.patch b/dev-lang/ocaml/files/ocaml-4.05.0-gcc10.patch
19 new file mode 100644
20 index 00000000000..a0c67da534a
21 --- /dev/null
22 +++ b/dev-lang/ocaml/files/ocaml-4.05.0-gcc10.patch
23 @@ -0,0 +1,59 @@
24 +--- a/byterun/caml/intext.h 2021-01-28 22:46:20.400224678 +0100
25 ++++ b/byterun/caml/intext.h 2021-01-28 22:46:49.312751054 +0100
26 +@@ -196,7 +196,7 @@
27 +
28 + CAMLextern struct code_fragment * caml_extern_find_code(char *addr);
29 +
30 +-struct ext_table caml_code_fragments_table;
31 ++extern struct ext_table caml_code_fragments_table;
32 +
33 + #endif /* CAML_INTERNALS */
34 +
35 +--- a/byterun/caml/major_gc.h 2021-01-28 22:44:12.193323457 +0100
36 ++++ b/byterun/caml/major_gc.h 2021-01-28 22:45:20.918198701 +0100
37 +@@ -64,9 +64,9 @@
38 + extern char *caml_gc_sweep_hp;
39 +
40 + extern int caml_major_window;
41 +-double caml_major_ring[Max_major_window];
42 +-int caml_major_ring_index;
43 +-double caml_major_work_credit;
44 ++extern double caml_major_ring[Max_major_window];
45 ++extern int caml_major_ring_index;
46 ++extern double caml_major_work_credit;
47 + extern double caml_gc_clock;
48 +
49 + /* [caml_major_gc_hook] is called just between the end of the mark
50 +--- a/byterun/meta.c 2021-01-28 22:47:34.148016359 +0100
51 ++++ b/byterun/meta.c 2021-01-28 22:47:56.048657393 +0100
52 +@@ -32,6 +32,8 @@
53 + #include "caml/prims.h"
54 + #include "caml/stacks.h"
55 +
56 ++struct ext_table caml_code_fragments_table;
57 ++
58 + #ifndef NATIVE_CODE
59 +
60 + CAMLprim value caml_get_global_data(value unit)
61 +--- a/byterun/backtrace.c 2021-01-28 22:50:25.275226598 +0100
62 ++++ b/byterun/backtrace.c 2021-01-28 22:50:37.541027290 +0100
63 +@@ -28,7 +28,7 @@
64 + #include "caml/fail.h"
65 +
66 + /* The table of debug information fragments */
67 +-struct ext_table caml_debug_info;
68 ++extern struct ext_table caml_debug_info;
69 +
70 + CAMLexport int32_t caml_backtrace_active = 0;
71 + CAMLexport int32_t caml_backtrace_pos = 0;
72 +--- a/asmrun/startup.c 2021-01-28 23:02:50.526072662 +0100
73 ++++ b/asmrun/startup.c 2021-01-28 23:03:09.977754311 +0100
74 +@@ -44,7 +44,7 @@
75 + #endif
76 +
77 + extern int caml_parser_trace;
78 +-CAMLexport header_t caml_atom_table[256];
79 ++CAMLextern header_t caml_atom_table[256];
80 + char * caml_code_area_start, * caml_code_area_end;
81 +
82 + /* Initialize the atom table and the static data and code area limits. */
83
84 diff --git a/dev-lang/ocaml/ocaml-4.05.0-r2.ebuild b/dev-lang/ocaml/ocaml-4.05.0-r2.ebuild
85 new file mode 100644
86 index 00000000000..dc6ca02c535
87 --- /dev/null
88 +++ b/dev-lang/ocaml/ocaml-4.05.0-r2.ebuild
89 @@ -0,0 +1,132 @@
90 +# Copyright 1999-2021 Gentoo Authors
91 +# Distributed under the terms of the GNU General Public License v2
92 +
93 +EAPI="5"
94 +
95 +inherit flag-o-matic eutils multilib versionator toolchain-funcs
96 +
97 +PATCHLEVEL="9"
98 +MY_P="${P/_/-}"
99 +DESCRIPTION="Type-inferring functional programming language descended from the ML family"
100 +HOMEPAGE="https://ocaml.org"
101 +SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.gz
102 + mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2"
103 +
104 +LICENSE="QPL-1.0 LGPL-2"
105 +# Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
106 +# so here we go with the subslot.
107 +SLOT="0/${PV}"
108 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
109 +IUSE="emacs flambda latex ncurses +ocamlopt spacetime X xemacs"
110 +
111 +RDEPEND="
112 + sys-libs/binutils-libs:=
113 + ncurses? ( sys-libs/ncurses:0= )
114 + spacetime? ( sys-libs/libunwind:= )
115 + X? ( x11-libs/libX11 )
116 + !dev-ml/num"
117 +DEPEND="${RDEPEND}
118 + virtual/pkgconfig"
119 +
120 +PDEPEND="emacs? ( app-emacs/ocaml-mode )
121 + xemacs? ( app-xemacs/ocaml )"
122 +
123 +S="${WORKDIR}/${MY_P}"
124 +pkg_setup() {
125 + # dev-lang/ocaml creates its own objects but calls gcc for linking, which will
126 + # results in relocations if gcc wants to create a PIE executable
127 + if gcc-specs-pie ; then
128 + append-ldflags -nopie
129 + ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
130 + ewarn "We have appended -nopie to ocaml build options"
131 + ewarn "because linking an executable with pie while the objects are not pic will not work"
132 + fi
133 +}
134 +
135 +src_prepare() {
136 + EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
137 + epatch "${FILESDIR}/${PN}-4.04.2-tinfo.patch" #459512
138 + epatch "${FILESDIR}"/${P}-gcc10.patch
139 +}
140 +
141 +src_configure() {
142 + export LC_ALL=C
143 + local myconf=""
144 +
145 + # Causes build failures because it builds some programs with -pg,
146 + # bug #270920
147 + filter-flags -fomit-frame-pointer
148 + # Bug #285993
149 + filter-mfpmath sse
150 +
151 + # -ggdb3 & co makes it behave weirdly, breaks sexplib
152 + replace-flags -ggdb* -ggdb
153 +
154 + # It doesn't compile on alpha without this LDFLAGS
155 + use alpha && append-ldflags "-Wl,--no-relax"
156 +
157 + use ncurses || myconf="${myconf} -no-curses"
158 + use X || myconf="${myconf} -no-graph"
159 + use flambda && myconf="${myconf} -flambda"
160 + use spacetime && myconf="${myconf} -spacetime"
161 +
162 + # ocaml uses a home-brewn configure script, preventing it to use econf.
163 + RAW_LDFLAGS="$(raw-ldflags)" ./configure \
164 + --prefix "${EPREFIX}"/usr \
165 + --bindir "${EPREFIX}"/usr/bin \
166 + --target-bindir "${EPREFIX}"/usr/bin \
167 + --libdir "${EPREFIX}"/usr/$(get_libdir)/ocaml \
168 + --mandir "${EPREFIX}"/usr/share/man \
169 + -target "${CHOST}" \
170 + -host "${CBUILD}" \
171 + -cc "$(tc-getCC)" \
172 + -as "$(tc-getAS)" \
173 + -aspp "$(tc-getCC) -c" \
174 + -partialld "$(tc-getLD) -r" \
175 + --with-pthread ${myconf} || die "configure failed!"
176 +
177 + # http://caml.inria.fr/mantis/view.php?id=4698
178 + export CCLINKFLAGS="${LDFLAGS}"
179 +}
180 +
181 +src_compile() {
182 + emake world
183 +
184 + # Native code generation can be disabled now
185 + if use ocamlopt ; then
186 + # bug #279968
187 + emake opt
188 + emake -j1 opt.opt
189 + fi
190 +}
191 +
192 +src_test() {
193 + if use ocamlopt ; then
194 + emake -j1 tests
195 + else
196 + ewarn "${PN} testsuite requires ocamlopt useflag"
197 + fi
198 +}
199 +
200 +src_install() {
201 + emake BINDIR="${ED}"/usr/bin \
202 + LIBDIR="${ED}"/usr/$(get_libdir)/ocaml \
203 + MANDIR="${ED}"/usr/share/man \
204 + install
205 +
206 + # Symlink the headers to the right place
207 + dodir /usr/include
208 + dosym /usr/$(get_libdir)/ocaml/caml /usr/include/caml
209 +
210 + dodoc Changes README.adoc
211 +
212 + # Create and envd entry for latex input files
213 + if use latex ; then
214 + echo "TEXINPUTS=${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:" > "${T}"/99ocamldoc
215 + doenvd "${T}"/99ocamldoc
216 + fi
217 +
218 + # Install ocaml-rebuild portage set
219 + insinto /usr/share/portage/config/sets
220 + doins "${FILESDIR}/ocaml.conf"
221 +}