1 |
To all interested in Gentoo Prefix on recent macOS. |
2 |
|
3 |
In the past few releases of macOS, /usr/include has disappeared. While |
4 |
this previously was remedied by performing some commands, Apple has made |
5 |
this more strict, and it appears the way forwards, is by no longer |
6 |
relying on /usr/include. |
7 |
|
8 |
To deal with this, the packages sys-kernel/xnu-headers and |
9 |
sys-libs/darwin-libc-headers were added to @system for newer macOS |
10 |
profiles. While you may have seen these packages coming in, getting |
11 |
some updates here and there, they may still not be perfect, yet I think |
12 |
we're getting somewhere. The purpose of these packages obviously is to |
13 |
provide system headers and frameworks without relying on Xcode. |
14 |
|
15 |
Next I've modified the bootstrap script to unpack a Prefix-built clang |
16 |
compiler, and use it to bootstrap. This, in addition to the headers, |
17 |
allowed me to progress until stage2 where a compiler is built. This |
18 |
failed, for a number of reasons. 1) requirement of cmake, which is |
19 |
horrible. It requires way too much in terms of dependencies, so I |
20 |
resorted to an unpacked Prefix-built version to provide it. Can't use |
21 |
upstream's binaries for cmake, because they insist on using Xcode SDKs. |
22 |
Next, 2) clang fails to build halfway because it throws away CXXFLAGS |
23 |
pointing to the headers provided. I seem to remember that this is what |
24 |
GCC build does as well, so not that surprising, but it basically renders |
25 |
the approach useless. |
26 |
|
27 |
This lead me to investigating how to tell the bootstrap compiler to keep |
28 |
looking for the headers we provided. Turns out the compiler is |
29 |
hard-wired to add c++ headers (stdinc) to its search-path, and this is |
30 |
necessary (at least on Darwin) because the math.h header appears twice, |
31 |
and only one of them is compatible with c++ code. Anyway. Apple seems |
32 |
to use -isysroot to point to an SDK that's selected/targetted. It seems |
33 |
to me, at this point we should follow that lead, and simply turn the |
34 |
Prefix into such sysroot. Experimenting with this option on our |
35 |
Prefix-build clang, results in not exactly desirable behaviour. Because |
36 |
the offset prefix is added to the compiler's search paths, nothing ends |
37 |
up right. |
38 |
So I downloaded clang binary from llvm.org, and tried the same. That |
39 |
made more sense, and it seems the search path is correct there. |
40 |
|
41 |
What I want to try now, is if I can set CC/CXX to "clang -isysroot |
42 |
/path/to/prefix", and if that will get me through compiler building of |
43 |
stage2 during bootstrap. |
44 |
|
45 |
If that works, it seems the first step towards Xcode free bootstrapping |
46 |
on macOS. There will be some questions towards how we build our clang, |
47 |
if we should step away from patching it and using isysroot instead. |
48 |
Finally, how we're going to provide the binaries that we want to use |
49 |
during bootstraps. Ideally we can provide stage1/stage2 by simply |
50 |
installing form binpkgs, for instance using q/portage-utils. |
51 |
|
52 |
End of update, hopefully bootstrapping can be working again soon. |
53 |
|
54 |
Thanks, |
55 |
Fabian |
56 |
|
57 |
-- |
58 |
Fabian Groffen |
59 |
Gentoo on a different level |