Re: lto: from insert_attributes to file_end?

Sam James via Gcc <[email protected]>
Newsgroups gmane.comp.gcc.devel
Organization Gentoo
Message-ID <[email protected]>
Georg-Johann Lay via Gcc <[email protected]> writes:

> Am 05.05.26 um 19:05 schrieb Richard Biener:
>> On Tue, May 5, 2026 at 5:41 PM Georg-Johann Lay via Gcc <[email protected]> wrote:
>>>
>>> In the avr backend there is a static variable avr_no_call_main_p that
>>> is set in TARGET_INSERT_ATTRIBUTES and used in TARGET_ASM_FILE_END.
>>>
>>> This works as expected in non-LTO compilations, with LTO however,
>>> TARGET_INSERT_ATTRIBUTES runs in cc1[plus] but TARGET_ASM_FILE_END
>>> is run by lto1, hence the variable is not set as expected.
>>>
>>> What's the recommended way to handle such a situation?
>> Without looking too closely I assume there's an actual attribute
>> somewhere
>> (on the main function decl?).  Instead of using a global variable you'd
>> check for the presence of the attribute.  Now - the question is whether
>> the TARGET_ASM_FILE_END behavior is only required in the TU with
>> the main() definition?  In that case this should work.
>
> What works is to attach a new attribute to main when the conditions are
> right, then check for that attribute in, say,
> TARGET_DECLARE_FUNCTION_NAME and set a variable accordingly, and then
> check for that var in TARGET_ASM_FILE_END.
>
> What's a bit ugly is that it requires a new target attribute that's only
> for internal usage and should not to be set by the user.  Maybe not
> document it is okay then.
>
> Is there some policy for such internal-use-only function attributes?

I believe we do " name".

>
> Johann
>
>> I see you emit a special symbol conditional so what you can also do is
>> create that as a global variable in the symbol table and rely on the middle-end
>> to output it.
signature.asc (application/pgp-signature, 418 B)
-----BEGIN PGP SIGNATURE-----

iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmn6UCUbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx
QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkJUH
AQDgpAnbYRl1Ts2U55gLltB1MM4bhwXuQMZd4aTFv+25LwD/XxJyeaV+dS/dk5fo
L+qVWfZl4JaUId8mER6ngr4nUQI=
=2OQh
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.