1 |
2016-06-22 21:54 GMT+08:00 Lei Zhang <zhanglei.april@×××××.com>: |
2 |
> 2016-06-21 12:54 GMT+08:00 Lei Zhang <zhanglei.april@×××××.com>: |
3 |
>> 2016-06-17 20:44 GMT+08:00 Lei Zhang <zhanglei.april@×××××.com>: |
4 |
>>> After putting about eight "#define _GNU_SOURCE"s in various *.cpp |
5 |
>>> files, it seems to work now :) |
6 |
>> |
7 |
>> I was wrong; it doesn't work... I still can't figure out a good solution :( |
8 |
>> |
9 |
>> Take glibc's strtoll_l for example: it's hidden by _GNU_SOURCE in |
10 |
>> stdlib.h and used exclusively by libc++'s header <locale>; but |
11 |
>> defining _GNU_SOURCE in <locale> could be too late, since stdlib.h |
12 |
>> might be included prior to <locale>. |
13 |
>> |
14 |
>> Though glibc's stdlib.h is only explicitly included in <cstdlib>, |
15 |
>> defining _GNU_SOURCE in <cstdlib> doesn't work either. It turns out |
16 |
>> strtoll_l (and others) is not directly protected by _GNU_SOURCE, but |
17 |
>> by __USE_GNU, which is in turn defined in features.h according to |
18 |
>> _GNU_SOURCE. That means "#define _GNU_SOURCE" must appear before the |
19 |
>> inclusion of features.h, and it's not very clear where "#undef |
20 |
>> _GNU_SOURCE" should be put. |
21 |
>> |
22 |
>> Any suggestions? |
23 |
> |
24 |
> So far the only feasible solution I can think of is to wrap every |
25 |
> inclusion of C headers in libc++ with a pair of "#define _GNU_SOURCE" |
26 |
> and "#undef _GNU_SOURCE", thus making sure _GNU_SOURCE is defined |
27 |
> before any implicitly inclusion of features.h. It is cumbersome, but |
28 |
> works. I haven't really figured out if this solution is 100% |
29 |
> error-proof. |
30 |
|
31 |
As an after-thought, I don't this justifies as a *real* solution, as |
32 |
it still exposes nearly all the hidden symbols to user program; it |
33 |
just enables us to compile LLVM against musl... |
34 |
|
35 |
|
36 |
Lei |