--- gcc-4.6.0/gcc/vhdl/Make-lang.in.orig	2012-01-09 19:45:32.000000000 +0100
+++ gcc-4.6.0/gcc/vhdl/Make-lang.in	2012-01-09 19:46:47.000000000 +0100
@@ -96,7 +96,7 @@ AGCC_GCCOBJ_DIR=../
 AGCC_INC_FLAGS=-I$(AGCC_GCCOBJ_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/include \
  -I$(AGCC_GCCSRC_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/gcc/config \
  -I$(AGCC_GCCSRC_DIR)/libcpp/include
-AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS)
+AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS) $(CFLAGS) $(INCLUDES)
 
 AGCC_LOCAL_OBJS=ortho-lang.o
 
@@ -132,7 +132,7 @@ ghdl1$(exeext): $(AGCC_OBJS) $(AGCC_DEPS
 	 -cargs $(CFLAGS) $(GHDL_ADAFLAGS)
 	$(GNATMAKE) -o $@ -aI$(srcdir)/vhdl -aOvhdl ortho_gcc-main \
 	 -bargs -E -cargs $(CFLAGS) $(GHDL_ADAFLAGS) \
-	 -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS)
+	 -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS) $(CLOOGLIBS) $(PPLLIBS) $(ZLIB) $(PLUGINLIBS)
 
 # The driver for ghdl.
 ghdl$(exeext): force
--- gcc-4.6.0/gcc/vhdl/ortho-lang.c.orig	2012-01-09 18:44:59.000000000 +0100
+++ gcc-4.6.0/gcc/vhdl/ortho-lang.c	2012-01-09 23:08:13.000000000 +0100
@@ -3,8 +3,9 @@
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
 #include "tree.h"
+#include "gimple.h"
+#include "tm.h"
 #include "tm_p.h"
 #include "defaults.h"
 #include "ggc.h"
@@ -15,19 +16,19 @@
 #include "opts.h"
 #include "options.h"
 #include "real.h"
-#include "tree-gimple.h"
 #include "function.h"
 #include "cgraph.h"
 #include "target.h"
 #include "convert.h"
 #include "tree-pass.h"
 #include "tree-dump.h"
+#include "tree-iterator.h"
 
 static tree type_for_size (unsigned int precision, int unsignedp);
 
 const int tree_identifier_size = sizeof (struct tree_identifier);
 
-struct binding_level GTY(())
+struct GTY(()) binding_level
 {
   /*  The BIND_EXPR node for this binding.  */
   tree bind;
@@ -64,7 +65,11 @@ push_binding (void)
   struct binding_level *res;
 
   if (old_binding_levels == NULL)
-    res = (struct binding_level *) ggc_alloc (sizeof (struct binding_level));
+	  /*
+	   * this looks like a normal memory allocation,
+	   * gcc_alloc changed to xmalloc
+	   */
+    res = (struct binding_level *) xmalloc (sizeof (struct binding_level));
   else
     {
       res = old_binding_levels;
@@ -133,22 +138,54 @@ pop_binding (void)
       tree t;
 
       /* Create an artificial var to save the stack pointer.  */
-      tmp_var = build_decl (VAR_DECL, NULL, ptr_type_node);
+      /* build_decl got a new parameter
+       * http://www.mail-archive.com/ghdl-discuss@gna.org/msg01245.html
+       */
+      tmp_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL, ptr_type_node);
       DECL_ARTIFICIAL (tmp_var) = true;
       DECL_IGNORED_P (tmp_var) = true;
       TREE_USED (tmp_var) = true;
       push_decl (tmp_var);
 
+      /*
+       * The functions
+       *   build_function_call_expr
+       *
+       * were eleminated in newer versions of GCC. See
+       *   http://patchwork.ozlabs.org/patch/57555/
+       *   http://patchwork.ozlabs.org/patch/57906/
+       *   http://patchwork.ozlabs.org/patch/57911/
+       *   http://patchwork.ozlabs.org/patch/57962/
+       *
+       *
+       */
+
       /* Create the save stmt.  */
-      save_call = build_function_call_expr
-	(implicit_built_in_decls[BUILT_IN_STACK_SAVE], NULL_TREE);
+
+      /*
+       * build_function_call_expr was removed with patch 57962
+       *   http://patchwork.ozlabs.org/patch/57962/
+       *
+       * The signtatur was
+       *   build_function_call_expr (location_t loc, tree fndecl, tree arglist)
+       * A new function build_call_expr_loc_vec was introduced.
+       * See examples in the patch how to replace that function.
+       */
+      save_call = build_call_expr_loc
+    		  (UNKNOWN_LOCATION,
+    		   implicit_built_in_decls[BUILT_IN_STACK_SAVE],
+    		   0);
       save = build2 (MODIFY_EXPR, ptr_type_node, tmp_var, save_call);
       TREE_SIDE_EFFECTS (save) = true;
 
       /* Create the restore stmt.  */
-      restore = build_function_call_expr
-	(implicit_built_in_decls[BUILT_IN_STACK_RESTORE],
-	 tree_cons (NULL_TREE, tmp_var, NULL_TREE));
+
+      // tree_cons (NULL_TREE, tmp_var, NULL_TREE)
+      restore = build_call_expr_loc
+    		  (UNKNOWN_LOCATION,
+    		   implicit_built_in_decls[BUILT_IN_STACK_RESTORE],
+    		   1,
+    		   tmp_var);
 
       /* Build a try-finally block.
 	 The statement list is the block of current statements.  */
@@ -252,14 +289,14 @@ ortho_init (void)
   /* Create a global binding.  */
   push_binding ();
 
-  build_common_tree_nodes (0, 0);
+  build_common_tree_nodes (0);
   size_type_node = type_for_size (GET_MODE_BITSIZE (Pmode), 1);
   set_sizetype (size_type_node);
   build_common_tree_nodes_2 (0);
 
-  n = build_decl (TYPE_DECL, get_identifier ("int"), integer_type_node);
+  n = build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("int"), integer_type_node);
   push_decl (n);
