libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replacing ar with libtool


From: Simon Richter
Subject: Re: Replacing ar with libtool
Date: Sat, 10 Aug 2024 22:14:08 +0900
User-agent: Mozilla Thunderbird

Hi,

On 8/10/24 20:08, Navin P wrote:

When i run make -j1 i find all the object files  libx.a but when i do make -j8 i find some missing object files inside libx.a.

Typically you'd generate all objects first, then archive them in a single invocation. This is I/O bound anyway, so you're not losing much from being single-threaded, and rerunning Make after a partial/failed build knows exactly which objects are missing.

Consider:

libx.a: a.o b.o
        $(AR) cru $@ $^

.c.o:
        $(CC) -o $@ -c $<

If you build a.o and add it to libx.a, then the next invocation of Make will compare the timestamp of libx.a against the timestamp of b.c, because b.o is an intermediate object, so the assumption is that it does not exist because it was successfully built and consumed by the only rule that references it.

This is safe only if the library is created last, i.e. will always have a timestamp that is later than any source files that go into it, so you cannot create an intermediate version of the library.

Libtool supports "convenience libraries", which are unpacked and repacked automatically to merge all objects to a single large library. That takes a bit of extra time in a build and cannot be parallelized either, but in large projects it makes the Makefile.am a little more readable.

   Simon

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]