lto: from insert_attributes to file_end?

Project / Subsystem

gcc / lto

Date

2026-05-05

Proposer

Georg-Johann Lay <avr@gjlay.de>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Need to find a way to share state between different stages of the LTO compilation process.
  • Consider alternatives to static variables for storing state.
  • Potential performance impact of different state sharing mechanisms.

All attributes

project
gcc
subsystem
lto
patch_id
discussion_id
63787b08-10ac-4200-af5c-433de283d2b8@gjlay.de
source_type
public_inbox
title
lto: from insert_attributes to file_end?
headline
Lto: How to handle static variables in LTO compilations?
tldr
The avr backend uses a static variable set in TARGET_INSERT_ATTRIBUTES and used in TARGET_ASM_FILE_END, but this doesn't work in LTO compilations. The author…
proposer
Georg-Johann Lay <avr@gjlay.de>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Need to find a way to share state between different stages of the LTO compilation process.
  • Consider alternatives to static variables for storing state.
  • Potential performance impact of different state sharing mechanisms.
series_id
series_role
standalone
series_parts
[]
tags
  • gcc
  • lto
  • avr
  • backend
  • static variable
bugzilla_url
date
2026-05-05T00:00:00.000Z

lto: from insert_attributes to file_end?

The avr backend defines a static variable, avr_no_call_main_p, in TARGET_INSERT_ATTRIBUTES and uses it in TARGET_ASM_FILE_END. This works for non-LTO compilations, but in LTO, TARGET_INSERT_ATTRIBUTES runs in cc1[plus] while TARGET_ASM_FILE_END runs in lto1, so the variable is not set as expected. The author is asking for the recommended way to handle this issue.