This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] binutils/nm.c: Skip sbrk() under Darwin when _POSIX_C_SOURCE not defined
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: Tristan Gingold <gingold at adacore dot com>
- Cc: amodra at gmail dot com, binutils at sourceware dot org, markus at trippelsdorf dot de, nickc at redhat dot com
- Date: Tue, 16 Sep 2014 10:00:13 +0800
- Subject: Re: [PATCH] binutils/nm.c: Skip sbrk() under Darwin when _POSIX_C_SOURCE not defined
- Authentication-results: sourceware.org; auth=none
- References: <5416E7A2 dot 7070602 at gmail dot com> <D5E1619B-77A8-4782-87B1-BDF34E3DF55D at adacore dot com> <5416EA1F dot 6000508 at gmail dot com> <48DF742F-6FAF-42A3-8CD3-E7CAFC841852 at adacore dot com>
On 9/15/14 21:54, Tristan Gingold wrote:
>
> On 15 Sep 2014, at 15:31, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
>> On 9/15/14 21:21, Tristan Gingold wrote:
>>> Hello,
>>>
>>> On 15 Sep 2014, at 15:20, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
>>> [...]
>>>> --- a/binutils/nm.c
>>>> +++ b/binutils/nm.c
>>>> @@ -1698,6 +1698,7 @@ main (int argc, char **argv)
>>>> END_PROGRESS (program_name);
>>>>
>>>> #ifdef HAVE_SBRK
>>>> +#if !defined (__DARWIN_C_LEVEL) || defined (_POSIX_C_SOURCE)
>>>> if (show_stats)
>>>> {
>>>> char *lim = (char *) sbrk (0);
>>>> @@ -1705,6 +1706,7 @@ main (int argc, char **argv)
>>>> non_fatal (_("data size %ld"), (long) (lim - (char *) &environ));
>>>> }
>>>> #endif
>>>> +#endif
>>>
>>> Enable code on machine specific macro is not recommended by the GNU standard.
>>> Also note that sbrk is also used by gas.
>>>
>>> Maybe the test of sbrk in configure should be done using warnings flags.
>>>
>>> (the work-around is to configure using --disable-werror).
>>>
>>
>> Originally, I really tried to do that, but I found that HAVE_SBRK really
>> need be true under Darwin, but may report warning.
>
> Can you clarify that ? IIRC, the only use of sbrk within binutils is to
> compute the amount of memory used.
>
Yeah, in "binutils/binutils", what you said is reasonable to me.
But in "bintuils" (include as, ld, gdb ...), most of sub-systems content
"HAVE_SBRK", and some of them not enable 'Werror'.
Originally I tried "binutils/binutils" in "binutils/binutils/configure"
(but not send patch). But after I thought of again, for me:
- 'HAVE_SBRK' express whether have sbrk(), do not care about warnings.
- Multiple sub-systems use 'HAVE_SBRK', some can bare the warnings.
- If the sub-systems can not bare warnings, it needs additional trying
(e.g binutils/binutils), and still keep the standard checking for
'HAVE_SBRK' in related configure.
Thanks.
--
Chen Gang
Open, share, and attitude like air, water, and life which God blessed