-  n = build_decl (TYPE_DECL, get_identifier ("char"), char_type_node);
+  n = build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("char"), char_type_node);
   push_decl (n);
 
   /* Create alloca builtin.  */
@@ -319,10 +356,11 @@ ortho_finish (void)
 {
 }
 
-static unsigned int
-ortho_init_options (unsigned int argc, const char **argv)
+static void
+ortho_init_options (unsigned int decoded_options_count,
+		  struct cl_decoded_option *decoded_options)
 {
-  return CL_vhdl;
+  //return CL_vhdl;
 }
 
 static bool
@@ -331,14 +369,24 @@ ortho_post_options (const char **pfilena
   if (*pfilename == NULL || strcmp (*pfilename, "-") == 0)
     *pfilename = "*stdin*";
 
+  /*
+   * http://www.mail-archive.com/ghdl-discuss@gna.org/msg01245.html
+   */
+  /* Excess precision other than "fast" requires front-end
+   * support.
+   */
+  flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
+
   /* Run the back-end.  */
   return false;
 }
 
 extern int lang_handle_option (const char *opt, const char *arg);
 
-static int
-ortho_handle_option (size_t code, const char *arg, int value)
+static bool
+ortho_handle_option (size_t code, const char *arg, int value,
+		  int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
+		  const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
 {
   const char *opt;
 
@@ -351,7 +399,8 @@ ortho_handle_option (size_t code, const 
     case OPT_c:
     case OPT__anaelab:
       /* Only a few options have a real arguments.  */
-      return lang_handle_option (opt, arg);
+      //return lang_handle_option (opt, arg);
+    	return true;
     default:
       /* The other options must have a joint argument.  */
       if (arg != NULL)
@@ -368,14 +417,15 @@ ortho_handle_option (size_t code, const 
 	  nopt[len1 + len2] = 0;
 	  opt = nopt;
 	}
-      return lang_handle_option (opt, NULL);
+      //return lang_handle_option (opt, NULL);
+      return true;
     }
 }
 
 extern int lang_parse_file (const char *filename);
 
 static void
-ortho_parse_file (int debug)
+ortho_parse_file (void)
 {
   const char *filename;
 
@@ -586,7 +636,7 @@ builtin_function (const char *name,
 		  const char *library_name,
 		  tree attrs ATTRIBUTE_UNUSED)
 {
-  tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
+  tree decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, get_identifier (name), type);
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
   if (library_name)
@@ -678,55 +728,59 @@ type_for_mode (enum machine_mode mode, i
 #undef LANG_HOOKS_GETDECLS
 #define LANG_HOOKS_GETDECLS lhd_return_null_tree_v
 
-const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
-
-/* Tree code classes.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-const enum tree_code_class tree_code_type[] = {
-#include "tree.def"
-  'x'
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
-   operands beyond the fixed part of the node structure.
-   Not used for types or decls.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-const unsigned char tree_code_length[] = {
-#include "tree.def"
-  0
-};
-#undef DEFTREECODE
+/*
+ *
+ */
+struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) NAME,
-const char * const tree_code_name[] = {
-#include "tree.def"
-  "@@dummy"
-};
-#undef DEFTREECODE
+///* Tree code classes.  */
+//
+//#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+//
+//const enum tree_code_class tree_code_type[] = {
+//#include "tree.def"
+//  'x'
+//};
+//#undef DEFTREECODE
+//
+///* Table indexed by tree code giving number of expression
+//   operands beyond the fixed part of the node structure.
+//   Not used for types or decls.  */
+//
+//#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+//
+//const unsigned char tree_code_length[] = {
+//#include "tree.def"
+//  0
+//};
+//#undef DEFTREECODE
+//
+//#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) NAME,
+//const char * const tree_code_name[] = {
+//#include "tree.def"
+//  "@@dummy"
+//};
+//#undef DEFTREECODE
 
-union lang_tree_node 
+union
   GTY((desc ("0"),
-       chain_next ("(union lang_tree_node *) GENERIC_NEXT (&%h.generic)")))
+       chain_next ("(union lang_tree_node *) TREE_CHAIN (&%h.generic)")))
+  lang_tree_node
 {
-  union tree_node GTY ((tag ("0"))) generic;
+  union GTY ((tag ("0"))) tree_node generic;
 };
 
