https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96905
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Tried --- gcc/cp/semantics.c.jj 2020-09-01 09:17:50.000000000 +0200 +++ gcc/cp/semantics.c 2020-09-03 21:20:20.678830381 +0200 @@ -4517,7 +4517,7 @@ expand_or_defer_fn_1 (tree fn) return false; } - if (DECL_OMP_DECLARE_REDUCTION_P (fn)) + if (DECL_IMMEDIATE_FUNCTION_P (fn) || DECL_OMP_DECLARE_REDUCTION_P (fn)) return false; return true; --- gcc/cp/decl2.c.jj 2020-07-28 15:39:09.780759362 +0200 +++ gcc/cp/decl2.c 2020-09-03 21:23:15.973278453 +0200 @@ -2172,7 +2172,7 @@ void mark_needed (tree decl) { TREE_USED (decl) = 1; - if (TREE_CODE (decl) == FUNCTION_DECL) + if (TREE_CODE (decl) == FUNCTION_DECL && !DECL_IMMEDIATE_FUNCTION_P (decl)) { /* Extern inline functions don't become needed when referenced. If we know a method will be emitted in other TU and no new --- gcc/cp/pt.c.jj 2020-09-01 09:17:28.042110726 +0200 +++ gcc/cp/pt.c 2020-09-03 21:14:14.497159429 +0200 @@ -23891,8 +23891,10 @@ mark_decl_instantiated (tree result, int { mark_definable (result); mark_needed (result); + if (DECL_IMMEDIATE_FUNCTION_P (result)) + ; /* Always make artificials weak. */ - if (DECL_ARTIFICIAL (result) && flag_weak) + else if (DECL_ARTIFICIAL (result) && flag_weak) comdat_linkage (result); /* For WIN32 we also want to put explicit instantiations in linkonce sections. */ but that is still not enough, the above are just some hacks to avoid creating cgraph nodes for immediate functions, but e.g. c_parse_final_cleanups still creates them.