Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/clang/files/9999/, sys-devel/clang/
Date: Sun, 27 Dec 2020 09:50:56
Message-Id: 1609062572.1b2b62e093d789f6b1a4609c866581991e287b88.grobian@gentoo
1 commit: 1b2b62e093d789f6b1a4609c866581991e287b88
2 Author: Jacob Floyd <cognifloyd <AT> gmail <DOT> com>
3 AuthorDate: Sat Dec 19 00:53:24 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 27 09:49:32 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1b2b62e0
7
8 sys-devel/clang: fix bootstrap on darwin prefix
9
10 Adjust the clang internal header/framework search paths when building on
11 darwin prefix. We symlink the selected MacOSX.sdk to EPREFIX/MacOSX.sdk
12 during bootstrap, so that is the correct place to get system headers,
13 such as those for libc, or for system framework headers, that we do not
14 replace in prefix.
15
16 Bug: https://bugs.gentoo.org/758167
17 Signed-off-by: Jacob Floyd <cognifloyd <AT> gmail.com>
18 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
19
20 sys-devel/clang/clang-11.0.0.ebuild | 13 ++++-
21 sys-devel/clang/clang-11.0.1.9999.ebuild | 11 +++-
22 sys-devel/clang/clang-11.0.1_rc1.ebuild | 11 +++-
23 sys-devel/clang/clang-11.0.1_rc2.ebuild | 11 +++-
24 sys-devel/clang/clang-12.0.0.9999.ebuild | 11 +++-
25 sys-devel/clang/files/9999/prefix-dirs.patch | 75 ++++++++++++++++++++++++++++
26 6 files changed, 126 insertions(+), 6 deletions(-)
27
28 diff --git a/sys-devel/clang/clang-11.0.0.ebuild b/sys-devel/clang/clang-11.0.0.ebuild
29 index cf0dde1f160..1d4f4bad16c 100644
30 --- a/sys-devel/clang/clang-11.0.0.ebuild
31 +++ b/sys-devel/clang/clang-11.0.0.ebuild
32 @@ -5,7 +5,7 @@ EAPI=7
33
34 PYTHON_COMPAT=( python3_{6..9} )
35 inherit cmake llvm llvm.org multilib-minimal pax-utils \
36 - python-single-r1 toolchain-funcs
37 + prefix python-single-r1 toolchain-funcs
38
39 DESCRIPTION="C language family frontend for LLVM"
40 HOMEPAGE="https://llvm.org/"
41 @@ -30,7 +30,7 @@ ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
42
43 LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA MIT"
44 SLOT="$(ver_cut 1)"
45 -KEYWORDS="amd64 arm arm64 ppc64 ~riscv x86 ~amd64-linux"
46 +KEYWORDS="amd64 arm arm64 ppc64 ~riscv x86 ~amd64-linux ~x64-macos"
47 IUSE="debug default-compiler-rt default-libcxx default-lld
48 doc +static-analyzer test xml kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}"
49 REQUIRED_USE="${PYTHON_REQUIRED_USE}
50 @@ -75,6 +75,10 @@ PDEPEND="
51 # Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
52 # multilib clang* libraries (not runtime, not wrappers).
53
54 +PATCHES=(
55 + "${FILESDIR}"/9999/prefix-dirs.patch
56 +)
57 +
58 pkg_setup() {
59 LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
60 python-single-r1_pkg_setup
61 @@ -88,6 +92,11 @@ src_prepare() {
62 llvm.org_src_prepare
63
64 mv ../clang-tools-extra tools/extra || die
65 +
66 + # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
67 + eprefixify \
68 + lib/Frontend/InitHeaderSearch.cpp \
69 + lib/Driver/ToolChains/Darwin.cpp || die
70 }
71
72 check_distribution_components() {
73
74 diff --git a/sys-devel/clang/clang-11.0.1.9999.ebuild b/sys-devel/clang/clang-11.0.1.9999.ebuild
75 index 4a3a05b4df8..c5362450b51 100644
76 --- a/sys-devel/clang/clang-11.0.1.9999.ebuild
77 +++ b/sys-devel/clang/clang-11.0.1.9999.ebuild
78 @@ -5,7 +5,7 @@ EAPI=7
79
80 PYTHON_COMPAT=( python3_{6..9} )
81 inherit cmake llvm llvm.org multilib-minimal pax-utils \
82 - python-single-r1 toolchain-funcs
83 + prefix python-single-r1 toolchain-funcs
84
85 DESCRIPTION="C language family frontend for LLVM"
86 HOMEPAGE="https://llvm.org/"
87 @@ -77,6 +77,10 @@ llvm.org_set_globals
88 # Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
89 # multilib clang* libraries (not runtime, not wrappers).
90
91 +PATCHES=(
92 + "${FILESDIR}"/9999/prefix-dirs.patch
93 +)
94 +
95 pkg_setup() {
96 LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
97 python-single-r1_pkg_setup
98 @@ -90,6 +94,11 @@ src_prepare() {
99 llvm.org_src_prepare
100
101 mv ../clang-tools-extra tools/extra || die
102 +
103 + # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
104 + eprefixify \
105 + lib/Frontend/InitHeaderSearch.cpp \
106 + lib/Driver/ToolChains/Darwin.cpp || die
107 }
108
109 check_distribution_components() {
110
111 diff --git a/sys-devel/clang/clang-11.0.1_rc1.ebuild b/sys-devel/clang/clang-11.0.1_rc1.ebuild
112 index 4a3a05b4df8..c5362450b51 100644
113 --- a/sys-devel/clang/clang-11.0.1_rc1.ebuild
114 +++ b/sys-devel/clang/clang-11.0.1_rc1.ebuild
115 @@ -5,7 +5,7 @@ EAPI=7
116
117 PYTHON_COMPAT=( python3_{6..9} )
118 inherit cmake llvm llvm.org multilib-minimal pax-utils \
119 - python-single-r1 toolchain-funcs
120 + prefix python-single-r1 toolchain-funcs
121
122 DESCRIPTION="C language family frontend for LLVM"
123 HOMEPAGE="https://llvm.org/"
124 @@ -77,6 +77,10 @@ llvm.org_set_globals
125 # Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
126 # multilib clang* libraries (not runtime, not wrappers).
127
128 +PATCHES=(
129 + "${FILESDIR}"/9999/prefix-dirs.patch
130 +)
131 +
132 pkg_setup() {
133 LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
134 python-single-r1_pkg_setup
135 @@ -90,6 +94,11 @@ src_prepare() {
136 llvm.org_src_prepare
137
138 mv ../clang-tools-extra tools/extra || die
139 +
140 + # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
141 + eprefixify \
142 + lib/Frontend/InitHeaderSearch.cpp \
143 + lib/Driver/ToolChains/Darwin.cpp || die
144 }
145
146 check_distribution_components() {
147
148 diff --git a/sys-devel/clang/clang-11.0.1_rc2.ebuild b/sys-devel/clang/clang-11.0.1_rc2.ebuild
149 index 4a3a05b4df8..c5362450b51 100644
150 --- a/sys-devel/clang/clang-11.0.1_rc2.ebuild
151 +++ b/sys-devel/clang/clang-11.0.1_rc2.ebuild
152 @@ -5,7 +5,7 @@ EAPI=7
153
154 PYTHON_COMPAT=( python3_{6..9} )
155 inherit cmake llvm llvm.org multilib-minimal pax-utils \
156 - python-single-r1 toolchain-funcs
157 + prefix python-single-r1 toolchain-funcs
158
159 DESCRIPTION="C language family frontend for LLVM"
160 HOMEPAGE="https://llvm.org/"
161 @@ -77,6 +77,10 @@ llvm.org_set_globals
162 # Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
163 # multilib clang* libraries (not runtime, not wrappers).
164
165 +PATCHES=(
166 + "${FILESDIR}"/9999/prefix-dirs.patch
167 +)
168 +
169 pkg_setup() {
170 LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
171 python-single-r1_pkg_setup
172 @@ -90,6 +94,11 @@ src_prepare() {
173 llvm.org_src_prepare
174
175 mv ../clang-tools-extra tools/extra || die
176 +
177 + # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
178 + eprefixify \
179 + lib/Frontend/InitHeaderSearch.cpp \
180 + lib/Driver/ToolChains/Darwin.cpp || die
181 }
182
183 check_distribution_components() {
184
185 diff --git a/sys-devel/clang/clang-12.0.0.9999.ebuild b/sys-devel/clang/clang-12.0.0.9999.ebuild
186 index e5da1c5cedb..8ebb9ceea5e 100644
187 --- a/sys-devel/clang/clang-12.0.0.9999.ebuild
188 +++ b/sys-devel/clang/clang-12.0.0.9999.ebuild
189 @@ -5,7 +5,7 @@ EAPI=7
190
191 PYTHON_COMPAT=( python3_{6..9} )
192 inherit cmake llvm llvm.org multilib-minimal pax-utils \
193 - python-single-r1 toolchain-funcs
194 + prefix python-single-r1 toolchain-funcs
195
196 DESCRIPTION="C language family frontend for LLVM"
197 HOMEPAGE="https://llvm.org/"
198 @@ -77,6 +77,10 @@ llvm.org_set_globals
199 # Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
200 # multilib clang* libraries (not runtime, not wrappers).
201
202 +PATCHES=(
203 + "${FILESDIR}"/9999/prefix-dirs.patch
204 +)
205 +
206 pkg_setup() {
207 LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
208 python-single-r1_pkg_setup
209 @@ -88,6 +92,11 @@ src_prepare() {
210 BUILD_DIR=${WORKDIR}/x/y/clang
211
212 llvm.org_src_prepare
213 +
214 + # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
215 + eprefixify \
216 + lib/Frontend/InitHeaderSearch.cpp \
217 + lib/Driver/ToolChains/Darwin.cpp || die
218 }
219
220 check_distribution_components() {
221
222 diff --git a/sys-devel/clang/files/9999/prefix-dirs.patch b/sys-devel/clang/files/9999/prefix-dirs.patch
223 new file mode 100644
224 index 00000000000..0f7b5ca31eb
225 --- /dev/null
226 +++ b/sys-devel/clang/files/9999/prefix-dirs.patch
227 @@ -0,0 +1,75 @@
228 +This mirrors cmake-*-prefix-dirs.patch
229 +
230 +It add EPREFIX to search paths for c/cxx headers.
231 +It also adds EPREFIX/MacOSX.sdk to search paths for c and Frameworks.
232 +Assumes that c++ lib and headers will be installed in the prefix.
233 +
234 +Also, a couple of args are populated by inspecting the SDK,
235 +so, default to EPREFIX/MacOSX.sdk when the sysroot is not specified.
236 +(This does NOT set sysroot).
237 +
238 +The ebuild adds an extra / at the end of EPREFIX so that it is never
239 +an empty string.
240 +
241 +--- a/clang/lib/Frontend/InitHeaderSearch.cpp 2020-11-30 12:53:42.000000000 -0600
242 ++++ b/clang/lib/Frontend/InitHeaderSearch.cpp 2020-11-30 13:57:52.000000000 -0600
243 +@@ -445,6 +445,9 @@
244 + // All header search logic is handled in the Driver for Darwin.
245 + if (triple.isOSDarwin()) {
246 + if (HSOpts.UseStandardSystemIncludes) {
247 ++ // Add Gentoo Prefix framework dirs first
248 ++ AddPath("@GENTOO_PORTAGE_EPREFIX@××××××.sdk/System/Library/Frameworks", System, true);
249 ++ AddPath("@GENTOO_PORTAGE_EPREFIX@××××××.sdk/Library/Frameworks", System, true);
250 + // Add the default framework include paths on Darwin.
251 + AddPath("/System/Library/Frameworks", System, true);
252 + AddPath("/Library/Frameworks", System, true);
253 +--- a/clang/lib/Driver/ToolChains/Darwin.cpp 2020-10-07 05:10:48.000000000 -0500
254 ++++ b/clang/lib/Driver/ToolChains/Darwin.cpp 2020-11-30 12:57:15.000000000 -0600
255 +@@ -1737,9 +1737,9 @@
256 + const ArgList &Args,
257 + const Driver &TheDriver) {
258 + const Arg *A = Args.getLastArg(options::OPT_isysroot);
259 +- if (!A)
260 +- return None;
261 +- StringRef isysroot = A->getValue();
262 ++ //if (!A)
263 ++ // return None;
264 ++ StringRef isysroot = A ? A->getValue() : "@GENTOO_PORTAGE_EPREFIX@××××××.sdk";
265 + auto SDKInfoOrErr = driver::parseDarwinSDKInfo(VFS, isysroot);
266 + if (!SDKInfoOrErr) {
267 + llvm::consumeError(SDKInfoOrErr.takeError());
268 +@@ -1921,13 +1921,14 @@
269 + return DriverArgs.getLastArgValue(options::OPT_isysroot);
270 + if (!getDriver().SysRoot.empty())
271 + return getDriver().SysRoot;
272 +- return "/";
273 ++ return "@GENTOO_PORTAGE_EPREFIX@";
274 + }
275 +
276 + void DarwinClang::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
277 + llvm::opt::ArgStringList &CC1Args) const {
278 + const Driver &D = getDriver();
279 +
280 ++ // Sysroot is effectively Gentoo EPREFIX when -isysroot/-sysroot is not defined
281 + llvm::StringRef Sysroot = GetHeaderSysroot(DriverArgs);
282 +
283 + bool NoStdInc = DriverArgs.hasArg(options::OPT_nostdinc);
284 +@@ -1969,6 +1970,10 @@
285 + SmallString<128> P(Sysroot);
286 + llvm::sys::path::append(P, "usr", "include");
287 + addExternCSystemInclude(DriverArgs, CC1Args, P.str());
288 ++ // And add <sysroot>/MacOSX.sdk/usr/include.
289 ++ SmallString<128> Psdk(Sysroot);
290 ++ llvm::sys::path::append(Psdk, "MacOSX.sdk", "usr", "include");
291 ++ addExternCSystemInclude(DriverArgs, CC1Args, Psdk.str());
292 + }
293 + }
294 +
295 +@@ -2017,6 +2022,7 @@
296 + DriverArgs.hasArg(options::OPT_nostdincxx))
297 + return;
298 +
299 ++ // Sysroot is effectively Gentoo EPREFIX when -isysroot/-sysroot is not defined
300 + llvm::StringRef Sysroot = GetHeaderSysroot(DriverArgs);
301 +
302 + switch (GetCXXStdlibType(DriverArgs)) {