From: Christopher Larson <chris_lar...@mentor.com>

When cross-compiling from a host which defines _FORTIFY_SOURCE by default, the
build fails when linking mkbuiltins, due to an inability to find the xread and
xopen symbols. This occurs because the __STRING macro in stdc.h overwrites the
macro from unistd.h, and when HAVE_STRINGIZE isn't set (as is the case when
compiling mkbuiltins.c with -DCROSS_COMPILING), the overwritten macro returns
'x', resulting in a concatenation of the function names, rather than an
assembly level rename of the function being called as was intended.

Either we can add HAVE_STRINGIZE to mkbuiltins.c, assuming that all hosts we
build on support stringize (but in that case, we might as well remove __STRING
from stdc.h entirely, giving up on supporting non-stringize-capable
compilers), or do this: don't define __STRING at all when _FORTIFY_SOURCE is
defined.

Signed-off-by: Christopher Larson <chris_lar...@mentor.com>
---
 include/stdc.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/stdc.h b/include/stdc.h
index df01d81..4375918 100644
--- a/include/stdc.h
+++ b/include/stdc.h
@@ -36,10 +36,12 @@
 #  endif
 #endif
 
-#if defined (HAVE_STRINGIZE)
-#  define __STRING(x) #x
-#else
-#  define __STRING(x) "x"
+#if !defined (_FORTIFY_SOURCE)
+#  if defined (HAVE_STRINGIZE)
+#    define __STRING(x) #x
+#  else
+#    define __STRING(x) "x"
+#  endif
 #endif
 
 #if !defined (__STDC__)
-- 
1.7.12.4


Reply via email to