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]

PATCH: Fix bootstrap with Sun Studio cc 12.1 and gmp 4.3.1 (PR bootstrap/41771)


As described in PR bootstrap/41771, bootstrap fails with Sun Studio cc
12.1 and gmp 4.3.1: xgcc doesn't link since gcc.o has undefined
references to libgmp functions, but isn't linked with -lgmp.

This happens because, compared to gmp 4.3.0, the new version correctly
detects that recent versions of Sun Studio cc support extern/static
inline, while ansidecl.h does not and has

#define inline

gcc.c includes flags.h, which (via real.h) includes gmp.h, and all
inline declarations there turn into function definitions.  To avoid
having to unnecessarily link xgcc with -lgmp, flags.h no longer includes
real.h directly, but only those files that need it (only
tree-ssa-reassoc.c is affected).  To allow this, the HONOR_* macros that
require real.h MODE_HAS_* macros are moved to real.h themselves, as
suggested by Ulrich.

To have gmp.h and ansidecl.h agree about inline support, the test has to
be fixed, otherwise every file including gmp.h still gets its own
definition of all the inline functions:

-#if __STDC_VERSION__ > 199901L || defined(__cplusplus)
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))

The first > is plain wrong: C99 defines __STDC_VERSION__ as 199901L.
The second part was suggested by this thread:

	http://mail.opensolaris.org/pipermail/tools-compilers/2008-June/000230.html

Afterwards, two Sun cc errors need to be fixed/avoided:

"/vol/src/gnu/gcc/gcc-4.4.2/gcc/dominance.c", line 718: reference to static
identifier "dom_convert_dir_to_idx" in extern inline function
"/vol/src/gnu/gcc/gcc-4.4.2/gcc/gimple.c", line 1471: reference to static
identifier "walk_gimple_asm" in extern inline function

These are from the 4.4.2 build; I don't have the mainline build log
available anymore.  I'm not sure they are really correct, but seem to
make sense, so I've removed inline from the calling functions to avoid
them.

With those changes, mainline bootstrapped successfully with Studio 12.1
cc and gmp 4.3.1.  Ok?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2009-12-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc:
	PR bootstrap/41771
	* flags.h: Don't include real.h.
	(HONOR_NANS, HONOR_SNANS, HONOR_INFINITIES, HONOR_SIGNED_ZEROS,
	HONOR_SIGN_DEPENDENT_ROUNDING): Move ...
	* real.h (HONOR_NANS, HONOR_SNANS, HONOR_INFINITIES,
	HONOR_SIGNED_ZEROS, HONOR_SIGN_DEPENDENT_ROUNDING): ... here.
	* tree-ssa-reassoc.c: Include real.h.
	* Makefile.in (FLAGS_H): Remove $(REAL_H).
	(tree-ssa-reassoc.o): Depend on real.h.
	* dominance.c (set_immediate_dominator):  Remove inline.
	* gimple.c (walk_gimple_op): Likewise.

	include:
	PR bootstrap/41771
	* ansidecl.h: Fix inline test for C99 and Sun Studio cc.

Index: gcc/flags.h
===================================================================
--- gcc/flags.h	(revision 155127)
+++ gcc/flags.h	(working copy)
@@ -24,7 +24,6 @@
 
 #include "coretypes.h"
 #include "options.h"
-#include "real.h"
 
 enum debug_info_type
 {
@@ -334,32 +333,6 @@
    instrumentation.  */
 extern bool flag_instrument_functions_exclude_p (tree fndecl);
 
-/* True if the given mode has a NaN representation and the treatment of
-   NaN operands is important.  Certain optimizations, such as folding
-   x * 0 into 0, are not correct for NaN operands, and are normally
-   disabled for modes with NaNs.  The user can ask for them to be
-   done anyway using the -funsafe-math-optimizations switch.  */
-#define HONOR_NANS(MODE) \
-  (MODE_HAS_NANS (MODE) && !flag_finite_math_only)
-
-/* Like HONOR_NANs, but true if we honor signaling NaNs (or sNaNs).  */
-#define HONOR_SNANS(MODE) (flag_signaling_nans && HONOR_NANS (MODE))
-
-/* As for HONOR_NANS, but true if the mode can represent infinity and
-   the treatment of infinite values is important.  */
-#define HONOR_INFINITIES(MODE) \
-  (MODE_HAS_INFINITIES (MODE) && !flag_finite_math_only)
-
-/* Like HONOR_NANS, but true if the given mode distinguishes between
-   positive and negative zero, and the sign of zero is important.  */
-#define HONOR_SIGNED_ZEROS(MODE) \
-  (MODE_HAS_SIGNED_ZEROS (MODE) && flag_signed_zeros)
-
-/* Like HONOR_NANS, but true if given mode supports sign-dependent rounding,
-   and the rounding mode is important.  */
-#define HONOR_SIGN_DEPENDENT_ROUNDING(MODE) \
-  (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) && flag_rounding_math)
-
 /* True if overflow wraps around for the given integral type.  That
    is, TYPE_MAX + 1 == TYPE_MIN.  */
 #define TYPE_OVERFLOW_WRAPS(TYPE) \
