This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PING: [PATCH, LTO] add externally_visible attribute when necessary with -fwhole-program and resolution file.
> + /* Set externally_visible flags for declaration of LDPR_PREVAILING_DEF */
> + if (flag_whole_program)
> + {
> + if (prevailing->resolution == LDPR_PREVAILING_DEF)
> + {
> + if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
> + prevailing->node->local.externally_visible = true;
> + else
> + prevailing->vnode->externally_visible = true;
> + }
> + else if (prevailing->resolution == LDPR_PREVAILING_DEF_IRONLY)
> + {
> + if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
> + prevailing->node->local.externally_visible = false;
> + else
> + prevailing->vnode->externally_visible = false;
> + }
> + }
This is executed only with LTO and -fwhole-program, so you would make non-LTO
-fwhole-program noop.
>
> The difference from original code is that when no -fwhole-program specified, the true
> value of externally_visible (from pass_ipa_function_and_variable_visibility)
> will be passed on and not conditionally set to false in pass_ipa_whole_program_visibility.
> But does that matter? Cgraph_externally_visible_p will always return true then.
Without -fwhole-program the visibilities should match, so this is not a
problem, but we need to keep non-LTO -fwhole-program working. It seems that
having specific flag for this case is better than trying to play rather fragile
games with setting/preserving the flag based on compliation mode.
It is useful to know if the symbol is bound from non-LTO object at linktime
also to make hidden symbols to become local when building the final DSO even
without -fwhole-program.
Honza