public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Adding Ada support
@ 2023-12-09 15:04 Luke A. Guest
  2023-12-09 15:12 ` Sam James
  0 siblings, 1 reply; 9+ messages in thread
From: Luke A. Guest @ 2023-12-09 15:04 UTC (permalink / raw)
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1329 bytes --]

Hi,

Can we add the following patch to the toolchain.eclass? I want to stop 
having to mess with this overlay. The diff can be generated by grabbing 
the repo https://github.com/Lucretia/ada-overlay and running 
./scripts/diff_eclass.sh.

The only thing I'm not sure about is the BDEPEND stuff.

The reason for doing this is because gnat-gpl is dead, more info can be 
found here https://www.adacore.com/community.

The 
https://github.com/Lucretia/ada-overlay/tree/master/dev-lang/ada-bootstrap 
ebuilds provide bootstrap compilers, the archives are hosted on dropbox, 
from 9.5.0 -> 14.

The scripts/build-bootstrap.sh script will build a bootstrap for a 
particular version based on an env var.

As for anything in dev-ada/* well, the ada guy would need to work on 
that really, I'm not really experienced enough to handle it properly.

Given GCC is masked up to :10 now, the gnat gpr tools / libs might be 
easier to get going with single versions covering numerous toolchain 
versions.

Alire would need to be added at some point, http://alire.ada.dev/ to 
provide an easier way to get packages going.

I originally envisioned gnatmake, gprbuild eclasses to cover building 
simple projects with one entry point (gnatmake) and projects (gprbuild). 
I think an alire based eclass would need to be added as well.

Thanks,
Luke.

[-- Attachment #2: gentoo-diff.patch --]
[-- Type: text/x-patch, Size: 3783 bytes --]

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 60769c93877f..7368894abd2f 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -250,7 +250,6 @@ if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then
 	IUSE+=" go"
 	IUSE+=" +sanitize"  TC_FEATURES+=( sanitize )
 	IUSE+=" graphite" TC_FEATURES+=( graphite )
-	IUSE+=" ada"
 	IUSE+=" vtv"
 	IUSE+=" jit"
 	tc_version_is_between 5.0 9 && IUSE+=" mpx"
@@ -259,6 +258,7 @@ if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then
 	IUSE+=" systemtap" TC_FEATURES+=( systemtap )
 
 	tc_version_is_at_least 9.0 && IUSE+=" d" TC_FEATURES+=( d )
+	tc_version_is_at_least 9.0 && IUSE+=" ada" TC_FEATURES+=( ada )
 	tc_version_is_at_least 9.1 && IUSE+=" lto"
 	tc_version_is_at_least 10 && IUSE+=" cet"
 	tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=( zstd )
@@ -284,8 +284,7 @@ fi
 
 #---->> DEPEND <<----
 
-RDEPEND="
-	sys-libs/zlib
+RDEPEND="sys-libs/zlib
 	virtual/libiconv
 	nls? ( virtual/libintl )
 "
@@ -311,6 +310,20 @@ BDEPEND="
 		>=sys-devel/autogen-5.5.4
 	)
 "
+
+# Ada in 9.0+ is self-hosting and needs Ada to bootstrap.
+# Taken from the D version below. I'm fairly sure if this is now correct,
+# We should build using either ada-bootstrap:<SLOT> if the installed gcc has
+# Ada disabled or the installed slot which matches the slot being built.
+if tc_has_feature ada ; then
+	if tc_version_is_at_least 9.0 ; then
+		BDEPEND+=" ada? ( || (
+			<sys-devel/gcc-${SLOT}[ada(-)]
+			dev-lang/ada-bootstrap:${GCCMAJOR}
+		) )"
+	fi
+fi
+
 DEPEND="${RDEPEND}"
 
 if [[ ${PN} == gcc && ${PV} == *_p* ]] ; then
@@ -341,12 +354,6 @@ if tc_has_feature valgrind ; then
 	BDEPEND+=" valgrind? ( dev-util/valgrind )"
 fi
 
-# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
-# supports Ada.
-if tc_has_feature ada ; then
-	BDEPEND+=" ada? ( || ( sys-devel/gcc[ada] dev-lang/gnat-gpl[ada] ) )"
-fi
-
 # TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
 # supports D.
 if tc_has_feature d && tc_version_is_at_least 12.0 ; then
@@ -489,6 +496,8 @@ SRC_URI=$(get_gcc_src_uri)
 
 toolchain_pkg_pretend() {
 	if ! _tc_use_if_iuse cxx ; then
+		_tc_use_if_iuse ada && \
+			ewarn 'Ada requires a C++ compiler, disabled due to USE="-cxx"'
 		_tc_use_if_iuse go && \
 			ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
 		_tc_use_if_iuse objc++ && \
@@ -784,6 +793,30 @@ toolchain_src_configure() {
 	fi
 	[[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
 
+	if _tc_use_if_iuse ada ; then
+		local PREVSLOT=$((${GCCMAJOR} - 1)) # Can't use SLOT because 9.5.0.
+		einfo " >> Ada Bootstrap slot is ${GCCMAJOR}/${PREVSLOT}"
+
+		# Make sure we set a path to the Ada bootstrap if gcc[ada] is not already
+		# installed. GNAT can usually be built using the last major version and
+		# the current version, at least.
+		if has_version -b "sys-devel/gcc:${SLOT}[ada]" ; then
+			einfo "Using GNAT compiler installed in slot ${SLOT}..."
+
+			PATH="${BINPATH}:${PATH}"
+		elif has_version -b "sys-devel/gcc:${PREVSLOT}[ada]" ; then
+			einfo "Using GNAT compiler installed in previous slot ${PREVSLOT}..."
+
+			PATH="${PREFIX}/${CTARGET}/gcc-bin/${PREVSLOT}:${PATH}"
+		else
+			einfo "Using bootstrap GNAT compiler..."
+
+			PATH="/opt/ada-bootstrap-${GCCMAJOR}/bin:${PATH}"
+
+			export PATH
+		fi
+	fi
+
 	confgcc+=(
 		--prefix="${PREFIX}"
 		--bindir="${BINPATH}"
@@ -1335,6 +1368,8 @@ toolchain_src_configure() {
 	einfo "DATAPATH:        ${DATAPATH}"
 	einfo "STDCXX_INCDIR:   ${STDCXX_INCDIR}"
 	einfo "Languages:       ${GCC_LANG}"
+	einfo "GCC version:     $(gcc -v 2>&1|grep " version " | awk '{ print $3 }')"
+	is_ada && einfo "GNAT version:    $(gnat 2>&1|grep GNAT | awk '{ print $2 }')"
 	echo
 
 	# Build in a separate build tree

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-12-09 23:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-09 15:04 [gentoo-dev] Adding Ada support Luke A. Guest
2023-12-09 15:12 ` Sam James
2023-12-09 15:24   ` Luke A. Guest
2023-12-09 15:30     ` Luke A. Guest
2023-12-09 15:37       ` Luke A. Guest
2023-12-09 15:51   ` Luke A. Guest
2023-12-09 23:40     ` Eli Schwartz
2023-12-09 17:55   ` Luke A. Guest
2023-12-09 18:08     ` Luke A. Guest

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox