Gentoo Archives: gentoo-alt

From: Fabian Groffen <grobian@g.o>
To: gentoo-alt@l.g.o
Subject: Re: [gentoo-alt] clang on Mac OS X (Was: Question before setting up sage-on-gentoo)
Date: Sat, 31 Jan 2015 15:58:06
Message-Id: 20150131155755.GC584@gentoo.org
In Reply to: Re: [gentoo-alt] clang on Mac OS X (Was: Question before setting up sage-on-gentoo) by Michael Weiser
1 Very nice writeup! some comments inline
2
3 On 31-01-2015 15:52:52 +0100, Michael Weiser wrote:
4 > Unfortunately that merge will almost certainly fail at the very last
5 > minute because of invalid install names in some iphone simulator runtime
6 > library. So either merge with FEATURE="allow_broken_install_names" or
7 > make an overlay with the llvm ebuilds in it and patch them with the
8 > patch from this bug:
9 >
10 > https://bugs.gentoo.org/show_bug.cgi?id=536716
11
12 I'll see to applying this one, looks like you fixed some bugs there.
13
14 > There is another bug however that provides somewhat preliminary/hackish
15 > ebuilds for libc++abi and libc++ for Darwin:
16 >
17 > https://bugs.gentoo.org/show_bug.cgi?id=474748
18 > https://bugs.gentoo.org/attachment.cgi?id=394024
19
20 I'll try and see if I can add these. I'd love to get into a state where
21 we can bootstrap into a fully self-providing clang.
22
23 > Note how clang++ -stdlib=libc++ is now used to compile ld64 and how ld
24 > -v reports LTO support (unfortunately not when called via the
25 > binutils-config wrapper but when called directly):
26
27 I'll try to tackle this, I guess it's because we insist on adding
28 command line arguments even through you do nothing.
29
30 > Finally it croaked on linking cctools stuff:
31 >
32 > undef: _prune_trie
33 > Undefined symbols for architecture x86_64:
34 > "_prune_trie", referenced from:
35 > _strip_symtab in strip.private.o
36 > ld: symbol(s) not found for architecture x86_64
37 >
38 > Most likely the -flto was missing when compiling some file. So there's
39 > definitely some work to be done there.
40
41 Ok. Recently I saw a problem like this with Apple's Clang which was
42 caused by the respective functions declared inline (e.g. bug). But I
43 guess this is a different issue.
44
45 > 1. portage currently masks OS X 10.10 as 10.9 because
46 > gcc-apple-4.2.1_p5666-r2 can't currently cope with 10.10. This will
47 > influence clang as well. All the stuff you compile will default to
48 > deployment target 10.9 unless you explicitly override that using a
49 > command line option to clang.
50 >
51 > There is a patch in a bug that lifts that limitation:
52 > https://bugs.gentoo.org/show_bug.cgi?id=537826. With that in place in
53 > the gcc ebuild and recompiled gcc you can override
54
55 I'll apply this and lift the awkward limitation.
56
57 > 2. As far as I was able to discern, clang/llvm are configured and
58 > patched to use -I$EPREFIX/usr/include and -L$EPREFIX/usr/lib by default.
59 > And it does work. But clang silently falls back to the system
60 > directories if for whatever reason it does not look there or is unhappy
61 > with what it finds or does not find there. So check your compiles from
62 > time to time to see if they're really using the headers and libraries
63 > you expect them to use.
64
65 Hmmm, this is bad :(
66
67 > 3. I've just recently noticed that clang++ *always* uses the system's
68 > libstdc++ because it just doesn't look for it anywhere else. I am looking
69 > into this and plan to write a patch for it. Obviously that's a
70 > no-brainer if you use libc++ anyway.
71
72 This is even worse :(
73
74 > 4. If you would like to try cross-compiling to arm, then you're in
75 > totally uncharted territories. There is however a patch to the
76 > binutils-config ebuild that at least makes clang produce binaries at
77 > all: https://bugs.gentoo.org/show_bug.cgi?id=537684.
78
79 I'll add this to my todo list for today, need to patch it anyway for the
80 -v above.
81
82 > 5. llvm/clang silently uses the Xcode tools and SDKs to compile its
83 > runtime libraries. The patch from this bug forces it to use itself (the
84 > compiler it has just compiled and is about to install) to compile
85 > those runtimes: https://bugs.gentoo.org/show_bug.cgi?id=537342. This
86 > disables compliation of all the stuff for ios, however.
87
88 Great! another one for the todo list.
89
90 > That's almost always due to the fact that Apple has started using clang
91 > extensions *in the system headers* and does not test it against other
92 > compilers any more. So while they have basic support for disabling those
93 > extensions e.g. in /usr/include/os/base.h they do not use them
94 > consistently.
95 >
96 > Those are __has_extension and __has_feature. There are two ways to deal
97 > with those:
98 >
99 > 1. First check if the include of the offending heder is needed at all. I
100 > was able to make at least two packages work again by just removing a
101 > senseless include that was pulling in one of those __has_features.
102
103 I'm affraid this is a solution that works only in a very few cases.
104
105 > 2. Define them to nothing as explained here:
106 > http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
107
108 I remember doing this for some package. I wonder if we shouldn't do
109 something with gcc's fixincludes to make this work for GCC by default.
110 I do feel gcc may be a dead-end for Mac OS X, but FSF-gcc may always be
111 nice to have from a development perspective.
112
113 Fabian
114
115 --
116 Fabian Groffen
117 Gentoo on a different level

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-alt] clang on Mac OS X (Was: Question before setting up sage-on-gentoo) Michael Weiser <michael@×××××××××××××××.net>