[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH 5/5] Disable header wrapping on unsupported ABIs.
From:       Michał Górny <mgorny () gentoo ! org>
Date:       2014-04-24 20:26:39
Message-ID: 1398371199-21869-5-git-send-email-mgorny () gentoo ! org
[Download RAW message or body]

After the previous changes, header wrapping is enabled even if only
a single ABI is enabled. While this is generally beneficial on multilib
arches, it triggered failures due to unsupported ABIs in header wrapping
code on other arches.

Instead, simply disable header wrapping on every ABI that does not
support it. This gives us one of the following cases:

a) on multilib arches, every ABI is supported, so headers are wrapped
properly and everything works,

b) on non-multilib arches, the ABI is unsupported and header wrapping
gets disabled,

c) on broken multilib arches where one of the ABIs is unsupported,
headers are partially wrapped and multilib header consistency check
jumps in shouting something gone terribly wrong.
---
 eclass/multilib-build.eclass | 101 ++++++++++++++++++++++++-------------------
 1 file changed, 57 insertions(+), 44 deletions(-)

diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
index 9dfec0a..b3bbb0d 100644
--- a/eclass/multilib-build.eclass
+++ b/eclass/multilib-build.eclass
@@ -342,22 +342,52 @@ multilib_prepare_wrappers() {
 		fi
 	done
 
-	for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
-		# drop leading slash if it's there
-		f=${f#/}
-
-		if [[ ${f} != usr/include/* ]]; then
-			die "Wrapping headers outside of /usr/include is not supported at the moment."
-		fi
-		# and then usr/include
-		f=${f#usr/include}
+	if [[ ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
+		# XXX: get abi_* directly
+		local abi_flag
+		case "${ABI}" in
+			amd64|amd64_fbsd)
+				abi_flag=abi_x86_64;;
+			x86|x86_fbsd)
+				abi_flag=abi_x86_32;;
+			x32)
+				abi_flag=abi_x86_x32;;
+			n32)
+				abi_flag=abi_mips_n32;;
+			n64)
+				abi_flag=abi_mips_n64;;
+			o32)
+				abi_flag=abi_mips_o32;;
+		esac
+
+		# If abi_flag is unset, then header wrapping is unsupported
+		# on this ABI. This could mean either that:
+		#
+		# 1) the arch doesn't support multilib at all -- in this case,
+		# the headers are not wrapped and everything works as expected,
+		#
+		# 2) someone added new ABI and forgot to update the function --
+		# in this case, the header consistency check will notice one of
+		# those ABIs has an extra header (compared to the header moved
+		# for wrapping) and will fail.
+
+		if [[ ${abi_flag} ]]; then
+			for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
+				# drop leading slash if it's there
+				f=${f#/}
+
+				if [[ ${f} != usr/include/* ]]; then
+					die "Wrapping headers outside of /usr/include is not supported at the moment."
+				fi
+				# and then usr/include
+				f=${f#usr/include}
 
-		local dir=${f%/*}
+				local dir=${f%/*}
 
-		if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
-			dodir "/tmp/multilib-include${dir}"
-			# a generic template
-			cat > "${ED}/tmp/multilib-include${f}" <<_EOF_
+				if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
+					dodir "/tmp/multilib-include${dir}"
+					# a generic template
+					cat > "${ED}/tmp/multilib-include${f}" <<_EOF_
 /* This file is auto-generated by multilib-build.eclass
  * as a multilib-friendly wrapper. For the original content,
  * please see the files that are #included below.
@@ -383,38 +413,21 @@ multilib_prepare_wrappers() {
 #	error "No ABI matched, please report a bug to bugs.gentoo.org"
 #endif
 _EOF_
-		fi
+				fi
+
+				# Some ABIs may have install less files than others.
+				if [[ -f ${root}/usr/include${f} ]]; then
+					# $CHOST shall be set by multilib_toolchain_setup
+					dodir "/tmp/multilib-include/${CHOST}${dir}"
+					mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
 
-		# Some ABIs may have install less files than others.
-		if [[ -f ${root}/usr/include${f} ]]; then
-			# $CHOST shall be set by multilib_toolchain_setup
-			dodir "/tmp/multilib-include/${CHOST}${dir}"
-			mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
-
-			# XXX: get abi_* directly
-			local abi_flag
-			case "${ABI}" in
-				amd64|amd64_fbsd)
-					abi_flag=abi_x86_64;;
-				x86|x86_fbsd)
-					abi_flag=abi_x86_32;;
-				x32)
-					abi_flag=abi_x86_x32;;
-				n32)
-					abi_flag=abi_mips_n32;;
-				n64)
-					abi_flag=abi_mips_n64;;
-				o32)
-					abi_flag=abi_mips_o32;;
-				*)
-					die "Header wrapping for ${ABI} not supported yet";;
-			esac
-
-			# Note: match a space afterwards to avoid collision potential.
-			sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
-				-i "${ED}/tmp/multilib-include${f}" || die
+					# Note: match a space afterwards to avoid collision potential.
+					sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
+						-i "${ED}/tmp/multilib-include${f}" || die
+				fi
+			done
 		fi
-	done
+	fi
 }
 
 # @FUNCTION: multilib_install_wrappers
-- 
1.9.2


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic