Re: Static dar build issues again

Robin Atwood <[email protected]>
Newsgroups gmane.comp.sysutils.backup.dar.support
Message-ID <[email protected]>
On Wed, 19 Jan 2022 19:56:32 +0100
Denis Corbin <[email protected]> wrote:

> Le 19/01/2022 à 15:36, Robin Atwood a écrit :
> > I am trying again to build a statically linked dar binary that I can
> > copy to a backup usb disk and execute from an arbitrary rescue
> > system. I have a Gentoo system but the dar ebuild does not bode
> > well on the subject of static builds so I checked-out the Github
> > 2.7.x branch and built that. I ended up with a 6MB+ binary which
> > was promising since normally it is about 500K. To check if it was
> > completely self-contained I moved the libdar libraries out of the
> > library path and tested:  
> 
> another way to check is to use 'file <path/to/binary>', the size is
> just an indication and when you run to test you did, you must
> explicitely use the path to the binary you want to test. Moreover
> doing the way you did, you may assume a binary is to static because
> it ran once you have removed the dynamic library while another is
> used from a previous installation in another path (/usr/local/lib vs
> /usr/lib for example).
> 
> > 
> > # ../dar_static -l backup-FULL-1642269601 -v
> > ../dar_static: error while loading shared libraries:
> > libdar64.so.6000: cannot open shared object file: No such file or
> > directory  
> 
> I never saw that before!
> obviously the file dar_static is not statically linked... how did you
> obtain it? Did you renamed a dar binary to dar_static?
> 
> > 
> > So even with a static build you still need the library modules?
> > What is the procedure for producing a dar module that works on,
> > say, the SysResCD system?  
> 
> The process to get a statically linked dar binary from its source code
> is first to have installed all the static flavors of the libraries you
> want dar to rely on,
> 
> then run (for example):
> 
>   mkdir -p /tmp/test
>   ./configure --prefix=/tmp/test
> 
> Eventually add --disable-shared and --disable-build-html to speed up
> the process. Once ./configure has completed, check the end of the
> output to see whether everything is aligned to build a statically
> linked dar. Add any missing static library if needed and retry.
> 
> Once all is OK from ./configure stand point, run
> 
>   make -j 4
> 
> Replace 4 by the number of CPU cores you have, or remove '-j 4' for
> single threaded compilation. Then run
> 
>   make install-strip
> 
> This will strip the symbols from the binary and upx compress the
> binary if you had upx available at the time you ran the ./configure
> script.
> 
> dar_static will be present in /tmp/test/bin
> 
> once you have copied out dar_static you can cleanup the rest using
> 
> rm -rf /tmp/test
> 
> (assuming /tmp/test was not present initially).

As I said in my first post I checked-out your code from GitHub. I then
ran misc/init, followed by ./configure and make in the usual way. I
copied the binary from /usr/src/dev/dar-code/src/dar_suite/.libs/dar
and renamed it dar_static on my USB disk. I then ran it using the path
which you can see in my post:
# ../dar_static -l backup-FULL-1642269601 -v

The problem is this:

Building dar_static    : NO  (system does not support static linking,
see note below)

So I followed the note and got:

# grep -e -static -A 2 config.log
configure:15282: checking if gcc static flag -static works
configure:15311: result: yes
configure:15326: checking if gcc supports -c -o file.o
--
configure:20679: checking if g++ static flag -static works
configure:20708: result: yes
configure:20720: checking if g++ supports -c -o file.o
--
configure:29118: g++ -o conftest -g -O2      -static conftest.cpp
-largon2 -lpthread -lattr -lgcrypt -lgpg-error -llz4 -lzstd -llzma
-llzo2 -lbz2 -lz -ldl -lcap  -L/usr/lib64 -lgpgme -lassuan -lgpg-error
-lcurl   >&5
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld:
cannot find -largon2
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld:
cannot find -llz4

So I need to install argon2 and lz4? This is also a problem:

>  is first to have installed all the static flavors of the libraries you
> want dar to rely on

I don't want static libraries in general because my executables would
be enormous and eat up memory. Is there some nifty way of building
static libraries that are only used by dar? I have a Gentoo system.

Thanks
Robin
-- 
----------------------------------------------------------------------
Robin Atwood.

"Ship me somewheres east of Suez, where the best is like the worst,
 Where there ain't no Ten Commandments an' a man can raise a thirst"
         from "Mandalay" by Rudyard Kipling
----------------------------------------------------------------------
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEYp1neJIXHDeWLqAy7++UPB3ap6UFAmHpe3sACgkQ7++UPB3a
p6UXYRAAmppb2S4ucgDw3WKGGd1rSaQWSLnMa4YBFc2eQUB+LS3zUfsqTqxKCR4W
7GIclIl8oEIgizHRFq2/+VGN0fO7Z3jPeCkwZL3uES43P+AAsyV4IE0zXXrRMHPh
ECBT6RtdPBDb/rYh54VB+wwuwo0NE2UCWBB55rovUSAEerXlqjTLh3MTDNUqOWit
QpkOMb/Vr8StrylN/KKADtsTmLrn0fnPA/rRDghRouazWDizKPGZA8Zh1OcWyN2l
6jWxb/6tScdcxkaUynW2CxALfsoPcDo4xg4gfhtxNcU4gRqPy27oAuC7YppYvaBm
EJEKFImhl0/oQhijDe2y6p/RHcRCf9miMTY2DDWSsQXRGBRZTg1MOFat58APLzRT
G3I4+FVUPhQBnNiR4gh6ZUOECqGM1d2JGcX36YzFNL5U+5txBjse4pgQOe7rzFjl
y19sZZl9HqzEEkZcJVpYp6lPuYJoKJ5Ne3CC/KIW6MpAnN56NM8G3WDlS9C7RZt4
oalGLG5NwYD7s4sfb7VJxjURlW/KEiJbx38z4b6Of0pETny7ll43WSFk+w32xZPf
ozWaF9PRaJFIfjSKDQhBLO7WeJnoQOk0jfuueMj2qL/q4wx/mfLYrLCX2Q8XoBS4
SL4vKdD/78lJdTr9CxSoKykF33VWwINY2WNYyJRnZ84jKn5y3go=
=ycQf
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.