-struct lang_decl GTY(())
+struct GTY(()) lang_decl
 {
   char dummy;
 };
 
-struct lang_type GTY (())
+struct GTY(()) lang_type
 {
   char dummy;
 };
 
-struct language_function GTY (())
+struct GTY(()) language_function
 {
   char dummy;
 };
@@ -964,7 +1018,13 @@ new_alloca (tree rtype, tree size)
     cur_binding_level->save_stack = 1;
 
   args = tree_cons (NULL_TREE, fold_convert (size_type_node, size), NULL_TREE);
-  res = build_call_list (ptr_type_node, stack_alloc_function_ptr, args);
+
+  /*
+   * build_call_list was removed 2010-05-18 by Nathan Froyd
+   * build_call_vec could be used instead, see
+   *   http://patchwork.ozlabs.org/patch/57555/
+   */
+  res = build_call_vec (ptr_type_node, stack_alloc_function_ptr, args);
   return fold_convert (rtype, res);
 }
 
@@ -1075,7 +1135,7 @@ new_record_union_field (struct o_element
 {
   tree res;
 
-  res = build_decl (FIELD_DECL, ident, etype);
+  res = build_decl (UNKNOWN_LOCATION, FIELD_DECL, ident, etype);
   DECL_CONTEXT (res) = list->res;
   chain_append (&list->chain, res);
   *el = res;
@@ -1162,7 +1222,10 @@ new_access_type (tree dtype)
       res = make_node (POINTER_TYPE);
       TREE_TYPE (res) = NULL_TREE;
       /* Seems necessary.  */
-      TYPE_MODE (res) = Pmode;
+      /*
+       * http://www.mail-archive.com/ghdl-discuss@gna.org/msg01245.html
+       */
+      SET_TYPE_MODE (res, Pmode);
       layout_type (res);
       return res;
     }
@@ -1574,7 +1637,7 @@ new_type_decl (tree ident, tree atype)
   tree decl;
 
   TYPE_NAME (atype) = ident;
-  decl = build_decl (TYPE_DECL, ident, atype);
+  decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, ident, atype);
   TYPE_STUB_DECL (atype) = decl;
   push_decl (decl);
   /*
@@ -1623,7 +1686,7 @@ new_const_decl (tree *res, tree ident, e
 {
   tree cst;
 
-  cst = build_decl (VAR_DECL, ident, atype);
+  cst = build_decl (UNKNOWN_LOCATION, VAR_DECL, ident, atype);
   set_storage (cst, storage);
   TREE_READONLY (cst) = 1;
   push_decl (cst);
@@ -1663,7 +1726,7 @@ new_var_decl (tree *res, tree ident, enu
 {
   tree var;
 
-  var = build_decl (VAR_DECL, ident, atype);
+  var = build_decl (UNKNOWN_LOCATION, VAR_DECL, ident, atype);
   if (current_function_decl != NULL_TREE)
     {    
       /*  Local variable. */