Index: gcc/real.h
===================================================================
--- gcc/real.h	(revision 155127)
+++ gcc/real.h	(working copy)
@@ -1,6 +1,6 @@
 /* Definitions of floating-point access for GNU compiler.
    Copyright (C) 1989, 1991, 1994, 1996, 1997, 1998, 1999,
-   2000, 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This file is part of GCC.
 
@@ -199,7 +199,32 @@
   (FLOAT_MODE_P (MODE) \
    && FLOAT_MODE_FORMAT (MODE)->has_sign_dependent_rounding)
 
+/* True if the given mode has a NaN representation and the treatment of
+   NaN operands is important.  Certain optimizations, such as folding
+   x * 0 into 0, are not correct for NaN operands, and are normally
+   disabled for modes with NaNs.  The user can ask for them to be
+   done anyway using the -funsafe-math-optimizations switch.  */
+#define HONOR_NANS(MODE) \
+  (MODE_HAS_NANS (MODE) && !flag_finite_math_only)
 
+/* Like HONOR_NANs, but true if we honor signaling NaNs (or sNaNs).  */
+#define HONOR_SNANS(MODE) (flag_signaling_nans && HONOR_NANS (MODE))
+
+/* As for HONOR_NANS, but true if the mode can represent infinity and
+   the treatment of infinite values is important.  */
+#define HONOR_INFINITIES(MODE) \
+  (MODE_HAS_INFINITIES (MODE) && !flag_finite_math_only)
+
+/* Like HONOR_NANS, but true if the given mode distinguishes between
+   positive and negative zero, and the sign of zero is important.  */
+#define HONOR_SIGNED_ZEROS(MODE) \
+  (MODE_HAS_SIGNED_ZEROS (MODE) && flag_signed_zeros)
+
+/* Like HONOR_NANS, but true if given mode supports sign-dependent rounding,
+   and the rounding mode is important.  */
+#define HONOR_SIGN_DEPENDENT_ROUNDING(MODE) \
+  (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) && flag_rounding_math)
+
 /* Declare functions in real.c.  */
 
 /* Binary or unary arithmetic on tree_code.  */
Index: gcc/dominance.c
===================================================================
--- gcc/dominance.c	(revision 155127)
+++ gcc/dominance.c	(working copy)
@@ -1,5 +1,5 @@
 /* Calculate (post)dominators in slightly super-linear time.
-   Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008 Free
+   Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
    Software Foundation, Inc.
    Contributed by Michael Matz (matz@ifh.de).
 
@@ -711,7 +711,7 @@
 
 /* Set the immediate dominator of the block possibly removing
    existing edge.  NULL can be used to remove any edge.  */
-inline void
+void
 set_immediate_dominator (enum cdi_direction dir, basic_block bb,
 			 basic_block dominated_by)
 {
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 155127)
+++ gcc/Makefile.in	(working copy)
@@ -875,7 +875,7 @@
 RECOG_H = recog.h
 ALIAS_H = alias.h coretypes.h
 EMIT_RTL_H = emit-rtl.h
-FLAGS_H = flags.h coretypes.h options.h $(REAL_H)
+FLAGS_H = flags.h coretypes.h options.h
 FUNCTION_H = function.h $(TREE_H) $(HASHTAB_H) vecprim.h
 EXPR_H = expr.h insn-config.h $(FUNCTION_H) $(RTL_H) $(FLAGS_H) $(TREE_H) $(MACHMODE_H) $(EMIT_RTL_H)
 OPTABS_H = optabs.h insn-codes.h
@@ -2500,7 +2500,7 @@
 tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
    $(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
    $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_PASS_H) $(FLAGS_H) \
-   tree-iterator.h $(BASIC_BLOCK_H) $(GIMPLE_H) $(TREE_INLINE_H) vec.h \
+   tree-iterator.h real.h $(BASIC_BLOCK_H) $(GIMPLE_H) $(TREE_INLINE_H) vec.h \
    langhooks.h alloc-pool.h pointer-set.h $(CFGLOOP_H)
 tree-optimize.o : tree-optimize.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_P_H) hard-reg-set.h $(EXPR_H) $(GGC_H) output.h \
Index: gcc/gimple.c
===================================================================
--- gcc/gimple.c	(revision 155127)
+++ gcc/gimple.c	(working copy)
@@ -1297,7 +1297,7 @@
    The return value is that returned by the last call to walk_tree, or
    NULL_TREE if no CALLBACK_OP is specified.  */
 
-inline tree
+tree
 walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
 		struct walk_stmt_info *wi)
 {
Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c	(revision 155127)
+++ gcc/tree-ssa-reassoc.c	(working copy)
@@ -32,6 +32,7 @@
 #include "tree-dump.h"
 #include "timevar.h"
 #include "tree-iterator.h"
+#include "real.h"
 #include "tree-pass.h"
 #include "alloc-pool.h"
 #include "vec.h"
Index: include/ansidecl.h
===================================================================
--- include/ansidecl.h	(revision 155127)
+++ include/ansidecl.h	(working copy)
@@ -178,7 +178,7 @@
 /* inline requires special treatment; it's in C99, and GCC >=2.7 supports
    it too, but it's not in C89.  */
 #undef inline
-#if __STDC_VERSION__ > 199901L || defined(__cplusplus)
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
 /* it's a keyword */
 #else
 # if GCC_VERSION >= 2007


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