1 |
Hi Fabian, |
2 |
|
3 |
On Tue, Dec 26, 2017 at 11:36:52AM +0100, Fabian Groffen wrote: |
4 |
|
5 |
> > After upgrading to macOS 10.13, a couple of packages stopped compiling |
6 |
> > with clang 3.9.1. The errors came from system headers. It looked like |
7 |
> > Apple had again used some funky new clang feature in them which 3.9.1 |
8 |
> > didn't support. |
9 |
> Yes, I noticed that too, see: |
10 |
> https://bugs.gentoo.org/632500 |
11 |
|
12 |
Ah, right, totally forgot about bison: I grabbed the workaround from |
13 |
Homebrew some time back |
14 |
(https://github.com/Homebrew/homebrew-core/issues/18591). |
15 |
|
16 |
> > Getting clang-5 up and running wasn't all that bad: I needed to clone |
17 |
> > the libcxx and libcxxabi ebuilds for version 5.0.1, adjust eclass |
18 |
> > cmake-utils and reintroduce some prefix provisions to clang and |
19 |
> > compiler-rt ebuilds that didn't make the move from the llvm ebuild. |
20 |
> Oh, I experienced failures to compile it on a 10.13 profile. |
21 |
|
22 |
Considering that the only real difference I can see between profiles is |
23 |
the MACOS_DEPLOYMENT_TARGET, it might have been the rpath problem. It |
24 |
failed to compile for me too until I removed |
25 |
CMAKE_BUILD_WITH_INSTALL_RPATH from the cmake config. This indication is |
26 |
that some binary (most likely llvm-tblgen) is called from the build |
27 |
directory and croaks on the old LLVM libs it loads from EPREFIX/usr/lib |
28 |
with missing symbols. |
29 |
|
30 |
> > Does anyone remember why CMAKE_BUILD_WITH_INSTALL_RPATH was necessary |
31 |
> > for cmake ebuilds? |
32 |
> I don't recall, seems like this indeed shouldn't be forced. |
33 |
|
34 |
I'll just go ahead and drop it from cmake-utils.eclass completely and |
35 |
see what breaks. |
36 |
|
37 |
> > @rpath. So I had to force an *install* rpath of |
38 |
> > ${EPREFIX}/usr/lib/llvm/${SLOT}/lib. |
39 |
> I assume this is install_name_tool-ing. |
40 |
|
41 |
Well, in a way: The libraries' ids get to be @rpath/<lib> as well. This |
42 |
way, when linking into a binary, they don't bring the path to themselves |
43 |
with them any more. The benefit is that an LLVM/clang installation can |
44 |
be fully relocatable. The drawback is, that you need to muck around with |
45 |
DYLD_{,FALLBACK_}LIBRARY_PATH, link every binary that links against |
46 |
them with an rpath where they're on or compile a static rpath into them |
47 |
as I did. The latter still doesn't propagate into a binary that links |
48 |
against them. So you can dlopen() them and they'll find their |
49 |
dependencies. But linking against them still requires putting an rpath |
50 |
into the binary they're linked into. It's all somewhat sad. |
51 |
|
52 |
I now realize that this might have been exactly the intention of the |
53 |
cmake settings, especially CMAKE_INSTALL_NAME_DIR. But a.) we'd need to |
54 |
adjust that for the llvm slot directory and b.) we'd need to disable it |
55 |
for the build directory. |
56 |
|
57 |
BTW: AFAIK all this isn't done using install_name_tool but directly when |
58 |
linking the binaries. According to |
59 |
https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.html, |
60 |
cmake normally links libs and executables twice: Once upon build with a |
61 |
additions to rpath that make them consistently use the newly compiled |
62 |
libraries in the build tree and then again upon install with the actual |
63 |
install rpath. This would also change the library id (install name). |
64 |
|
65 |
Here's what it looks like on my system right now: |
66 |
|
67 |
# otool -D EPREFIX/usr/lib/llvm/5/lib/libLLVMSupport.dylib |
68 |
EPREFIX/usr/lib/llvm/5/lib/libLLVMSupport.dylib: |
69 |
@rpath/libLLVMSupport.dylib |
70 |
# otool -L EPREFIX/usr/lib/llvm/5/lib/libLLVMSupport.dylib |
71 |
EPREFIX/usr/lib/llvm/5/lib/libLLVMSupport.dylib: |
72 |
@rpath/libLLVMSupport.dylib (compatibility version 0.0.0, current version 0.0.0) |
73 |
EPREFIX/usr/lib/libncurses.6.dylib (compatibility version 6.0.0, current version 6.0.0) |
74 |
EPREFIX/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11) |
75 |
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0) |
76 |
@rpath/libLLVMDemangle.dylib (compatibility version 0.0.0, current version 0.0.0) |
77 |
EPREFIX/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0) |
78 |
# otool -l EPREFIX/usr/lib/llvm/5/lib/libLLVMSupport.dylib |
79 |
EPREFIX/usr/lib/llvm/5/lib/libLLVMSupport.dylib: |
80 |
[...] |
81 |
Load command 3 |
82 |
cmd LC_ID_DYLIB |
83 |
cmdsize 56 |
84 |
name @rpath/libLLVMSupport.dylib (offset 24) |
85 |
Load command 12 |
86 |
cmd LC_LOAD_DYLIB |
87 |
cmdsize 56 |
88 |
name /usr/lib/libSystem.B.dylib (offset 24) |
89 |
time stamp 2 Thu Jan 1 01:00:02 1970 |
90 |
current version 1252.0.0 |
91 |
compatibility version 1.0.0 |
92 |
Load command 13 |
93 |
cmd LC_LOAD_DYLIB |
94 |
cmdsize 56 |
95 |
name @rpath/libLLVMDemangle.dylib (offset 24) |
96 |
time stamp 2 Thu Jan 1 01:00:02 1970 |
97 |
current version 0.0.0 |
98 |
compatibility version 0.0.0 |
99 |
Load command 14 |
100 |
cmd LC_LOAD_DYLIB |
101 |
cmdsize 72 |
102 |
name EPREFIX/usr/lib/libc++.1.dylib (offset 24) |
103 |
[...] |
104 |
Load command 16 |
105 |
cmd LC_DATA_IN_CODE |
106 |
cmdsize 16 |
107 |
dataoff 1040248 |
108 |
datasize 440 |
109 |
Load command 17 |
110 |
cmd LC_RPATH |
111 |
cmdsize 56 |
112 |
path EPREFIX/usr/lib/llvm/5/lib (offset 12) |
113 |
^ by default this is @loader_path/../lib or @executable_path/../lib |
114 |
|
115 |
> > As long as neither USE tapi nor lto are enabled on binutils-apple, they |
116 |
> > should be fine. Symlinks to size and nm will break and will need |
117 |
> > adjustment to point to the new llvm install though. |
118 |
> Hmm... |
119 |
|
120 |
I've put the current version of the updated ebuild into a new bug |
121 |
#642292. Rationale for the changes are somewhat scattered in the bug |
122 |
comments, ebuild, patch headers and comments in the patches. Let me know |
123 |
if you'd like me to collect them in one place. :) |
124 |
|
125 |
The main change is that I added a function and a shim binary to cctools |
126 |
that goes looking for llvm tools and libs in the slot directories for |
127 |
major versions 10 to 4 and EPREFIX/usr/bin directly. Since cctools |
128 |
dlopen libLTO and exec() the tools, that should make them very robust |
129 |
against updates. |
130 |
|
131 |
ld64 is another story because it directly links against libLTO. If only |
132 |
libLTO had a proper version number, portage could help by preserving it |
133 |
on update. As of now, only the different slot paths of llvm major |
134 |
versions might provide some protection against breakage. |
135 |
|
136 |
> > Any comments on my approach would be highly appreciated. Patches |
137 |
> > attached for documentation. |
138 |
> Seems like you got yourself pretty deep into it! clang-5 is the blocker |
139 |
> for supporting high sierra IMO. Can you now build 5 using 3.9.1? |
140 |
|
141 |
I have indeed successfully built llvm and clang 5.0.1 using 3.9.1 with |
142 |
the above changes in my existing prefix. I am now trying to get all |
143 |
packages updated to the current portage tree, switch profile and CHOST |
144 |
to 10.13 and recompile the whole thing again. This will tell, if it's |
145 |
self-hosting. After that I can try downgrading llvm/clang and upgrading |
146 |
it again to see what breaks. |
147 |
|
148 |
> I think the cmake patches are ok, I'll look into the ebuilds you |
149 |
> mention. I'll sync whatever I can find in this area. |
150 |
|
151 |
Actually, the cmake patch might be incorrect since it got lost on emaint |
152 |
sync and I had to reconstruct it from memory. I'm sure about |
153 |
CMAKE_BUILD_WITH_INSTALL_RPATH, CMAKE_INSTALL_RPATH, |
154 |
CMAKE_INSTALL_RPATH_USE_LINK_PATH but I think I also dropped |
155 |
CMAKE_INSTALL_NAME_DIR for llvm and clang. |
156 |
-- |
157 |
bye, Michael |