@@ -1726,7 +1789,7 @@ new_interface_decl (struct o_inter_list 
 {
   tree r;
 
-  r = build_decl (PARM_DECL, ident, atype);
+  r = build_decl (UNKNOWN_LOCATION, PARM_DECL, ident, atype);
   /* DECL_CONTEXT (Res, Xxx); */
 
   /*  Do type conversion: convert boolean and enums to int  */
@@ -1762,7 +1825,7 @@ finish_subprogram_decl (struct o_inter_l
      is known not be have variables arguments.  */
   ortho_list_append (&interfaces->param_list, void_type_node);
 
-  decl = build_decl (FUNCTION_DECL, interfaces->ident,
+  decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, interfaces->ident,
 		     build_function_type (interfaces->rtype,
 					  interfaces->param_list.first));
   DECL_SOURCE_LOCATION (decl) = input_location;
@@ -1784,7 +1847,7 @@ finish_subprogram_decl (struct o_inter_l
 
   /*  Declare the result.
       FIXME: should be moved in start_function_body. */
-  result = build_decl (RESULT_DECL, NULL_TREE, interfaces->rtype);
+  result = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, interfaces->rtype);
   DECL_RESULT (decl) = result;
   DECL_CONTEXT (result) = decl;
 
@@ -1909,7 +1972,7 @@ new_association (struct o_assoc_list *as
 tree
 new_function_call (struct o_assoc_list *assocs)
 {
-  return build_call_list (TREE_TYPE (TREE_TYPE (assocs->subprg)),
+  return build_call_vec (TREE_TYPE (TREE_TYPE (assocs->subprg)),
 			  build_function_ptr (assocs->subprg),
 			  assocs->list.first);
 }
@@ -1919,7 +1982,7 @@ new_procedure_call (struct o_assoc_list 
 {
   tree res;
 
-  res = build_call_list (TREE_TYPE (TREE_TYPE (assocs->subprg)),
+  res = build_call_vec (TREE_TYPE (TREE_TYPE (assocs->subprg)),
 			 build_function_ptr (assocs->subprg),
 			 assocs->list.first);
   TREE_SIDE_EFFECTS (res) = 1;
@@ -2030,7 +2093,7 @@ build_label (void)
 {
   tree res;
 
-  res = build_decl (LABEL_DECL, NULL_TREE, void_type_node);
+  res = build_decl (UNKNOWN_LOCATION, LABEL_DECL, NULL_TREE, void_type_node);
   DECL_CONTEXT (res) = current_function_decl;
   DECL_ARTIFICIAL (res) = 1;
   return res;
@@ -2126,7 +2189,7 @@ new_expr_choice (struct o_case_block *bl
   tree stmt;
   
   stmt = build3 (CASE_LABEL_EXPR, void_type_node,
-		 expr, NULL_TREE, create_artificial_label ());
+		 expr, NULL_TREE, create_artificial_label (UNKNOWN_LOCATION));
   append_stmt (stmt);
 }
 
@@ -2136,7 +2199,7 @@ new_range_choice (struct o_case_block *b
   tree stmt;
 
   stmt = build3 (CASE_LABEL_EXPR, void_type_node,
-		 low, high, create_artificial_label ());
+		 low, high, create_artificial_label (UNKNOWN_LOCATION));
   append_stmt (stmt);
 }
 
@@ -2146,7 +2209,7 @@ new_default_choice (struct o_case_block 
   tree stmt;
 
   stmt = build3 (CASE_LABEL_EXPR, void_type_node,
-		 NULL_TREE, NULL_TREE, create_artificial_label ());
+		 NULL_TREE, NULL_TREE, create_artificial_label (UNKNOWN_LOCATION));
   append_stmt (stmt);
 }
 
--- gcc-4.6.0/gcc/configure.orig	2012-01-09 19:23:58.000000000 +0100
+++ gcc-4.6.0/gcc/configure	2012-01-09 19:26:50.000000000 +0100
@@ -7443,12 +7443,13 @@ else
 fi
 
 case "${host}" in
-*-*-darwin*)
   # By default, the Darwin ranlib will not treat common symbols as
   # definitions when  building the archive table of contents.  Other
   # ranlibs do that; pass an option to the Darwin ranlib that makes
   # it behave similarly.
-  ranlib_flags="-c"
+  # ranlib before Darwin10 requires the -c flag to look at common symbols.                          
+  *-*-darwin[3-9]*)
+  ranlib_flags=" -c"
   ;;
 *)
   ranlib_flags=""
