duplicate symbols in a package?

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Wed, 14 Aug 2002 12:28:20 +0100

Hi GHC users,

I am trying to build a package (HaXml) for ghc that will also work in GHCi.
I followed the instructions in the manual, to convert the .a file to a .o:

    ld -r --whole-archive -o HSHaXml.o libHSHaXml.a

and installed, ran ghc-pkg, etc.  However, now when I start up GHCi, it throws
an error:

    $ ghci -package HaXml
       ___         ___ _
      / _ \ /\  /\/ __(_)
     / /_\// /_/ / /  | |      GHC Interactive, version 5.02.2, for Haskell 98.
    / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
    \____/\/ /_/\____/|_|      Type :? for help.
    Loading package std ... linking ... done.
    Loading package lang ... linking ... done.
    Loading package concurrent ... linking ... done.
    Loading package posix ... linking ... done.
    Loading package util ... linking ... done.
    Loading package data ... linking ... done.
    Loading package HaXml ... 
    GHCi runtime linker: fatal error: I found a duplicate definition for symbol
    whilst processing object file
    This could be caused by:
       * Loading two different object files which export the same symbol
       * Specifying the same object file twice on the GHCi command line
       * An incorrect `package.conf' entry, causing some object to be
         loaded twice.
    GHCi cannot safely continue in this situation.  Exiting now.  Sorry.

Indeed, running nm on the HSHaXml.o file shows that there are numerous
symbols with multiple definitions.  Here are just some of them:

    r13_closure,  r13_entry,  r13_info,  r13_srt,
    r19_closure,  r19_entry,  r19_info,  r19_srt,
    r1D_closure,  r1D_entry,  r1D_info,  r1D_srt,
    r1J1_closure, r1J1_entry, r1J1_info, r1J1_srt,
    r1b_closure,  r1b_entry,  r1b_info,  r1b_srt,
    r1l_closure,  r1l_entry,  r1l_info,
    r1p_closure,  r1p_entry,  r1p_info,
                  s1JM_entry, s1JM_info,
                  s1JZ_entry, s1JZ_info,
                  s1Le_entry, s1Le_info,

Any ideas what these are, and how I can avoid them?