Bug 18010 - Cairo requires -DREENTRANT (along with -D_POSIX_THREAD_SEMANTICS) to compile on Solaris 10 with pthreads
Summary: Cairo requires -DREENTRANT (along with -D_POSIX_THREAD_SEMANTICS) to compile ...
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.8.0
Hardware: Other All
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-10 14:12 UTC by Michael
Modified: 2008-10-14 14:54 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Define _POSIX_C_SOURCE (1.27 KB, patch)
2008-10-10 14:32 UTC, Chris Wilson
Details | Splinter Review

Description Michael 2008-10-10 14:12:16 UTC
Compilation of the Cairo test suite (with pthreads enabled) fails at cairo_test.c:

 gcc -DHAVE_CONFIG_H -I. -I.. -I. -I./pdiff -I../boilerplate -I../src -I../src -I/usr/local/include/pixman-1 -I/usr/local/include/freetype2 -I/usr/local/include -I/usr/local/include -I/usr/local/include/libpng12 -I/usr/local/include -Wall -Wextra -Wsign-compare -Werror-implicit-function-declaration -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wpacked -Wswitch-enum -Wmissing-format-attribute -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations -Wdeclaration-after-statement -Wold-style-definition -Wno-missing-field-initializers -Wno-unused-parameter -Wno-attributes -Wno-long-long -Winline -fno-strict-aliasing -Wp,-D_FORTIFY_SOURCE=2 -I/usr/openwin/include -g -O2 -D_POSIX_PTHREAD_SEMANTICS -MT cairo-test.lo -MD -MP -MF .deps/cairo-test.Tpo -c cairo-test.c  -fPIC -DPIC -o .libs/cairo-test.o
cairo-test.c: In function 'cairo_test_run':
cairo-test.c:1060: error: implicit declaration of function 'flockfile'
cairo-test.c:1060: warning: nested extern declaration of 'flockfile'
cairo-test.c:1091: error: implicit declaration of function 'funlockfile'
cairo-test.c:1091: warning: nested extern declaration of 'funlockfile'
make[5]: *** [cairo-test.lo] Error 1
make[5]: Target `imagediff' not remade because of errors.
gcc -DHAVE_CONFIG_H -I. -I..  -I. -I./pdiff -I../boilerplate -I../src -I../src -I/usr/local/include/pixman-1      -I/usr/local/include/freetype2 -I/usr/local/include   -I/usr/local/include   -I/usr/local/include/libpng12   -I/usr/local/include      -Wall -Wextra -Wsign-compare -Werror-implicit-function-declaration -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wpacked -Wswitch-enum -Wmissing-format-attribute -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations -Wdeclaration-after-statement -Wold-style-definition -Wno-missing-field-initializers -Wno-unused-parameter -Wno-attributes -Wno-long-long -Winline -fno-strict-aliasing -Wp,-D_FORTIFY_SOURCE=2          -I/usr/openwin/include    -g -O2 -D_POSIX_PTHREAD_SEMANTICS -MT png-flatten.o -MD -MP -MF .deps/png-flatten.Tpo -c -o png-flatten.o png-flatten.c
mv -f .deps/png-flatten.Tpo .deps/png-flatten.Po
make[5]: Target `png-flatten' not remade because of errors.
make[5]: Leaving directory `/tmp/cairo-1.8.0/test'
make[4]: *** [check-am] Error 2
make[4]: Leaving directory `/tmp/cairo-1.8.0/test'
make[3]: *** [check-recursive] Error 1
make[3]: Leaving directory `/tmp/cairo-1.8.0/test'
make[2]: *** [check] Error 2
make[2]: Leaving directory `/tmp/cairo-1.8.0/test'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/tmp/cairo-1.8.0'
make: *** [check] Error 2


The missing definitions of flockfile and funlockfile are protected in /usr/include/stdio.h with the following conditions:

#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
        (_POSIX_C_SOURCE - 0 >= 199506L)


Adding -D_REENTRANT to the CFLAGS permits this to build.  I do not know if this change will work on earlier versions of Solaris, nor do I know if it will work on any version of Solaris x86.

The test suite, however, still gives a large number of failures, which I am still investigating.
Comment 1 Chris Wilson 2008-10-10 14:23:00 UTC
Whats the reason for -D_POSIX_THREAD_SEMANTICS? Also I guess -D_POSIX_C_SOURCE would be a better define for flockfile (plus apparently the feature check should be based on _POSIX_THREAD_SAFE_FUNCTIONS).
Comment 2 Michael 2008-10-10 14:25:50 UTC
My understanding is that Solaris, by default on seeing -D_REENTRANT, uses Solaris threads.  -D_POSIX_PTHREAD_SEMANTICS tells it to use PThreads instead.
Comment 3 Chris Wilson 2008-10-10 14:32:29 UTC
Created attachment 19580 [details] [review]
Define _POSIX_C_SOURCE

Can you try this patch to see if addresses the (build) issue?
Comment 4 Chris Wilson 2008-10-13 16:00:51 UTC
FYI, I've pushed the #define _POSIX_C_SOURCE patch to 1.8, from which we want to make a 1.8.2 release soon. I'd be grateful if you can either try the attached patch or build from git and verify whether that patch alone is sufficient. Thank you.
Comment 5 Michael 2008-10-14 14:40:36 UTC
The patch worked: both Cairo and the test suite built without further modification.  I applied the patch rather than build from git.
Comment 6 Chris Wilson 2008-10-14 14:54:42 UTC
Cheers for confirming that we don't yet need REENTRANT - I'm trying to keep the number of random defines to a minimum ;-)

Please send the summary and some examples of the test suite failures to the mailing list - we'll help identify if you have any critical failures. Certainly most developers do not have access to Solaris, so it'll be useful for us to look at typical output on that platform. And hopefully it'll encourage a few more people to report their failures/successes.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.