This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

3.[234] PATCH: Fix Tru64 UNIX V5.1B bootstrap failure


This patch fixes the Tru64 UNIX V5.1B bootstrap failure reported by Olle
and fixes two other PRs related to the support for #pragma extern_prefix
introduced for GCC 3.1: starting from that release, in addition to support
for the pragma, gcc predefines __EXTERN_PREFIX.  Unfortunately, unlike
__PRAGMA_REDEFINE_EXTNAME used by the Solaris 2 system headers to detect
support for their similar #pragma redefine_extname, this __EXTERN_PREFIX
macro is not a general feature test macro used to detect whether the
compiler used supports the pragma, but only used in <sys/stat.h> to detect
the pragma.

The V5.1B bootstrap failure reported in PR other/9671 can be observed with
the following trivial example:

#include <sys/types.h>
#include <sys/stat.h>

int
main (void)
{
  struct stat st;

  stat ("/", &st);
  return (0);
}

which, when linked, results in an unresolved reference to _F64__F64_stat.

The V5.1B <sys/stat.h> has this code section (condensed for clarity):

#   if defined(__DECC)
#     define __EXTERN_PREFIX	/* rename via #pragma extern_prefix "_F64_" */
#   else  /* ! __DECC */
#       define __F64_USE_JACKET __inline__ static
#       undef  __STAT__
#       define __STAT__  _F64_stat	/* Add _F64_ prefix */
#   endif /* __DECC */

# defined(__EXTERN_PREFIX)
#   pragma extern_prefix "_F64_"
# endif
  extern int __STAT__ __((const char *, struct stat *));
# if defined(__EXTERN_PREFIX)
#   pragma extern_prefix ""
# endif
# if  defined(__F64_USE_JACKET)
    __F64_USE_JACKET int stat(const char *__a, struct stat *__b) {
      return(_F64_stat(__a,__b));
    }
# endif /* __F64_USE_JACKET */

In effect, we get both the effects of #pragma extern_prefix (since gcc
predefines __EXTERN_PREFIX) and the wrapper functions (since obviously
__DECC isn't defined), resulting in the double prefix observed.

The fix is trivial: instead of defining __EXTERN_PREFIX ourselves, define
__PRAGMA_EXTERN_PREFIX (similar to the Solaris 2 solution above) and change
the __DECC test via fixincludes to test for __DECC || __PRAGMA_EXTERN_PREFIX
instead.

The patch below implements this and allows me to bootstrap gcc 3.2.2 on
alpha-dec-osf5.1b (thanks to Larry McVoy for providing a test system).
Besides, the patch fixes PR c/6126 (verified on the 3.3 branch on
alpha-dec-osf5.1) and most likely PR c/5059 as well.  I couldn't check
mainline, which doesn't bootstrap on Tru64 UNIX for about 2 months ;-(
It passes make check in fixinc, too.

Note that 3.3/3.4 need a slightly different version of the osf.h patch,
appended separately below.

Unfortunately, this patch fixes only part of the #pragma extern_prefix
problem on Tru64 UNIX: besides <sys/stat.h> with its __EXTERN_PREFIX magic,
many other system headers use that pragma.  I'll have to provide
fixincludes fixes to test for __PRAGMA_EXTERN_PREFIX in addition to __DECC,
but this will have to wait for a different patch since several forms of the
__DECC test are used there.

Ok for 3.2 and 3.3 branches as well as mainline?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


Thu Feb 20 16:23:34 2003  Rainer Orth  <ro at TechFak dot Uni-Bielefeld dot DE>

	* config/alpha/osf.h (CPP_SUBTARGET_SPEC): Define
	__PRAGMA_EXTERN_PREFIX to signal support to system headers.

	* fixinc/inclhack.def (alpha___extern_prefix): Indicate #pragma
	extern_prefix support for Tru64 UNIX V5 <sys/stat.h>. 
	* fixinc/fixincl.x: Regenerate.
	* fixinc/tests/base/sys/stat.h [ALPHA___EXTERN_PREFIX_CHECK]: New
	testcase.
	Fixes PR c/5059, c/6126, other/9671.
	
Index: config/alpha/osf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/osf.h,v
retrieving revision 1.22.14.3
diff -u -p -r1.22.14.3 osf.h
--- config/alpha/osf.h	12 Apr 2002 22:16:56 -0000	1.22.14.3
+++ config/alpha/osf.h	20 Feb 2003 20:25:01 -0000
@@ -48,7 +48,7 @@ Boston, MA 02111-1307, USA.  */
 #undef CPP_SUBTARGET_SPEC
 #define CPP_SUBTARGET_SPEC \
 "%{pthread|threads:-D_REENTRANT} %{threads:-D_PTHREAD_USE_D4} %(cpp_xfloat) \
--D__EXTERN_PREFIX"
+-D__PRAGMA_EXTERN_PREFIX"
 
 /* Under OSF4, -p and -pg require -lprof1, and -lprof1 requires -lpdf.  */
 
Index: fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.120.2.6.4.2
diff -u -p -r1.120.2.6.4.2 inclhack.def
--- fixinc/inclhack.def	14 Feb 2003 04:58:24 -0000	1.120.2.6.4.2
+++ fixinc/inclhack.def	20 Feb 2003 20:25:02 -0000
@@ -603,6 +603,22 @@ fix = {
 
 
 /*
+ *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/stat.h>.
+ */
+fix = {
+    hackname  = alpha___extern_prefix;
+    files     = sys/stat.h;
+    select    = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
+
+    mach      = "alpha*-dec-osf5*";
+    c_fix     = format;
+    c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
+
+    test_text = "#   if defined(__DECC)";
+};
+
+
+/*
  *  Fix assert macro in assert.h on Alpha OSF/1.
  *  The superfluous int cast breaks C++.
  */
Index: fixinc/tests/base/sys/stat.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/tests/base/sys/stat.h,v
retrieving revision 1.4
diff -u -p -r1.4 stat.h
--- fixinc/tests/base/sys/stat.h	19 Jul 2000 14:18:31 -0000	1.4
+++ fixinc/tests/base/sys/stat.h	20 Feb 2003 20:25:02 -0000
@@ -9,6 +9,11 @@
 
 
 
+#if defined( ALPHA___EXTERN_PREFIX_CHECK )
+#   if defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX)
+#endif  /* ALPHA___EXTERN_PREFIX_CHECK */
+
+
 #if defined( M88K_BAD_S_IF_CHECK )
 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* is regular? */
 #endif  /* M88K_BAD_S_IF_CHECK */


Thu Feb 20 16:23:34 2003  Rainer Orth  <ro at TechFak dot Uni-Bielefeld dot DE>

	* config/alpha/osf.h (TARGET_OS_CPP_BUILTINS): Define
	__PRAGMA_EXTERN_PREFIX to signal support to system headers.

Index: config/alpha/osf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/osf.h,v
retrieving revision 1.29
diff -u -p -b -r1.29 osf.h
--- config/alpha/osf.h	26 Nov 2002 04:54:47 -0000	1.29
+++ config/alpha/osf.h	20 Feb 2003 20:26:19 -0000
@@ -39,7 +39,7 @@ Boston, MA 02111-1307, USA.  */
 	builtin_define ("_SYSTYPE_BSD");	\
 	builtin_define ("__osf__");		\
 	builtin_define ("_LONGLONG");		\
-	builtin_define ("__EXTERN_PREFIX");	\
+	builtin_define ("__PRAGMA_EXTERN_PREFIX");	\
 	builtin_assert ("system=unix");		\
 	builtin_assert ("system=xpg4");		\
 	/* Tru64 UNIX V5 has a 16 byte long	\


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]