Adding a global define

Adriaan van Os gpc at microbizz.nl
Sat May 2 13:06:14 CEST 2009


Waldek Hebisch wrote:
> Adriaan van Os wrote:
>> I have created a patch that adds a define to include/ansidecl.h. When I build the compiler with the
>> patch, the build hangs as indicated below.
>>
>> My questions are:
>>
>> 1. What's going on ?
>> 2. Is there a configuration file in gcc/p or gcc/p/rts that needs a manual rebuild after the patch ?
>> 3. Is there a recommended way to add a define to the compilation of all files (including libiberty) ?
>>
> 
>> ./xgcc -B./ -B/Developer/Pascal/gpc346u4/i386-apple-darwin10/bin/ -isystem
>> /Developer/Pascal/gpc346u4/i386-apple-darwin10/include -isystem
>> /Developer/Pascal/gpc346u4/i386-apple-darwin10/sys-include
>> -L/Volumes/P300/Users/adriaan/gnu/gpc/gpc346u4/build/gcc/../ld -DIN_GCC    -W -Wall -Wwrite-strings
>> -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -I. -I.
>> -I../../gcc-3.4.6/gcc -I../../gcc-3.4.6/gcc/. -I../../gcc-3.4.6/gcc/../include   \
>> 	  -c ../../gcc-3.4.6/gcc/config/darwin-crt2.c -o crt2.o
>> xgcc: unrecognized option `-isystem'
>> xgcc: unrecognized option `-isystem'
>> xgcc: unrecognized option `-DIN_GCC'
>> xgcc: unrecognized option `-isystem'
>> xgcc: unrecognized option `-I.'
>> xgcc: unrecognized option `-I.'
>> xgcc: unrecognized option `-I../../gcc-3.4.6/gcc'
>> xgcc: unrecognized option `-I../../gcc-3.4.6/gcc/.'
>> xgcc: unrecognized option `-I../../gcc-3.4.6/gcc/../include'
>>
> 
> Looks that you have broken option parser.  I am affraid that without
> seeing that actual patch it is hard to say more.

The Mac OS X headers for /usr/include/string.h and /usr/include/stdio.h forget to check for the GCC 
version when using a feature <http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html> that is 
available in gcc 4.1 or later only.

#if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus)
/* Security checking functions.  */
#include <secure/_stdio.h>
#endif

#if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus)
/* Security checking functions.  */
#include <secure/_string.h>
#endif

So, I were adding

diff -urN gcc-3.4.6-orig/include/ansidecl.h gcc-3.4.6/include/ansidecl.h
--- gcc-3.4.6/include/ansidecl-orig.h	2006-02-06 15:06:55.000000000 +0100
+++ gcc-3.4.6/include/ansidecl.h	2009-05-01 13:31:36.000000000 +0200
@@ -321,4 +321,7 @@
  #define __extension__
  #endif

+/* avoid problems with memset and friends on Mac OS X */
+#define _FORTIFY_SOURCE 0
+
  #endif	/* ansidecl.h	*/

I guess I could instead add a header patch to gcc. Something like:

--- stdio-orig.h    2009-05-02 09:29:48.000000000 +0200
+++ stdio.h    2009-05-02 10:04:41.000000000 +0200
@@ -426,7 +426,7 @@
  #include <xlocale/_stdio.h>
  #endif /* _USE_EXTENDED_LOCALES_ */

-#if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus)
+#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && 
_FORTIFY_SOURCE > 0 && !defined (__cplusplus)
  /* Security checking functions.  */
  #include <secure/_stdio.h>
  #endif

--- string-orig.h    2009-05-02 09:29:55.000000000 +0200
+++ string.h    2009-05-02 10:04:50.000000000 +0200
@@ -143,7 +143,7 @@
  #include <xlocale/_string.h>
  #endif /* _USE_EXTENDED_LOCALES_ */

-#if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus)
+#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && 
_FORTIFY_SOURCE > 0 && !defined (__cplusplus)
  /* Security checking functions.  */
  #include <secure/_string.h>
  #endif

> Concerning adding a global define: have you tried passing modified
> CFLAGS to make?

I already tried, but it didn' work (using gcc-3.4.6) Neither does a configure --with-cppflags=. 
However, a make with CPPFLAGS="-D_FORTIFY_SOURCE=0" does do the job. Still the same problem as 
above, so I think it's unrelated. I will look further.

Regards,

Adriaan van Os






More information about the Gpc mailing list