Using --make with -odir and hierarchical modules
Sat, 18 Jan 2003 12:40:49 +0100
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.
Leaf name "clashes" in the current GHC version: