Why ar doesn't call ranlib on Mac?
Peter O'Gorman
peter at pogma.com
Mon Mar 9 06:59:43 PDT 2009
Alexy Khrabrov wrote:
> Peter --
>
> On Wed, Mar 4, 2009 at 10:18 AM, Peter O'Gorman <peter at pogma.com> wrote:
>> Alexy Khrabrov wrote:
>>> In building various Linux things from source on Mac, I've run into the
>>> "archive has no table of contents" problem several times. The fix is
>>> invariably to go and stick ranlib after each ar.
>> What version of Mac OS X/Xcode are you using? ar, since Mac OS X 10.4
>> does ranlib the archive. I filed a bug at the time asking for the -S
>> flag to turn off this behavior to speed up creating an archive
>> incrementally.
>>
>> http://www.opensource.apple.com/darwinsource/10.5.6/cctools-667.3/ar/ar.c
>
> In fact, I checked and see that ranlib is not being run!
My 10.5 system is currently unavailable, but to prove that ranlib is
being run on 10.4/ppc:
$ sudo -s
Password:
# ls -l /usr/bin/ranlib
lrwxr-xr-x 1 root wheel 7 Mar 9 08:38 /usr/bin/ranlib -> libtool
# rm /usr/bin/ranlib
# vim /usr/bin/ranlib
# cat /usr/bin/ranlib
#!/bin/sh
echo "ranlib $@"
# chmod +x /usr/bin/ranlib
# exit
$ rm -f libf.a; ar cr libf.a f.o
ranlib -q libf.a
$ rm -f libf.a; ar crs libf.a f.o
ranlib -f libf.a
$ sudo -s
# rm /usr/bin/ranlib
# ln -s libtool /usr/bin/ranlib
# ls -asl /usr/bin/ranlib
8 lrwxr-xr-x 1 root wheel 7 Mar 9 08:45 /usr/bin/ranlib -> libtool
# exit
$ xcodebuild -version
Component versions: DevToolsCore-757.0; DevToolsSupport-733.0
Note that if your archive has no symbols it is not really useful anyway.
Is it supposed to be empty? Are all the global symbols common? If so you
need to run ranlib with -c.
Also note, if you look at the bottom of the ld manpage on 10.5, you will
see a note that ld no longer checks timestamps so that "out of date"
errors should be a thing of the past.
If you find that ranlib is indeed not being run on 10.5 (as I said, I
can not currently check 10.5), then ensure that your COMMAND_MODE
environment variable is unset and file a bug at
http://bugreporter.apple.com.
(btw, a quick way to check if ranlib has been run is to check for a
__SYMDEF SORTED file in the archive with ar t).
Hope this is some help,
Peter
--
Peter O'Gorman
http://pogma.com
More information about the macports-users
mailing list