https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117010
Thomas Schwinge <tschwinge at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |tschwinge at gcc dot gnu.org Status|NEW |ASSIGNED CC| |jakub at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Last reconfirmed|2024-10-08 00:00:00 |2025-3-25 --- Comment #4 from Thomas Schwinge <tschwinge at gcc dot gnu.org> --- Jakub, Richi, C++/offloading question. For the small test case posted here, for 'V<0>::V()' I see in the '-O0' x86_64 host code: .section .text._ZN1VILi0EEC2Ev,"axG",@progbits,_ZN1VILi0EEC5Ev,comdat .align 2 .weak _ZN1VILi0EEC2Ev .type _ZN1VILi0EEC2Ev, @function _ZN1VILi0EEC2Ev: [...] .size _ZN1VILi0EEC2Ev, .-_ZN1VILi0EEC2Ev .weak _ZN1VILi0EEC1Ev .set _ZN1VILi0EEC1Ev,_ZN1VILi0EEC2Ev That is, weak definitions of '_ZN1VILi0EEC2Ev' and its alias '_ZN1VILi0EEC1Ev' (which gets called from 'foo'). Likewise, I see weak definitions, if compiling such code for GCN target: .section .text._ZN1VILi0EEC2Ev,"axG",@progbits,_ZN1VILi0EEC5Ev,comdat .align 4 .weak _ZN1VILi0EEC2Ev .type _ZN1VILi0EEC2Ev,@function _ZN1VILi0EEC2Ev: [...] .size _ZN1VILi0EEC2Ev, .-_ZN1VILi0EEC2Ev .weak _ZN1VILi0EEC1Ev .set _ZN1VILi0EEC1Ev,_ZN1VILi0EEC2Ev ..., so that appears consistent. For nvptx target (with '-malias'), I see: .weak .func _ZN1VILi0EEC1Ev (.param.u64 %in_ar0) { [...] } That is, it directly emits the (used) '_ZN1VILi0EEC1Ev' constructor, instead of emitting '_ZN1VILi0EEC2Ev' and then aliasing the former to the latter. (I'll look into that, to understand why that's happening; maybe it does it this way, because PTX doesn't support weak aliases.) Now, the observation/question: compiling this code for offloading (as originally reported), I see for GCN offloading: .text [...] .type _ZN1VILi0EEC2Ev,@function _ZN1VILi0EEC2Ev: [...] .size _ZN1VILi0EEC2Ev, .-_ZN1VILi0EEC2Ev .set _ZN1VILi0EEC1Ev,_ZN1VILi0EEC2Ev That is, '_ZN1VILi0EEC2Ev' and its alias '_ZN1VILi0EEC1Ev' are now strong instead of weak definitions. Is this expected, or unexpected, and potentially problematic?