vasi / squashfuse

FUSE filesystem to mount squashfs archives
Other
288 stars 66 forks source link

Split squashfuse_ll into a lib and executable #59

Closed haampie closed 3 years ago

haampie commented 3 years ago

This makes it easier for people to statically link squashfuse_ll into their application, which can in turn be used to more easily ship self-exectracting binaries (e.g. facebook xar or appimage)

chipturner commented 3 years ago

Is it easy to make it so the squashfuse binary links against squashfuse_ll statically rather than dynamically? Having a more portable, self-contained executable is nicer (probably no practical perf benefit but there's that, too). Automake is... challenging... so it may be nontrivial. But if it's easy I think I'd prefer that.

haampie commented 3 years ago

I was wondering the same thing, but didn't bother looking into it yet. Right now we have

bin/{squashfuse,squashfuse_ll} and lib/{libsquashfuse,libsquasfuse_ll}.{a,so}

what you mean is to statically link lib/ into bin/, right?

Then the only dynamically linked libs are likely libfuse and compression libs? I don't think we can statically link other libs, since libfuse is LGPL and squashfuse BSD (otherwise we'd have to make squashfuse GPL too).

Not very experienced with autotools, but to be honest I don't hate it -- in fact it's better than cmake when it comes to generating static AND shared libraries (and even cross compilation out of the box?).

haampie commented 3 years ago

Hm, I guess it should just not link at all, but use the object files.

haampie commented 3 years ago

I think I've figured it out. For what it's worth, the executables and libs can be really tiny:

$ autoreconf -fi
$ ./configure
$ make CFLAGS=-Os DESTDIR=$PWD/install install -j
$ libtree install/usr/local/bin/squashfuse
squashfuse
├── liblzma.so.5 [ld.so.conf]
├── liblz4.so.1 [ld.so.conf]
├── libzstd.so.1 [ld.so.conf]
└── libfuse3.so.3 [ld.so.conf]

$ libtree install/usr/local/bin/squashfuse_ll 
squashfuse_ll
├── liblzma.so.5 [ld.so.conf]
├── liblz4.so.1 [ld.so.conf]
├── libzstd.so.1 [ld.so.conf]
└── libfuse3.so.3 [ld.so.conf]

$ ls install/usr/local/lib/
libsquashfuse.a  libsquashfuse.la  libsquashfuse_ll.a  libsquashfuse_ll.la  libsquashfuse_ll.so  libsquashfuse_ll.so.0  libsquashfuse_ll.so.0.0.0  libsquashfuse.so  libsquashfuse.so.0  libsquashfuse.so.0.0.0  pkgconfig

$ du -sh install/usr/local/bin/* install/usr/local/lib/libsquashfuse.so.0.0.0 install/usr/local/lib/libsquashfuse_ll.so.0.0.0 
40K     install/usr/local/bin/squashfuse
56K     install/usr/local/bin/squashfuse_ll
48K     install/usr/local/lib/libsquashfuse.so.0.0.0
68K     install/usr/local/lib/libsquashfuse_ll.so.0.0.0
chipturner commented 3 years ago

Looks good!