Discussion:
gnulib: __builtin_expect()
(too old to reply)
Paul Eggert
2016-12-16 22:58:02 UTC
Permalink
Raw Message
DEPDIR=.deps depmode=aix /bin/sh /u/darkstar/testdir/build-aux/depcomp \
xlc-wrap -DHAVE_CONFIG_H -I. -I/u/darkstar/testdir/gllib -I.. -DGNULIB_STRICT_CHECKING=1 -D_XOPEN_SOURCE=600 -DNSIG=39 -qhaltonmsg=CCN3296 -g -qfloat=ieee -qlanglvl=extc99 -c -o fnmatch.o /u/darkstar/testdir/gllib/fnmatch.c
ERROR CCN3046 /usr/include/builtins.h:1858 Syntax error.
CCN0793(I) Compilation failed for file /u/darkstar/testdir/gllib/fnmatch.c. Object file not created.
make[4]: *** [fnmatch.o] Error 12
As far as I can tell, __builtin_expect() is not a preprocessor symbol on
No, it's a compiler builtin. I installed the attached to gnulib; please give it
a try.
Bruno Haible
2016-12-16 23:26:18 UTC
Permalink
Raw Message
Hi Paul,
I installed the attached to gnulib; please give it a try.
Is it intentional that regex-internal.h now uses __builtin_expect
unconditionally, yet the module 'regex' does not depend on 'builtin-expect'?

Bruno
Paul Eggert
2016-12-17 00:33:01 UTC
Permalink
Raw Message
Post by Bruno Haible
Is it intentional that regex-internal.h now uses __builtin_expect
unconditionally, yet the module 'regex' does not depend on 'builtin-expect'?
No, and thanks for catching that typo. I installed the attached.
Daniel Richard G.
2016-12-16 23:31:55 UTC
Permalink
Raw Message
Post by Paul Eggert
No, it's a compiler builtin. I installed the attached to gnulib;
please give it a try.
Alas, git master 005973d6 gives me a new build failure:

source='/u/darkstar/testdir/gllib/allocator.c' object='allocator.o' libtool=no \
DEPDIR=.deps depmode=aix /bin/sh /u/darkstar/testdir/build-aux/depcomp \
xlc-wrap -DHAVE_CONFIG_H -I. -I/u/darkstar/testdir/gllib -I.. -DGNULIB_STRICT_CHECKING=1 -D_XOPEN_SOURCE=600 -DNSIG=39 -qhaltonmsg=CCN3296 -g -qfloat=ieee -qlanglvl=extc99 -c -o allocator.o /u/darkstar/testdir/gllib/allocator.c
ERROR CCN3046 /usr/include/builtins.h:1858 Syntax error.
CCN0793(I) Compilation failed for file /u/darkstar/testdir/gllib/allocator.c. Object file not created.
make[3]: *** [allocator.o] Error 12

It seems like the configure-time detection of __builtin_expect() failed:

configure:32144: checking for __builtin_expect
configure:32159: xlc-wrap -o conftest -g -qfloat=ieee -qlanglvl=extc99 -D_XOPEN_SOURCE=600 -DNSIG=39 -qhaltonmsg=CCN3296 conftest.c >&5
IEW2456E 9207 SYMBOL __builtin_expect UNRESOLVED. MEMBER COULD NOT BE INCLUDED
FROM THE DESIGNATED CALL LIBRARY.
FSUM3065 The LINKEDIT step ended with return code 8.
configure:32159: $? = 3

Some testing shows that "#include<builtins.h>" is needed in order for
the linkage to work correctly. #include<stdlib.h> also does the trick,
as that header pulls in this one unconditionally.


--Daniel
--
Daniel Richard G. || ***@iSKUNK.ORG
My ASCII-art .sig got a bad case of Times New Roman.
Paul Eggert
2016-12-17 00:55:06 UTC
Permalink
Raw Message
I hadn't thought about the possibility that the standard includes define
__builtin_expect as a macro. I installed the attached; please give it a try.
Daniel Richard G.
2016-12-17 02:02:46 UTC
Permalink
Raw Message
Post by Paul Eggert
I hadn't thought about the possibility that the standard includes
define __builtin_expect as a macro. I installed the attached; please
give it a try.
In git master d1469b79, the configure-time detection now works, but the
build fails later at

DEPDIR=.deps depmode=aix /bin/sh /u/darkstar/testdir/build-aux/depcomp \
xlc-wrap -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I/u/darkstar/testdir/gltests -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I/u/darkstar/testdir/gltests -I.. -I/u/darkstar/testdir/gltests/.. -I../gllib -I/u/darkstar/testdir/gltests/../gllib -D_XOPEN_SOURCE=600 -DNSIG=39 -qhaltonmsg=CCN3296 -g -qfloat=ieee -qlanglvl=extc99 -c -o test-canonicalize-lgpl.o /u/darkstar/testdir/gltests/test-canonicalize-lgpl.c
xlc-wrap -g -qfloat=ieee -qlanglvl=extc99 -o test-canonicalize-lgpl test-canonicalize-lgpl.o libtests.a ../gllib/libgnu.a libtests.a
IEW2456E 9207 SYMBOL __builtin_expect UNRESOLVED. MEMBER COULD NOT BE INCLUDED
FROM THE DESIGNATED CALL LIBRARY.
FSUM3065 The LINKEDIT step ended with return code 8.
make[4]: *** [test-canonicalize-lgpl] Error 3

This appears to be due to lib/strstr.c, which uses __builtin_expect()
without #including stdlib.h. Adding the #include to that file allows the
test program to link.

lib/fnmatch_loop.c is also in the same situation, but that one is not
causing any build failures for me.

As an aside: It's not that the headers #define __builtin_expect as a
macro on this platform, but rather (from builtins.h):

/*__builtin_expect GCC Compatability */
#ifdef __cplusplus
extern "builtin" {
#else
#pragma linkage(__builtin_expect, builtin)
#endif /* cplusplus */
#ifdef _NO_PROTO
long __builtin_expect();
#else
long __builtin_expect(long,long);
#endif
#ifdef __cplusplus
}
#endif

That is, builtins on this platform are handled as functions with a
special sort of linkage.


--Daniel
--
Daniel Richard G. || ***@iSKUNK.ORG
My ASCII-art .sig got a bad case of Times New Roman.
Paul Eggert
2016-12-17 02:24:55 UTC
Permalink
Raw Message
Post by Daniel Richard G.
As an aside: It's not that the headers #define __builtin_expect as a
Thanks. We should address this underyling problem. I installed the attached to
try to work around the problem. I don't want to have to modify lots of programs
to include seemingly-irrelevant headers like stdint.h.
Daniel Richard G.
2016-12-17 17:34:27 UTC
Permalink
Raw Message
Post by Paul Eggert
Thanks. We should address this underyling problem. I installed the
attached to try to work around the problem. I don't want to have to
modify lots of programs to include seemingly-irrelevant headers like
stdint.h.
Good call, and I'm happy to report that your changes have resolved the
issue in git master ff41dd1f. Thank you for the fix!


--Daniel
--
Daniel Richard G. || ***@iSKUNK.ORG
My ASCII-art .sig got a bad case of Times New Roman.
Loading...