http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53068

             Bug #: 53068
           Summary: collect2 breaks link order control
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: igod...@pacbell.net


Created attachment 27214
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27214
generated linker script

Not sure which heading collect2 goes under; placed in c++ heading by default.

We use a linker script to control static initialization order. We manually
maintain files that give intra- and inter-project dependencies from which a
tool produces a partial ordering file that is added to each project library.
Before linking, another tool collects the partial order files of all libraries
referenced on the link command line to produce a global partial order for the
program being linked. It then takes the default linker script that gcc uses and
textually modifies it with linker commands that reflect the partial order. We
then pass the modified script to gcc on the gcc linker command line, which
invokes collect2 and the system linker in the normal way.

For this to work we depend on the collect2 priority sort defaulting to the file
order that the system gives it on the first link pass. That is, we depend on
the sort being stable in the absence of program-specified priorities, which we
do not use (priority is impractical for large developments that incorporate
third-party binaries; our system uses local relative dependency rather than
trying to maintain global absolute priority).

This has worked for a decade, but breaks in 4.7. Because we are using the same
linker I conclude that there have been changes in collect2, most likely the
introduction of an unstable sort.

I will attach a representative script generated by our system.

Reply via email to