Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: multilib@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 5/5] Disable header wrapping on unsupported ABIs.
Date: Thu, 24 Apr 2014 20:27:52
Message-Id: 1398371199-21869-5-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] multilib RFC: improving wrapping compatibility with non-multilib and multilib-portage systems by "Michał Górny"
1 After the previous changes, header wrapping is enabled even if only
2 a single ABI is enabled. While this is generally beneficial on multilib
3 arches, it triggered failures due to unsupported ABIs in header wrapping
4 code on other arches.
5
6 Instead, simply disable header wrapping on every ABI that does not
7 support it. This gives us one of the following cases:
8
9 a) on multilib arches, every ABI is supported, so headers are wrapped
10 properly and everything works,
11
12 b) on non-multilib arches, the ABI is unsupported and header wrapping
13 gets disabled,
14
15 c) on broken multilib arches where one of the ABIs is unsupported,
16 headers are partially wrapped and multilib header consistency check
17 jumps in shouting something gone terribly wrong.
18 ---
19 eclass/multilib-build.eclass | 101 ++++++++++++++++++++++++-------------------
20 1 file changed, 57 insertions(+), 44 deletions(-)
21
22 diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
23 index 9dfec0a..b3bbb0d 100644
24 --- a/eclass/multilib-build.eclass
25 +++ b/eclass/multilib-build.eclass
26 @@ -342,22 +342,52 @@ multilib_prepare_wrappers() {
27 fi
28 done
29
30 - for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
31 - # drop leading slash if it's there
32 - f=${f#/}
33 -
34 - if [[ ${f} != usr/include/* ]]; then
35 - die "Wrapping headers outside of /usr/include is not supported at the moment."
36 - fi
37 - # and then usr/include
38 - f=${f#usr/include}
39 + if [[ ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
40 + # XXX: get abi_* directly
41 + local abi_flag
42 + case "${ABI}" in
43 + amd64|amd64_fbsd)
44 + abi_flag=abi_x86_64;;
45 + x86|x86_fbsd)
46 + abi_flag=abi_x86_32;;
47 + x32)
48 + abi_flag=abi_x86_x32;;
49 + n32)
50 + abi_flag=abi_mips_n32;;
51 + n64)
52 + abi_flag=abi_mips_n64;;
53 + o32)
54 + abi_flag=abi_mips_o32;;
55 + esac
56 +
57 + # If abi_flag is unset, then header wrapping is unsupported
58 + # on this ABI. This could mean either that:
59 + #
60 + # 1) the arch doesn't support multilib at all -- in this case,
61 + # the headers are not wrapped and everything works as expected,
62 + #
63 + # 2) someone added new ABI and forgot to update the function --
64 + # in this case, the header consistency check will notice one of
65 + # those ABIs has an extra header (compared to the header moved
66 + # for wrapping) and will fail.
67 +
68 + if [[ ${abi_flag} ]]; then
69 + for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
70 + # drop leading slash if it's there
71 + f=${f#/}
72 +
73 + if [[ ${f} != usr/include/* ]]; then
74 + die "Wrapping headers outside of /usr/include is not supported at the moment."
75 + fi
76 + # and then usr/include
77 + f=${f#usr/include}
78
79 - local dir=${f%/*}
80 + local dir=${f%/*}
81
82 - if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
83 - dodir "/tmp/multilib-include${dir}"
84 - # a generic template
85 - cat > "${ED}/tmp/multilib-include${f}" <<_EOF_
86 + if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
87 + dodir "/tmp/multilib-include${dir}"
88 + # a generic template
89 + cat > "${ED}/tmp/multilib-include${f}" <<_EOF_
90 /* This file is auto-generated by multilib-build.eclass
91 * as a multilib-friendly wrapper. For the original content,
92 * please see the files that are #included below.
93 @@ -383,38 +413,21 @@ multilib_prepare_wrappers() {
94 # error "No ABI matched, please report a bug to bugs.gentoo.org"
95 #endif
96 _EOF_
97 - fi
98 + fi
99 +
100 + # Some ABIs may have install less files than others.
101 + if [[ -f ${root}/usr/include${f} ]]; then
102 + # $CHOST shall be set by multilib_toolchain_setup
103 + dodir "/tmp/multilib-include/${CHOST}${dir}"
104 + mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
105
106 - # Some ABIs may have install less files than others.
107 - if [[ -f ${root}/usr/include${f} ]]; then
108 - # $CHOST shall be set by multilib_toolchain_setup
109 - dodir "/tmp/multilib-include/${CHOST}${dir}"
110 - mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
111 -
112 - # XXX: get abi_* directly
113 - local abi_flag
114 - case "${ABI}" in
115 - amd64|amd64_fbsd)
116 - abi_flag=abi_x86_64;;
117 - x86|x86_fbsd)
118 - abi_flag=abi_x86_32;;
119 - x32)
120 - abi_flag=abi_x86_x32;;
121 - n32)
122 - abi_flag=abi_mips_n32;;
123 - n64)
124 - abi_flag=abi_mips_n64;;
125 - o32)
126 - abi_flag=abi_mips_o32;;
127 - *)
128 - die "Header wrapping for ${ABI} not supported yet";;
129 - esac
130 -
131 - # Note: match a space afterwards to avoid collision potential.
132 - sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
133 - -i "${ED}/tmp/multilib-include${f}" || die
134 + # Note: match a space afterwards to avoid collision potential.
135 + sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
136 + -i "${ED}/tmp/multilib-include${f}" || die
137 + fi
138 + done
139 fi
140 - done
141 + fi
142 }
143
144 # @FUNCTION: multilib_install_wrappers
145 --
146 1.9.2