Bug0032
- Description
- Build error in sgzlib.c
When trying to compile pyflag-0.84RC2 with gcc-4.1.2-12, I receive the following error:
make[3]: Entering directory `/home/lmacken/rpmbuild/BUILD/pyflag-0.84RC2/src/lib/libsgzip'
if /bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I../../../src/include -I../../../src/include -include config.h -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -MT sgzlib.lo -MD -MP -MF ".deps/sgzlib.Tpo" -c -o sgzlib.lo sgzlib.c; \
then mv -f ".deps/sgzlib.Tpo" ".deps/sgzlib.Plo"; else rm -f ".deps/sgzlib.Tpo"; exit 1; fi
gcc -DHAVE_CONFIG_H -I. -I. -I../../../src/include -I../../../src/include -include config.h -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -MT sgzlib.lo -MD -MP -MF .deps/sgzlib.Tpo -c sgzlib.c -fPIC -DPIC -o .libs/sgzlib.o
sgzlib.c:298:53: error: macro "memcpy" requires 3 arguments, but only 2 given
sgzlib.c: In function 'SgzipFile_CreateFile':
sgzlib.c:298: warning: statement with no effect
sgzlib.c:299:60: error: macro "memcpy" requires 3 arguments, but only 2 given
sgzlib.c:299: warning: statement with no effect
make[3]: *** [sgzlib.lo] Error 1
- Logged
- 2007-05-19
- Logged By
- Assigned to
- Status
- Closed
Get back to the BugIndex
This is interesting. It seems that Fedora turns on the FORTIFY_SOURCE flag which causes all calls to memcpy to be expanded through a macro into a version which checks the size of the buffer etc. This breaks because we define ZSTRING() as another macro which expands its arg into a length as well.
So for example doing a memcmp(a, ZSTRING("hello")) should expand to memcmp(a, "hello", strlen("hello")) which is more convenient but will apparently break if the FORTIFY SOURCE option is enabled. You can just make it compile by:
- Changing the ZSTRING by hand in that file (that seems to be the only file affected)
- Added a #undef FORTIFY_SOURCE to the top of that file.
- Pulling the latest darcs version (which will become RC3 shortly).
I defined a bunch of more macros specifically designed to avoid this issue from now on. This is still a pain because strcmp and strcpy must be treated specially. These are done in misc.h. I tried to compile it with FORTIFY_SOURCE here and it worked.
Thanks for the bug report... Luke. I am closing this bug because it appears to be fixed. Please reopen it if there are more issues.
