------- Comment #12 from davek at gcc dot gnu dot org  2010-01-04 15:42 -------
COMMON symbols don't cause members to be pulled in from library archives.  You
can omit "-L. -lex" from the final link altogether and get the same result:
it's unused.  So the reference from bug.o to _jindx2 doesn't cause the library
archive member to be drawn into the final link.

With g77, there's this additional undefined symbol _juinit2_ in bug.o, which is
not common, and hence causes the libex.a(juinit2.o) member to be drawn into the
final link, at which time the explicit definition of _jindx2 overrides the
common definition.  gfortran doesn't generate any reference to _juinit2_ when
it is used to compile bug.f, so there is nothing left to pull the archive
member into the final link.

The reference to _juinit2_ that g77 generates while compiling bug.f but
gfortran does not generate has a label associated with it that suggests very
strongly that g77 was aware of the problem that common symbols don't pull in
lib archive members and uses this reference to an associated non-common symbol
deliberately to solve the problem:

        .file   "bug.f"
        .data
        .align 4
___g77_forceload_0.0:
        .long   _juinit2_

The "forceload" bit seems highly suggestive.  Does gfortran need to adopt this
part of g77's mechanism?


-- 


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

Reply via email to