Henrik Nilsson wrote:

> [...] Well, ar does not support directories anyway, so if the objective
> here is to build a link library, the leaf names had better be distinct.
> (At least GNU make does seem to allow putting two object files with the
> same name into a link library if done as a single operation, but my guess
> is that doing so is asking for trouble.) [...]

Allowing leaf names to be equal is essential for the whole hierarchical
module business! Otherwise you would get evil non-local interactions
between different modules. And in practice it doesn't seem to be a problem
for ar/ld, because the base package and the GLUT package have lots of
examples for equal leaf names (see below). I'm not sure how ar/ld handle
this exactly, but I guess it works because of an index in the archive. From
the Linux ar man page:

       ...
       ar creates an index to the symbols defined in  relocatable
       object  modules  in the archive when you specify the modi
       fier s.  Once  created,  this  index  is  updated  in  the
       archive  whenever  ar makes a change to its contents (save
       for the q update operation).   An  archive  with  such  an
       index  speeds  up  linking to the library, and allows rou
       tines in the library to call each other without regard  to
       their placement in the archive.

       You  may  use nm -s or nm --print-armap to list this index
       table.  If an archive lacks the table, another form of  ar
       called ranlib can be used to add just the table.
       ...

Newer ar versions to add this index automatically, other need an explicit
ranlib. The GHC installation process takes care of that automatically.

Cheers,
   S.

---------------------------------------------------------------------------
Leaf name "clashes" in the current GHC version:

libHSGLUT.a:
   Graphics.UI.GLUT.Window
   Graphics.UI.GLUT.Callbacks.Window

libHSbase.a:
   Data.Array
   Foreign.Marshal.Array

   Data.Array.Base
   GHC.Base

   Data.Char
   Text.ParserCombinators.Parsec.Char

   Control.Monad.Error
   Foreign.C.Error
   Foreign.Marshal.Error
   System.IO.Error
   Text.ParserCombinators.Parsec.Error

   Control.Exception
   GHC.Exception

   Data.Array.IO
   GHC.IO
   System.IO

   Data.Int
   GHC.Int

   Control.Monad.ST.Lazy
   Data.STRef.Lazy

   Control.Monad.List
   Data.List
   GHC.List

   GHC.Posix
   Text.Regex.Posix

   Foreign.Ptr
   GHC.Ptr

   GHC.Read
   Text.Read

   Data.STRef
   GHC.STRef

   Control.Monad.ST
   Data.Array.ST
   GHC.ST

   GHC.Show
   Text.Show

   Data.Array.Storable
   Foreign.Storable
   GHC.Storable

   Control.Monad.ST.Strict
   Data.STRef.Strict

   Foreign.C.Types
   System.Posix.Types

   Debug.QuickCheck.Utils
   Foreign.Marshal.Utils

   GHC.Weak
   System.Mem.Weak

_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to