Gentoo Archives: gentoo-musl

From: Lei Zhang <zhanglei.april@×××××.com>
To: Luca Barbato <lu_zero@g.o>
Cc: gentoo-musl@l.g.o
Subject: Re: [gentoo-musl] [GSoC] _GNU_SOURCE in C++
Date: Fri, 17 Jun 2016 12:44:08
Message-Id: CAOYuCc3EPZcw6xy_gbcuTEsgyjn=ttBqmwKjtW-qrNmYw91usA@mail.gmail.com
1 2016-06-17 19:25 GMT+08:00 Luca Barbato <lu_zero@g.o>:
2 > On 17/06/16 13:12, Lei Zhang wrote:
3 >> 2016-06-16 21:42 GMT+08:00 Lei Zhang <zhanglei.april@×××××.com>:
4 >>> 2016-06-16 21:13 GMT+08:00 Luca Barbato <lu_zero@g.o>:
5 >>>> On 16/06/16 14:47, Lei Zhang wrote:
6 >>>>> 2016-06-16 17:43 GMT+08:00 Luca Barbato <lu_zero@g.o>:
7 >>>>>> On 16/06/16 05:36, Lei Zhang wrote:
8 >>>>>>> Attached is what I've got so far.
9 >>>>>>>
10 >>>>>>> Some of them are not documented in man pages, so I checked their
11 >>>>>>> declarations in musl's headers. Functions strtold_l, strtoll_l and
12 >>>>>>> strtoull_l are not available in musl, but libc++ is smart enough to
13 >>>>>>> not use them when linked against musl.
14 >>>>>
15 >>>>> I made a mistake. Actually strtold_l *is* available in musl, but
16 >>>>> hidden by _GNU_SOURCE.
17 >>>>
18 >>>> Not hidden by _BSD_SOURCE as well?
19 >>>
20 >>> No, only by _GNU_SOURCE.
21 >>>
22 >>>>>> beside vasprintf, the rest is covered by _XOPEN_SOURCE 700
23 >>>>>>
24 >>>>>> Might be worth trying to do -U_GNU_SOURCES -D_XOPEN_SOURCE=700 and see
25 >>>>>> how it goes.
26 >>>>>
27 >>>>> So far vasprintf and strtold_l are not covered. vasprintf can be
28 >>>>> covered with -D_BSD_SOURCE. But _BSD_SOURCE is deprecated since glibc
29 >>>>> 2.20; I don't know if this has any impact on musl.
30 >>>>
31 >>>> It should not and -D_BSD_SOURCE should be fine for musl.
32 >>>
33 >>> I just found that vasprintf is only protected by _GNU_SOURCE in glibc,
34 >>> which means in this case _BSD_SOURCE only works for musl.
35 >>>
36 >>>>>> How vasprintf is used?
37 >>>>>
38 >>>>> It's used by <locale>. The code is kinda hard to read; I can't tell
39 >>>>> exactly what it's doing...
40 >>>>
41 >>>> same for the _l variants I guess.
42 >>>
43 >>> So what now? So far strtold_l still needs _GNU_SOURCE in musl;
44 >>> strtold_l, strtoll_l, strtoull_l and vasprintf all need _GNU_SOURCE in
45 >>> glibc.
46 >>
47 >> To sum it up:
48 >>
49 >> * As for musl, "-U_GNU_SOURCES -U_GNU_SOURCES=700 -D_BSD_SOURCE"
50 >> covers every symbol needed by libc++ except for strtold_l.
51 >>
52 >> * As for glibc, "-U_GNU_SOURCE -D_ISOC11_SOURCE -D_DEFAULT_SOURCE"
53 >> covers everything except for strtold_l, strtoll_l, strtoull_l and
54 >> vasprintf.
55 >
56 >
57 > Sounds almost good, now some configure/cmake patches to put that in and
58 > some #define _GNU_SOURCES /#undef in selected places might get it
59 > working completely...
60
61 After putting about eight "#define _GNU_SOURCE"s in various *.cpp
62 files, it seems to work now :)
63
64 I'll see if I can reduce the number of "#define"s needed.
65
66 Lei

Replies

Subject Author
Re: [gentoo-musl] [GSoC] _GNU_SOURCE in C++ Lei Zhang <zhanglei.april@×××××.com>