[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Autoconf protype breaks GCC builtin inlining
From: |
Ferenc Wágner |
Subject: |
Re: Autoconf protype breaks GCC builtin inlining |
Date: |
Thu, 25 Jan 2018 17:47:25 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Zack Weinberg <address@hidden> writes:
> On Wed, Jan 24, 2018 at 6:55 PM, Zack Weinberg <address@hidden> wrote:
>
>> On Wed, Jan 24, 2018 at 4:36 PM, Ferenc Wágner <address@hidden> wrote:
>>
>>> Since ceil() can be inlined when optimization is enabled, I use
>>>
>>> AC_SEARCH_LIBS([ceil], [m], , [AC_MSG_ERROR([ceil not found])])
>>> AC_SUBST([m_LIBS], [$LIBS])
>>>
>>> to link against libm only when necessary (that is, when ceil is not
>>> inlined). However, it does not work because GCC says in config.log:
>>>
>>> conftest.c:76:6: warning: conflicting types for built-in function 'ceil'
>>> char ceil ();
>>> ~~~~
>>>
>>> and inlining is disabled, thus ceil becomes an undefined reference
>>> without -lm. However, in the actual code where math.h is #included, the
>>> above warning does not happen, ceil is inlined and I unnecessarily link
>>> with -lm. How could I overcome this?
>>
>> You could try setting -Wl,--as-needed (which really should be the
>> default) in your makefiles.
>
> That was unnecessarily cryptic, sorry.
Nevermind, it was fine, I met --as-needed before, but I was somewhat
wary about using it for no concrete reason (FUD).
> The GNU linker accepts an option --as-needed
Which brings us to a followup question: how to check whether it's safe
to use --as-needed? Is AX_CHECK_LINK_FLAG sufficient, should I check
for the effect somehow or what else is the best practice here?
> (This is not the default only for silly historical reasons which let's
> not get into here.)
Just out of curiosity, have to got a good link to the topic?
--
Thanks,
Feri