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: Wed, 15 Jun 2016 01:45:25
Message-Id: CAOYuCc3ZyA0SS1EUpVMGYmNrTUSX3k69d4Jz7dz2iYW1fQkF_A@mail.gmail.com
1 This issue is probably not as simple as I thought. Supposing C++
2 header iostream depends on some non-standard functions from stdio.h,
3 it may look like:
4
5 // iostream
6 #define _BSD_SOURCE
7 #include <stdio.h>
8 #undef _BSD_SOURCE
9 ...
10
11 But if a user writes some code like:
12
13 // user code
14 #include <stdio.h>
15 #include <iostream> // stdio.h already expanded before this point
16 ...
17
18 then iostream never has the chance to get those non-standard symbols,
19 *unless* the compiler predefines _BSD_SOURCE for it. So simply
20 patching libc++/libstdc++ doesn't work; you have to carefully choose
21 which visibility macros to predefine in the compiler. And predefining
22 _GNU_SOURCE is just the safest bet.
23
24 I don't see any easy fix for this at the moment :(
25
26
27 Lei
28
29 2016-06-14 20:03 GMT+08:00 Luca Barbato <lu_zero@g.o>:
30 > On 14/06/16 13:48, Lei Zhang wrote:
31 >> 2016-06-14 19:18 GMT+08:00 Luca Barbato <lu_zero@g.o>:
32 >>> On 14/06/16 11:35, Lei Zhang wrote:
33 >>>> I agree. It seems libstdc++ is also taking the lazy route, and someone
34 >>>> intended to fix it:
35 >>>>
36 >>>> https://lwn.net/Articles/590504/
37 >>>>
38 >>>> but I see no progress so far.
39 >>>>
40 >>>
41 >>> make -k and let's try to extract the list of missing symbols from it.
42 >>
43 >> A quick test with libc++:
44 >>
45 >> aligned_alloc
46 >
47 > aligned_alloc(): _ISOC11_SOURCE
48 >
49 >> atoll
50 >
51 > atoll():
52 > _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
53 > _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
54 >
55 >> _Exit
56 >
57 > _Exit():
58 > _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >=
59 > 200112L;
60 >
61 >> fwide
62 >
63 > fwide():
64 > _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE ||
65 > _POSIX_C_SOURCE >= 200112L;
66 >
67 > etc etc etc
68 >
69 > try to figure out which defines correctly enable those and send patches
70 > to be precise =)
71 >
72 > lu
73 >
74 >
75 >