While working with GCC's language hooks, we found that certain places in GCC test for a null value of lang_hooks.callgraph.expand_function, but cgraph_expand_function() calls the hook directly:
In cgraphunit.c: /* Expand function specified by NODE. */ static void cgraph_expand_function (struct cgraph_node *node) { tree decl = node->decl; /* We ought to not compile any inline clones. */ gcc_assert (!node->global.inlined_to); if (flag_unit_at_a_time) announce_function (decl); cgraph_lower_function (node); /* Generate RTL for the body of DECL. */ lang_hooks.callgraph.expand_function (decl); ------------ In toplev.c: /* Disable unit-at-a-time mode for frontends not supporting callgraph interface. */ if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function) flag_unit_at_a_time = 0; ------------ In function.c: /* Possibly warn about unused parameters. When frontend does unit-at-a-time, the warning is already issued at finalization time. */ if (warn_unused_parameter && !lang_hooks.callgraph.expand_function) do_warn_unused_parameter (current_function_decl); ------------ We tried setting lang_hooks.callgraph.expand_function to NULL: /* For now, disable unit-at-a-time by setting expand_function to NULL */ #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION NULL which has the desited effect of disabling unit-at-a-time, but runs aground in cgraph_expand_function() with a segfault, when it attempts to call lang_hooks.callgraph.expand_function(). It seems that GCC is handling lang_hooks.callgraph.expand_function in an inconsistent fashion. Is a null value for expand_function meaningful? If it is, then what is the fix for cgraph_expand_function()?