https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95622
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> --- I think there are three related issues here: (a) force_output = 1 prevents at least one optimization (b) If not using force_output = 1, we need to find another way to tell the compiler that the variable is actually needed – even if unused. (cf. comment 1) (c) There are missed optimizations related to offloading – both before streaming-out the offload table and afterward. * * * (See also PR 92029 for another test case fixed – but I think we cannot learn much from that one as there the optimization happens before the stream out.) (In reply to Thomas Schwinge from comment #2) > We'll need to analyze if we need to restore that functionality now, or if > it's OK to lose that optimization. Fixing "now" is only possible by reverting the patch. But given that the patch fixes a wrong code generation (link errors or ICE) and comes after the first optimizations have been done (before LTO streamout), I would not undo it. – Hence: not fixing now but the more optimizations the better :-) [In particular, my impression is that artificial, read-only static variables do not need to be linked between host and device as one cannot really take their address and they cannot be updated or changed.]