Message ID | 55417DCC.2090708@redhat.com |
---|---|
State | New |
Headers | show |
On Wed, Apr 29, 2015 at 5:56 PM, Aldy Hernandez <aldyh@redhat.com> wrote: > > Despite what Go thinks: > > /* The debug hooks are used to implement -fdump-go-spec because it > gives a simple and stable API for all the information we need to > dump. */ > > ...the debug hooks are not stable... :). Alas. > With this patch I have done my best to give Go what it wants without > recreating what the front-ends were doing. I've made the go_decl() call > work from within the early_global_decl() hook which gets called as we parse > (rest_of_decl_compilation). I far as I understand, this hack is a one-time > thing for use internally in the build process, so we don't care whether > go_decl() will receive location information?? That is true: the goal is to output the declarations in Go syntax; location information is irrelevant. > Is there not a more modern way of Go getting the DECLs it needs without > abusing the debug_hook machinery? I don't know. Thanks for working on this. Have you tried building with --enable-languages=go? On a GNU/Linux system it should build and pass all tests with no extra effort. Ian
> Thanks for working on this. Have you tried building with > --enable-languages=go? On a GNU/Linux system it should build and pass > all tests with no extra effort. Yes. No regressions. Thanks. Aldy
diff --git a/gcc/godump.c b/gcc/godump.c index 94d0c8b..5de34db 100644 --- a/gcc/godump.c +++ b/gcc/godump.c @@ -517,6 +517,7 @@ go_function_decl (tree decl) static void go_early_global_decl (tree decl) { + go_decl (decl); real_debug_hooks->early_global_decl (decl); } @@ -526,7 +527,6 @@ static void go_late_global_decl (tree decl) { real_debug_hooks->late_global_decl (decl); - go_decl (decl); } /* A type declaration. */ diff --git a/gcc/passes.c b/gcc/passes.c index 3bb0e5d..4dee8ad 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -297,10 +297,20 @@ rest_of_decl_compilation (tree decl, /* Generate early debug for global variables. Any local variables will be handled by either handling reachable functions from finalize_compilation_unit (and by consequence, locally scoped - symbols), or by rest_of_type_compilation below. */ + symbols), or by rest_of_type_compilation below. + + Also, pick up function prototypes, which will be mostly ignored + by the different early_global_decl() hooks, but will at least be + used by Go's hijack of the debug_hooks to implement + -fdump-go-spec. */ if (!flag_wpa && !in_lto_p - && TREE_CODE (decl) != FUNCTION_DECL + && (TREE_CODE (decl) != FUNCTION_DECL + /* This will pick up function prototypes with no bodies, + which are not visible in finalize_compilation_unit() + while iterating with FOR_EACH_*_FUNCTION through the + symbol table. */ + || !DECL_SAVED_TREE (decl)) && !decl_function_context (decl) && !current_function_decl && !decl_type_context (decl))