diff options
| author | Leah Rowe <leah@libreboot.org> | 2024-12-27 15:44:51 +0000 | 
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2024-12-30 00:21:02 +0000 | 
| commit | 01fc65a0a9d5310732b95ce3cd2c96ad01479c25 (patch) | |
| tree | 3599a16960cd9d58f01d08d7689994a4f04c0a7f | |
| parent | 424b0c7103b71c50396219352cc5f13a9078a461 (diff) | |
Mitigate Debian Trixie/Sid GCC/GNAT version mismatch
When I tested Debian Trixie, and Debian Sid, I saw that
GCC in PATH pointed to gcc-14, but gnat in path pointed
to GNAT-13, even if you manually install gnat-14.
GNAT 14 was marked experimental, but GCC 14 was marked
for use, in the apt repositories.
So this patch doesn't address the mismatch when doing e.g.
apt-get install gcc gnat
I will address the actual package dependency in a follow-up
patch, on the Debian dependencies config.
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | include/lib.sh | 3 | ||||
| -rw-r--r-- | include/path.sh | 46 | ||||
| -rwxr-xr-x | script/trees | 3 | 
4 files changed, 53 insertions, 0 deletions
| @@ -41,3 +41,4 @@  /f  /r  /e +/xbmkpath/ diff --git a/include/lib.sh b/include/lib.sh index 92651c84..f204309d 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -95,6 +95,9 @@ if [ -z "${TMPDIR+x}" ]; then  	export TMPDIR="/tmp"  	export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"  	touch lock || $err "cannot create 'lock' file" +	rm -Rf xbmkpath || $err "cannot create xbmkpath" +	mkdir -p xbmkpath || $err "cannot create xbmkpath" +	export PATH="$PWD/xbmkpath:$PATH" || $err "Can't create xbmkpath"  	xbmk_parent="y"  fi diff --git a/include/path.sh b/include/path.sh new file mode 100644 index 00000000..04e1d887 --- /dev/null +++ b/include/path.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env sh +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Leah Rowe <leah@libreboot.org> + +# debian trixie/sid ship with gcc 14 when running "gcc", +# but (as of December 2024) gnat is gnat-13. we must create +# a symlink accordingly. +# however, the user may also have gcc 13+14, but only gnat 13 +check_gnat_path() +{ +	eval `setvars "" gccver gnatver gccdir` +	command -v gcc 1>/dev/null || $err "Command 'gcc' unavailable." + +	for _util in gcc gnat; do +		eval "$_util --version 1>/dev/null 2>/dev/null || continue" +		eval "${_util}ver=\"`$_util --version 2>/dev/null | head -n1`\"" +		eval "${_util}ver=\"\${${_util}ver##* }\"" +		eval "${_util}ver=\"\${${_util}ver%%.*}\"" +	done + +	[ -z "$gccver" ] && $err "Cannot detect host GCC version" +	[ "$gnatver" = "$gccver" ] && return 0 + +	gccdir="$(dirname "$(command -v gcc)")" + +	for _gnatbin in "$gccdir/gnat-"*; do +		[ -f "$_gnatbin" ] || continue +		[ "${_gnatbin#"$gccdir/gnat-"}" = "$gccver" ] || continue +		gnatver="${_gnatbin#"$gccdir/gnat-"}" +		break +	done + +	[ "$gnatver" = "$gccver" ] || $err "GCC/GNAT versions do not match." + +	# we already established that the versions match, but if gnat isn't +	# in path, then we assume it's in e.g. /usr/bin/gnat-14 +	( +	x_ cd xbmkpath +	for _gnatbin in "$gccdir/gnat"*"-$gccver"; do +		[ -e "$_gnatbin" ] || continue +		_gnatutil="${_gnatbin##*/}" +		ln -s "$_gnatbin" "${_gnatutil%"-$gccver"}" || \ +		    $err "E: ln -s \"$_gnatbin\" \"${_gnatutil%"-$gccver"}\"" +	done +	) || $err "Cannot create gnat-$gccver link in $gccdir" +} diff --git a/script/trees b/script/trees index 698d2b34..b9fd21eb 100755 --- a/script/trees +++ b/script/trees @@ -8,6 +8,7 @@ set -u -e  . "include/lib.sh"  . "include/git.sh" +. "include/path.sh"  XBMKPATH="$PATH" @@ -205,6 +206,8 @@ check_cross_compiler()  		xfix="${_xarch%-*}" && [ "$xfix" = "x86_64" ] && xfix="x64" +		check_gnat_path +  		# sometimes buildgcc fails for like no reason. try twice.  		make -C "$cbdir" crossgcc-$xfix $xgccargs || \  		    make -C "$cbdir" crossgcc-$xfix $xgccargs || \ | 
