In an attempt to solve some of the dependency issues when building klibc library I started to do a modular build of klibc library. The priciple is simple. build all sub-directories specified with lib-y := dir/ before the final lib.a But reading "man ar" it was not obvious if: ar cp lib.a dir/lib.a dir2/lib.a file1.o file2.o would produce the desired result. The linux kernel uses lr -r instead, but thats not libraries. I could try it out but thought asking the list could reveal some pratical experiences. Sam
Sam Ravnborg wrote:> In an attempt to solve some of the dependency issues when building klibc > library I started to do a modular build of klibc library. > > The priciple is simple. build all sub-directories specified with > lib-y := dir/ before the final lib.a > > But reading "man ar" it was not obvious if: > ar cp lib.a dir/lib.a dir2/lib.a file1.o file2.o > > would produce the desired result. > > The linux kernel uses lr -r instead, but thats not libraries. > I could try it out but thought asking the list could reveal some > pratical experiences. > > SamIt can be done with "MRI scripts" (described in ar.info). Something like the following should do the job: ar -M << EOF CREATE lib.a ADDLIB dir/lib.a ADDLIB dir2/lib.a SAVE EOF Luc Van Oostenryck
Sam Ravnborg wrote:> In an attempt to solve some of the dependency issues when building klibc > library I started to do a modular build of klibc library. > > The priciple is simple. build all sub-directories specified with > lib-y := dir/ before the final lib.a > > But reading "man ar" it was not obvious if: > ar cp lib.a dir/lib.a dir2/lib.a file1.o file2.o > > would produce the desired result. > > The linux kernel uses lr -r instead, but thats not libraries. > I could try it out but thought asking the list could reveal some > pratical experiences. >It doesn't. ar is an archiver, kind of like zip (but without compression), and still has braindamage from trying to behave as if anyone still used it that way. One of those braindamages is that the above command line will add dir/lib.a and dir2/lib.a as members, instead of their contents; it doesn't "flatten". And no, the linker and binutils don't understand this kind of nested libraries. -hpa
On Sun, Jul 09, 2006 at 07:27:12PM +0200, Luc Van Oostenryck wrote:> > It can be done with "MRI scripts" (described in ar.info). > Something like the following should do the job: > ar -M << EOF > CREATE lib.a > ADDLIB dir/lib.a > ADDLIB dir2/lib.a > SAVE > EOFThanks. But info ar said this was some backward compatibility cruft so I decided to create a file for each directory that lists the .o files then it is quite simple to use ar. Sam
Sam Ravnborg wrote:> On Sun, Jul 09, 2006 at 07:27:12PM +0200, Luc Van Oostenryck wrote: >> It can be done with "MRI scripts" (described in ar.info). >> Something like the following should do the job: >> ar -M << EOF >> CREATE lib.a >> ADDLIB dir/lib.a >> ADDLIB dir2/lib.a >> SAVE >> EOF > > Thanks. But info ar said this was some backward compatibility cruft > so I decided to create a file for each directory that lists the .o files > then it is quite simple to use ar. >Another alternative would be to create a wrapper script for ar which would detect an archive, unpack it, and include the unpacked files. Hacky, though. -hpa