https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91596

            Bug ID: 91596
           Summary: IPA cdtor merging should preserve link file ordering
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

See https://bugzilla.suse.com/show_bug.cgi?id=1148217 where using -flto changes
the order of global ctor invocations, breaking programs relying on (undefined)
order of executing them for different TUs (and likely being lucky with link
file order).

IMHO using -flto should not change the order of ctor/dtor invocations and thus
should preserve linker behavior (which we simply assume concatenating in
linker argument order or reverse which we could expose via a flag or try
to detect at configure time).

ipa_cdtor_merge via compare_dtor sorts after DECL_{INIT,FINI}_PRIORITY
and then after DECL_UID where the latter should be changed to first
order after the command-line order of files the definitions come from.

Reply via email to