aboutsummaryrefslogtreecommitdiffstats
path: root/ortho/gcc
diff options
context:
space:
mode:
authorBrian Drummond <brian@shapes.demon.co.uk>2013-12-07 15:04:30 +0000
committerBrian Drummond <brian@shapes.demon.co.uk>2013-12-07 15:04:30 +0000
commit04b041be9062db340a648f5ed0f0788ac25c7290 (patch)
treeaec835ddea47847cdad443d7b372fff07412b80f /ortho/gcc
parentdf660489af69e9fbfa6ede69790777b7b07401a5 (diff)
downloadghdl-04b041be9062db340a648f5ed0f0788ac25c7290.tar.gz
ghdl-04b041be9062db340a648f5ed0f0788ac25c7290.tar.bz2
ghdl-04b041be9062db340a648f5ed0f0788ac25c7290.zip
Patch ortho-lang.c to fix gcc failure in optimisation passes; patch others to allow debug backend and oread to build with gcc4.8
Diffstat (limited to 'ortho/gcc')
-rw-r--r--ortho/gcc/Makefile10
-rw-r--r--ortho/gcc/ortho-lang.c35
-rw-r--r--ortho/gcc/ortho_ident.adb3
3 files changed, 44 insertions, 4 deletions
diff --git a/ortho/gcc/Makefile b/ortho/gcc/Makefile
index 2687b791a..da64a29a8 100644
--- a/ortho/gcc/Makefile
+++ b/ortho/gcc/Makefile
@@ -2,11 +2,13 @@ ortho_srcdir=..
orthobe_srcdir=$(ortho_srcdir)/gcc
agcc_objdir=.
agcc_srcdir=$(ortho_srcdir)/gcc
-AGCC_GCCSRC_DIR:=$(HOME)/dist/gcc-4.7.2
-AGCC_GCCOBJ_DIR:=$(AGCC_GCCSRC_DIR)-objs/
+# Modify AGCC_GCCSRC_DIR and AGCC_GCCOBJ_DIR for your environment
+AGCC_GCCSRC_DIR:=$(HOME)/Projects/gcc4.8.2/source/gcc-4.8.2/
+AGCC_GCCOBJ_DIR:=$(HOME)/Projects/gcc4.8.2/build/
SED=sed
GNATMAKE=gnatmake
CC=gcc
+COMPILER=g++
all: $(ortho_exec)
@@ -16,7 +18,8 @@ ORTHO_BASENAME=$(orthobe_srcdir)/ortho_gcc
ORTHO_PACKAGE=Ortho_Gcc
#LIBFLAGS=$(HOME)/dist/mpfr-2.3.1/.libs/libmpfr.a $(HOME)/dist/gmp-4.2.2/.libs/libgmp.a
-LIBFLAGS=-L$(HOME)/dist/build/lib -lmpc -lmpfr -lgmp -lz -ldl #$(AGCC_GCCOBJ_DIR)/intl/libintl.a -liconv -lz
+LIBFLAGS=-L$(AGCC_GCCOBJ_DIR)./mpfr/.libs -L$(AGCC_GCCOBJ_DIR)./mpc/src/.libs -lmpc -lmpfr -lgmp -lz -ldl -lstdc++
+#$(AGCC_GCCOBJ_DIR)/intl/libintl.a -liconv -lz
$(ortho_exec): $(AGCC_DEPS) $(ORTHO_BASENAME).ads force
$(GNATMAKE) -m -o $@ -g -aI$(ortho_srcdir) \
@@ -26,6 +29,7 @@ $(ortho_exec): $(AGCC_DEPS) $(ORTHO_BASENAME).ads force
$(AGCC_GCCOBJ_DIR)gcc/libcommon-target.a \
$(AGCC_GCCOBJ_DIR)gcc/libcommon.a \
$(AGCC_GCCOBJ_DIR)libcpp/libcpp.a \
+ $(AGCC_GCCOBJ_DIR)libbacktrace/.libs/libbacktrace.a \
$(AGCC_GCCOBJ_DIR)libiberty/libiberty.a \
$(AGCC_GCCOBJ_DIR)libdecnumber/libdecnumber.a \
$(LIBFLAGS) #-static
diff --git a/ortho/gcc/ortho-lang.c b/ortho/gcc/ortho-lang.c
index b46c0123f..904bfa46d 100644
--- a/ortho/gcc/ortho-lang.c
+++ b/ortho/gcc/ortho-lang.c
@@ -23,6 +23,9 @@
#include "tree-pass.h"
#include "tree-dump.h"
+// temp for debugging
+// #include "stdio.h"
+
/* TODO:
* remove stmt_list_stack, save in if/case/loop block
* Re-add -v (if necessary)
@@ -307,6 +310,38 @@ ortho_init (void)
BUILT_IN_STACK_RESTORE, BUILT_IN_NORMAL, NULL, NULL_TREE), true);
}
+ /* Test and (if necessary) repair BUILT_IN_UNREACHABLE builtin.
+ FIXME: Re-evaluate this and remove when upstream gcc has fixed the
+ underlying problem : gcc4.8.2 segfaults compiling with -O2,
+ during fn "void unloop_loops" in tree-ssa-loop-ivcanon.c */
+ {
+ tree func_type = build_function_type (ptr_type_node, NULL_TREE);
+
+ if (builtin_decl_implicit_p (BUILT_IN_UNREACHABLE))
+ {
+ // printf("BUILT_IN_UNREACHABLE function is available\n");
+ }
+ else
+ {
+ tree builtin_f = builtin_decl_explicit (BUILT_IN_UNREACHABLE);
+ // printf("No implicit BUILT_IN_UNREACHABLE function : repairing!\n");
+ debug_tree(builtin_f);
+ if (builtin_f == NULL_TREE)
+ {
+ // printf("Adding BUILT_IN_UNREACHABLE function\n");
+ set_builtin_decl (BUILT_IN_UNREACHABLE,
+ builtin_function("__builtin_unreachable", func_type,
+ BUILT_IN_UNREACHABLE, BUILT_IN_NORMAL, NULL, NULL_TREE),
+ true);
+ }
+ else
+ {
+ // printf("Making BUILT_IN_UNREACHABLE function implicit\n");
+ set_builtin_decl_implicit_p (BUILT_IN_UNREACHABLE, true);
+ }
+ }
+ }
+
{
REAL_VALUE_TYPE v;
diff --git a/ortho/gcc/ortho_ident.adb b/ortho/gcc/ortho_ident.adb
index 5ff093955..56a851016 100644
--- a/ortho/gcc/ortho_ident.adb
+++ b/ortho/gcc/ortho_ident.adb
@@ -1,7 +1,8 @@
package body Ortho_Ident is
function Get_Identifier_With_Length (Str : Address; Size : Integer)
return O_Ident;
- pragma Import (C, Get_Identifier_With_Length, "get_identifier_with_length_c");
+ pragma Import (C, Get_Identifier_With_Length,
+ "get_identifier_with_length_c");
function Compare_Identifier_String
(Id : O_Ident; Str : Address; Size : Integer)