[GHC] #10531: modules that can be linked successfully when compiled with optimizations, fail to link with: multiple definition of `__stginit_ZCMain'

GHC ghc-devs at haskell.org
Tue Jun 16 12:48:09 UTC 2015


#10531: modules that can be linked successfully when compiled with optimizations,
fail to link with: multiple definition of `__stginit_ZCMain'
-------------------------------------+-------------------------------------
        Reporter:  imz               |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.6.1
      Resolution:                    |                Keywords:
Operating System:  Linux             |            Architecture:  x86_64
 Type of failure:  GHC rejects       |  (amd64)
  valid program                      |               Test Case:  attached
      Blocked By:                    |                Blocking:
 Related Tickets:  #437              |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by rwbarton):

 * related:  437 => #437


Comment:

 So the problem here is that while the interface file contains a hash of
 flags like `-main-is`, that hash isn't incorporated into the top-level
 interface hash. When you remove `A.o` (but ''not'' `A.hi`) and then
 rebuild `a`, GHC builds a new `A.o` with the symbols like
 `ZCMain_main_info` but doesn't update the interface file `A.hi` on disk
 accordingly, because it thinks it hasn't changed (the interface hash
 didn't change because it doesn't include the flag hash). Then when
 building `b` GHC sees that the interface file claims that main was not
 A.main when A was built, so GHC sees no need to recompile A.

 Relevant code starts at
 https://github.com/ghc/ghc/blob/bac927b9770ff769128b66d13a3e72bf5a9bc514/compiler/iface/MkIface.hs#L597.
 This looks like an easy fix except there are a few comments there I don't
 understand, like the one about two hashes being returned for the flag hash
 and the one that claims that the ABI hash depends on "flag abi hash".
 (Perhaps they apply to a version of the patch for #437 from before it was
 committed?)

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10531#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list