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/gnat-gpl/, dev-lang/gnat-gpl/files/
Date: Sat, 17 Nov 2018 14:08:37
Message-Id: 1542463704.8bcf1b9a496f83e7e3fc9f98c6fad7d50f202867.tupone@gentoo
1 commit: 8bcf1b9a496f83e7e3fc9f98c6fad7d50f202867
2 Author: Tupone Alfredo <tupone <AT> gentoo <DOT> org>
3 AuthorDate: Sat Nov 17 14:07:47 2018 +0000
4 Commit: Alfredo Tupone <tupone <AT> gentoo <DOT> org>
5 CommitDate: Sat Nov 17 14:08:24 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8bcf1b9a
7
8 dev-lang/gnat-gpl: Add Finalization_Size su gnatcoll-2017 can build
9
10 Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>
11 Package-Manager: Portage-2.3.51, Repoman-2.3.11
12
13 .../files/gnat-gpl-2016-finalization.patch | 220 +++++++++++++++++++++
14 dev-lang/gnat-gpl/gnat-gpl-2016-r2.ebuild | 216 ++++++++++++++++++++
15 2 files changed, 436 insertions(+)
16
17 diff --git a/dev-lang/gnat-gpl/files/gnat-gpl-2016-finalization.patch b/dev-lang/gnat-gpl/files/gnat-gpl-2016-finalization.patch
18 new file mode 100644
19 index 00000000000..44503ae6b72
20 --- /dev/null
21 +++ b/dev-lang/gnat-gpl/files/gnat-gpl-2016-finalization.patch
22 @@ -0,0 +1,220 @@
23 +--- a/gcc/ada/exp_attr.adb 2018-11-16 20:23:21.775906196 +0100
24 ++++ b/gcc/ada/exp_attr.adb 2018-11-16 20:25:57.418211404 +0100
25 +@@ -3121,6 +3121,121 @@
26 + Analyze_And_Resolve (N, Standard_String);
27 + end External_Tag;
28 +
29 ++ -----------------------
30 ++ -- Finalization_Size --
31 ++ -----------------------
32 ++
33 ++ when Attribute_Finalization_Size => Finalization_Size : declare
34 ++ function Calculate_Header_Size return Node_Id;
35 ++ -- Generate a runtime call to calculate the size of the hidden header
36 ++ -- along with any added padding which would precede a heap-allocated
37 ++ -- object of the prefix type.
38 ++
39 ++ ---------------------------
40 ++ -- Calculate_Header_Size --
41 ++ ---------------------------
42 ++
43 ++ function Calculate_Header_Size return Node_Id is
44 ++ begin
45 ++ -- Generate:
46 ++ -- Universal_Integer
47 ++ -- (Header_Size_With_Padding (Pref'Alignment))
48 ++
49 ++ return
50 ++ Convert_To (Universal_Integer,
51 ++ Make_Function_Call (Loc,
52 ++ Name =>
53 ++ New_Occurrence_Of (RTE (RE_Header_Size_With_Padding), Loc),
54 ++
55 ++ Parameter_Associations => New_List (
56 ++ Make_Attribute_Reference (Loc,
57 ++ Prefix => New_Copy_Tree (Pref),
58 ++ Attribute_Name => Name_Alignment))));
59 ++ end Calculate_Header_Size;
60 ++
61 ++ -- Local variables
62 ++
63 ++ Size : Entity_Id;
64 ++
65 ++ -- Start of Finalization_Size
66 ++
67 ++ begin
68 ++ -- An object of a class-wide type first requires a runtime check to
69 ++ -- determine whether it is actually controlled or not. Depending on
70 ++ -- the outcome of this check, the Finalization_Size of the object
71 ++ -- may be zero or some positive value.
72 ++ --
73 ++ -- In this scenario, Pref'Finalization_Size is expanded into
74 ++ --
75 ++ -- Size : Integer := 0;
76 ++ --
77 ++ -- if Needs_Finalization (Pref'Tag) then
78 ++ -- Size :=
79 ++ -- Universal_Integer
80 ++ -- (Header_Size_With_Padding (Pref'Alignment));
81 ++ -- end if;
82 ++ --
83 ++ -- and the attribute reference is replaced with a reference to Size.
84 ++
85 ++ if Is_Class_Wide_Type (Ptyp) then
86 ++ Size := Make_Temporary (Loc, 'S');
87 ++
88 ++ Insert_Actions (N, New_List (
89 ++
90 ++ -- Generate:
91 ++ -- Size : Integer := 0;
92 ++
93 ++ Make_Object_Declaration (Loc,
94 ++ Defining_Identifier => Size,
95 ++ Object_Definition =>
96 ++ New_Occurrence_Of (Standard_Integer, Loc),
97 ++ Expression => Make_Integer_Literal (Loc, 0)),
98 ++
99 ++ -- Generate:
100 ++ -- if Needs_Finalization (Pref'Tag) then
101 ++ -- Size :=
102 ++ -- Universal_Integer
103 ++ -- (Header_Size_With_Padding (Pref'Alignment));
104 ++ -- end if;
105 ++
106 ++ Make_If_Statement (Loc,
107 ++ Condition =>
108 ++ Make_Function_Call (Loc,
109 ++ Name =>
110 ++ New_Occurrence_Of (RTE (RE_Needs_Finalization), Loc),
111 ++
112 ++ Parameter_Associations => New_List (
113 ++ Make_Attribute_Reference (Loc,
114 ++ Prefix => New_Copy_Tree (Pref),
115 ++ Attribute_Name => Name_Tag))),
116 ++
117 ++ Then_Statements => New_List (
118 ++ Make_Assignment_Statement (Loc,
119 ++ Name => New_Occurrence_Of (Size, Loc),
120 ++ Expression => Calculate_Header_Size)))));
121 ++
122 ++ Rewrite (N, New_Occurrence_Of (Size, Loc));
123 ++
124 ++ -- The prefix is known to be controlled at compile time. Calculate
125 ++ -- Finalization_Size by calling function Header_Size_With_Padding.
126 ++
127 ++ elsif Needs_Finalization (Ptyp) then
128 ++ Rewrite (N, Calculate_Header_Size);
129 ++
130 ++ -- The prefix is not an object with controlled parts, so its
131 ++ -- Finalization_Size is zero.
132 ++
133 ++ else
134 ++ Rewrite (N, Make_Integer_Literal (Loc, 0));
135 ++ end if;
136 ++
137 ++ -- Due to cases where the entity type of the attribute is already
138 ++ -- resolved the rewritten N must get re-resolved to its appropriate
139 ++ -- type.
140 ++
141 ++ Analyze_And_Resolve (N, Typ);
142 ++ end Finalization_Size;
143 ++
144 + -----------
145 + -- First --
146 + -----------
147 +--- a/gcc/ada/snames.ads-tmpl 2016-05-16 11:29:28.000000000 +0200
148 +--- b/gcc/ada/snames.ads-tmpl 2016-05-16 11:29:28.000000000 +0200
149 +@@ -884,6 +884,7 @@
150 + Name_Exponent : constant Name_Id := N + $;
151 + Name_External_Tag : constant Name_Id := N + $;
152 + Name_Fast_Math : constant Name_Id := N + $; -- GNAT
153 ++ Name_Finalization_Size : constant Name_Id := N + $; -- GNAT
154 + Name_First : constant Name_Id := N + $;
155 + Name_First_Bit : constant Name_Id := N + $;
156 + Name_First_Valid : constant Name_Id := N + $; -- Ada 12
157 +@@ -1523,6 +1524,7 @@
158 + Attribute_Exponent,
159 + Attribute_External_Tag,
160 + Attribute_Fast_Math,
161 ++ Attribute_Finalization_Size,
162 + Attribute_First,
163 + Attribute_First_Bit,
164 + Attribute_First_Valid,
165 +--- a/gcc/ada/sem_attr.ads 2018-11-16 21:35:46.821279875 +0100
166 ++++ b/gcc/ada/sem_attr.ads 2018-11-16 21:36:00.028057464 +0100
167 +@@ -242,6 +242,16 @@
168 + -- enumeration value. Constraint_Error is raised if no value of the
169 + -- enumeration type corresponds to the given integer value.
170 +
171 ++ -----------------------
172 ++ -- Finalization_Size --
173 ++ -----------------------
174 ++
175 ++ Attribute_Finalization_Size => True,
176 ++ -- For every object or non-class-wide-type, Finalization_Size returns
177 ++ -- the size of the hidden header used for finalization purposes as if
178 ++ -- the object or type was allocated on the heap. The size of the header
179 ++ -- does take into account any extra padding due to alignment issues.
180 ++
181 + -----------------
182 + -- Fixed_Value --
183 + -----------------
184 +--- a/gcc/ada/sem_attr.adb 2018-11-16 21:35:49.698231429 +0100
185 ++++ b/gcc/ada/sem_attr.adb 2018-11-16 21:36:00.028057464 +0100
186 +@@ -3828,6 +3828,42 @@
187 + Check_Standard_Prefix;
188 + Rewrite (N, New_Occurrence_Of (Boolean_Literals (Fast_Math), Loc));
189 +
190 ++ -----------------------
191 ++ -- Finalization_Size --
192 ++ -----------------------
193 ++
194 ++ when Attribute_Finalization_Size =>
195 ++ Check_E0;
196 ++
197 ++ -- The prefix denotes an object
198 ++
199 ++ if Is_Object_Reference (P) then
200 ++ Check_Object_Reference (P);
201 ++
202 ++ -- The prefix denotes a type
203 ++
204 ++ elsif Is_Entity_Name (P) and then Is_Type (Entity (P)) then
205 ++ Check_Type;
206 ++ Check_Not_Incomplete_Type;
207 ++
208 ++ -- Attribute 'Finalization_Size is not defined for class-wide
209 ++ -- types because it is not possible to know statically whether
210 ++ -- a definite type will have controlled components or not.
211 ++
212 ++ if Is_Class_Wide_Type (Etype (P)) then
213 ++ Error_Attr_P
214 ++ ("prefix of % attribute cannot denote a class-wide type");
215 ++ end if;
216 ++
217 ++ -- The prefix denotes an illegal construct
218 ++
219 ++ else
220 ++ Error_Attr_P
221 ++ ("prefix of % attribute must be a definite type or an object");
222 ++ end if;
223 ++
224 ++ Set_Etype (N, Universal_Integer);
225 ++
226 + -----------
227 + -- First --
228 + -----------
229 +@@ -8264,6 +8300,13 @@
230 + Fold_Uint (N,
231 + Eval_Fat.Exponent (P_Base_Type, Expr_Value_R (E1)), Static);
232 +
233 ++ -----------------------
234 ++ -- Finalization_Size --
235 ++ -----------------------
236 ++
237 ++ when Attribute_Finalization_Size =>
238 ++ null;
239 ++
240 + -----------
241 + -- First --
242 + -----------
243
244 diff --git a/dev-lang/gnat-gpl/gnat-gpl-2016-r2.ebuild b/dev-lang/gnat-gpl/gnat-gpl-2016-r2.ebuild
245 new file mode 100644
246 index 00000000000..8474d085bc1
247 --- /dev/null
248 +++ b/dev-lang/gnat-gpl/gnat-gpl-2016-r2.ebuild
249 @@ -0,0 +1,216 @@
250 +# Copyright 1999-2018 Gentoo Authors
251 +# Distributed under the terms of the GNU General Public License v2
252 +
253 +EAPI="5"
254 +
255 +PATCH_VER="1.3"
256 +UCLIBC_VER="1.0"
257 +
258 +# Hardened gcc 4 stuff
259 +PIE_VER="0.6.4"
260 +SPECS_VER="0.2.0"
261 +SPECS_GCC_VER="4.4.3"
262 +# arch/libc configurations known to be stable with {PIE,SSP}-by-default
263 +PIE_GLIBC_STABLE="x86 amd64 mips ppc ppc64 arm ia64"
264 +PIE_UCLIBC_STABLE="x86 arm amd64 mips ppc ppc64"
265 +SSP_STABLE="amd64 x86 mips ppc ppc64 arm"
266 +# uclibc need tls and nptl support for SSP support
267 +# uclibc need to be >= 0.9.33
268 +SSP_UCLIBC_STABLE="x86 amd64 mips ppc ppc64 arm"
269 +#end Hardened stuff
270 +
271 +TOOLCHAIN_GCC_PV=4.9.4
272 +
273 +inherit eutils toolchain-funcs toolchain
274 +
275 +REL=4.9
276 +MYP=gcc-${REL}-gpl-${PV}-src
277 +BTSTRP_X86=gnat-gpl-2014-x86-linux-bin
278 +BTSTRP_AMD64=gnat-gpl-2014-x86_64-linux-bin
279 +
280 +DESCRIPTION="GNAT Ada Compiler - GPL version"
281 +HOMEPAGE="http://libre.adacore.com/"
282 +SRC_URI+="
283 + http://mirrors.cdn.adacore.com/art/57399304c7a447658e0aff7f
284 + -> ${P}-src.tar.gz
285 + http://mirrors.cdn.adacore.com/art/573992d4c7a447658d00e1db
286 + -> ${MYP}.tar.gz
287 + http://mirrors.cdn.adacore.com/art/57399232c7a447658e0aff7d
288 + -> gcc-interface-${REL}-gpl-${PV}-src.tar.gz
289 + bootstrap? (
290 + amd64? (
291 + http://mirrors.cdn.adacore.com/art/564b3ebec8e196b040fbe66c ->
292 + ${BTSTRP_AMD64}.tar.gz
293 + )
294 + x86? (
295 + http://mirrors.cdn.adacore.com/art/564b3e9dc8e196b040fbe248 ->
296 + ${BTSTRP_X86}.tar.gz
297 + )
298 + )"
299 +
300 +LICENSE+=" GPL-2 GPL-3"
301 +SLOT="${TOOLCHAIN_GCC_PV}"
302 +KEYWORDS="~amd64 ~x86"
303 +IUSE="bootstrap"
304 +
305 +RDEPEND="!sys-devel/gcc:${TOOLCHAIN_GCC_PV}"
306 +DEPEND="${RDEPEND}
307 + elibc_glibc? ( >=sys-libs/glibc-2.8 )
308 + >=sys-devel/binutils-2.20"
309 +
310 +PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.8 )"
311 +
312 +S="${WORKDIR}"/${MYP}
313 +
314 +FSFGCC=gcc-${TOOLCHAIN_GCC_PV}
315 +
316 +pkg_setup() {
317 + toolchain_pkg_setup
318 +
319 + if use amd64; then
320 + BTSTRP=${BTSTRP_AMD64}
321 + else
322 + BTSTRP=${BTSTRP_X86}
323 + fi
324 + if use bootstrap; then
325 + GCC="${WORKDIR}"/${BTSTRP}/bin/gcc
326 + else
327 + GCC=${ADA:-$(tc-getCC)}
328 + fi
329 + CC=${GCC}
330 + local base=$(basename ${GCC})
331 + CXX="${base/gcc/g++}"
332 + GNATMAKE="${base/gcc/gnatmake}"
333 + GNATBIND="${base/gcc/gnatbind}"
334 + if [[ ${base} != ${GCC} ]] ; then
335 + local path=$(dirname ${GCC})
336 + GNATMAKE="${path}/${GNATMAKE}"
337 + GNATBIND="${path}/${GNATBIND}"
338 + CXX="${path}/${CXX}"
339 + fi
340 +}
341 +
342 +src_unpack() {
343 + if ! use bootstrap && [[ -z "$(type ${GNATMAKE} 2>/dev/null)" ]] ; then
344 + eerror "You need a gcc compiler that provides the Ada Compiler:"
345 + eerror "1) use gcc-config to select the right compiler or"
346 + eerror "2) set the bootstrap use flag"
347 + die "ada compiler not available"
348 + fi
349 +
350 + GCC_A_FAKEIT="${P}-src.tar.gz
351 + ${MYP}.tar.gz
352 + ${FSFGCC}.tar.bz2
353 + gcc-interface-${REL}-gpl-${PV}-src.tar.gz"
354 + if use bootstrap; then
355 + GCC_A_FAKEIT="${GCC_A_FAKEIT} ${BTSTRP}.tar.gz"
356 + fi
357 +
358 + toolchain_src_unpack
359 + if use bootstrap; then
360 + rm ${BTSTRP}/libexec/gcc/${CHOST}/4.7.4/ld || die
361 + fi
362 +}
363 +
364 +src_prepare() {
365 + mv ../${P}-src/src/ada gcc/ || die
366 + mv ../gcc-interface-${REL}-gpl-${PV}-src gcc/ada/gcc-interface || die
367 +
368 + sed -i \
369 + -e "s:gnatmake:${GNATMAKE}:g" \
370 + gcc/ada/Make-generated.in || die "sed failed"
371 +
372 + sed -i \
373 + -e "/xoscons/s:gnatmake:${GNATMAKE}:g" \
374 + gcc/ada/gcc-interface/Makefile.in || die "sed failed"
375 +
376 + mv ../${FSFGCC}/gcc/doc/gcc.info gcc/doc/ || die
377 + mv ../${FSFGCC}/libjava . || die
378 + rm -r ../${FSFGCC} || die
379 +
380 + cd ..
381 + epatch "${FILESDIR}"/${P}-gentoo.patch
382 + rm patch/10_all_default-fortify-source.patch
383 + rm piepatch/34_all_gcc48_config_i386.patch
384 + cd -
385 +
386 + if has_version '<sys-libs/glibc-2.12' ; then
387 + ewarn "Your host glibc is too old; disabling automatic fortify."
388 + ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
389 + EPATCH_EXCLUDE+=" 10_all_default-fortify-source.patch"
390 + fi
391 +
392 + # Bug 638056
393 + epatch "${FILESDIR}/${P}-bootstrap.patch"
394 + # add Finalization_Size Attribute
395 + epatch "${FILESDIR}/${P}-finalization.patch"
396 +
397 + toolchain_src_prepare
398 +
399 + use vanilla && return 0
400 + # Use -r1 for newer piepatchet that use DRIVER_SELF_SPECS for the hardened specs.
401 + [[ ${CHOST} == ${CTARGET} ]] && epatch "${FILESDIR}"/gcc-spec-env-r1.patch
402 +}
403 +
404 +src_configure() {
405 + local trueGCC_BRANCH_VER=${GCC_BRANCH_VER}
406 + GCC_BRANCH_VER=$(gcc-version)
407 + downgrade_arch_flags
408 + GCC_BRANCH_VER=${trueGCC_BRANCH_VER}
409 + toolchain_src_configure \
410 + --enable-languages=ada \
411 + --disable-libada \
412 + CC=${GCC} \
413 + GNATBIND=${GNATBIND} \
414 + GNATMAKE=yes
415 +}
416 +
417 +src_compile() {
418 + unset ADAFLAGS
419 + toolchain_src_compile
420 + gcc_do_make "-C gcc gnatlib-shared"
421 + ln -s gcc ../build/prev-gcc || die
422 + ln -s ${CHOST} ../build/prev-${CHOST} || die
423 + gcc_do_make "-C gcc gnattools"
424 +}
425 +
426 +src_install() {
427 + toolchain_src_install
428 + cd "${D}"${BINPATH}
429 + for x in gnat*; do
430 + # For some reason, g77 gets made instead of ${CTARGET}-g77...
431 + # this should take care of that
432 + if [[ -f ${x} ]] ; then
433 + # In case they're hardlinks, clear out the target first
434 + # otherwise the mv below will complain.
435 + rm -f ${CTARGET}-${x}
436 + mv ${x} ${CTARGET}-${x}
437 + fi
438 +
439 + if [[ -f ${CTARGET}-${x} ]] ; then
440 + if ! is_crosscompile ; then
441 + ln -sf ${CTARGET}-${x} ${x}
442 + dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
443 + /usr/bin/${x}-${GCC_CONFIG_VER}
444 + fi
445 + # Create versioned symlinks
446 + dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
447 + /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
448 + fi
449 +
450 + if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
451 + rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
452 + ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
453 + fi
454 + done
455 +}
456 +
457 +pkg_postinst () {
458 + toolchain_pkg_postinst
459 + einfo "This provide the GNAT compiler with gcc for ada/c/c++ and more"
460 + einfo "The compiler binary is gcc-${TOOLCHAIN_GCC_PV}"
461 + einfo "Even if the c/c++ compilers are using almost the same patched"
462 + einfo "source as the sys-devel/gcc package its use is not extensively"
463 + einfo "tested, and not supported for updating your system, except for ada"
464 + einfo "related packages"
465 +}