[x264-devel] configure: test for log2f fails, external reference folded out

BugMaster BugMaster at narod.ru
Mon Oct 15 20:55:45 CEST 2018


On Wed, 10 Oct 2018 12:16:22 +0100, Dirk Fieldhouse wrote:
> I'm building the 8 October stable version on a MIPS Broadcom 7405 SoC
> platform with gcc-4.5.2 and uClibc-0.9.29.

> The test at configure l1070 for support of log2f() in libm
> (here:<http://git.videolan.org/?p=x264.git;a=blob;f=configure;h=07ba4490f4be6699549c8ac2f2745a0512ccea77;hb=HEAD#l1070>)
> succeeds incorrectly.

> The program fragment used by configure's cc_check call is

> #include <math.h>

> int main(void) {

> log2f(2);

> return 0;
> }

> gcc 4.5.2 folds the constant expression log2f(2) leaving no external
> reference to log2f. It even does this with no optimisation set.
> Consequently the build defines HAVE_LOG2F to 1 when in fact there is no
> log2f() in the libm provided by this version of uClibc.

> Whereas this reference survives:

> #include <math.h>

> int main(void) {

> float x = 2; x = log2f(x);

> return 0;
> }

> I suppose that even this is not guaranteed by the C standard(s) to
> survive compile-time evaluation, but it beats this version of gcc.

> To implement this, replace configure l1070 by this line

> if cc_check 'math.h' '' 'float x = 2; x = log2f(x);' ; then

> I'm not subscribed to the list at the moment so please CC: me as well.

> thx
> /df

Hi.

So log2f exists at compile time for constant evolution but not at
runtime for variables? It is weird system/environment. Or is this only
due use of uClibc instead of glibc (and gcc still use glibc during
constant evolution)?

Anyway for even more obstacle to compiler to optimize it out we can
also add volatile to variable declaration.

Check that it works as expected with attached patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-configure-Fix-log2f-support-check-at-some-systems.patch
Type: application/octet-stream
Size: 658 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20181015/fe134a05/attachment.obj>


More information about the x264-devel mailing list