[Fuego] [PATCH 2/2] iperf3: only do static compilation for libiperf

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Wed Aug 22 07:07:05 UTC 2018


> -----Original Message-----
> From: Tim.Bird at sony.com <Tim.Bird at sony.com>
> Sent: Friday, August 17, 2018 7:09 AM
> > -----Original Message-----
> > From: Li, Xiaoming
> > Hi Tim:
> >
> >
> > > -----Original Message-----
> > > From: Tim.Bird at sony.com [mailto:Tim.Bird at sony.com]
> > > Sent: Thursday, August 16, 2018 6:15 AM
> > > To: daniel.sangorrin at toshiba.co.jp; Li, Xiaoming/李 霄鸣;
> > > fuego at lists.linuxfoundation.org
> > > Subject: RE: [Fuego] [PATCH 2/2] iperf3: only do static compilation for
> > libiperf
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Daniel Sangorrin
> > > >
> > > > > -----Original Message-----
> > > > > From: Li Xiaoming
> > > > > Sent: Tuesday, July 3, 2018 4:41 AM
> > > > > To: fuego at lists.linuxfoundation.org
> > > > > Subject: [Fuego] [PATCH 2/2] iperf3: only do static compilation for
> > > > > libiperf
> > > > >
> > > > > Not necessary static libraries will be needed, if we do a completely
> > > > > static compilation. E.g. libc.a.
> > > > >
> > > > > Signed-off-by: Li Xiaoming <lixm.fnst at cn.fujitsu.com>
> > > > > ---
> > > > >  engine/tests/Benchmark.iperf3/fuego_test.sh | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/engine/tests/Benchmark.iperf3/fuego_test.sh
> > > > > b/engine/tests/Benchmark.iperf3/fuego_test.sh
> > > > > index 6876d90..c8c0113 100755
> > > > > --- a/engine/tests/Benchmark.iperf3/fuego_test.sh
> > > > > +++ b/engine/tests/Benchmark.iperf3/fuego_test.sh
> > > > > @@ -2,7 +2,7 @@
> > > > >  tarball=iperf-3.1.3-source.tar.gz
> > > > >
> > > > >  function test_build {
> > > > > -    LDFLAGS=-static ./configure --host=$HOST --prefix=$(pwd)/build
> > > > > +    ./configure --host=$HOST --prefix=$(pwd)/build
> > > > > + --enable-shared=no
> > > > >      make
> > > > >  }
> > > > >
> > > > > --
> > > > > 2.7.4
> > > >
> > > > Thanks Li.
> > > > I asked to the upstream developer[1] and he mentioned that the next
> > > > options were correct. Could you try them and resend?
> > > >
> > > > --enable-static --disable-shared
> > >
> > > FWIW, I tried these options, and I still get dynamically-linked binaries.
> > >
> > > root at timdesk:/fuego-rw/buildzone# ls *iperf3*/src/iperf3 | xargs file |
> > grep
> > > -v default
> > > Benchmark.iperf3-debian-armhf/src/iperf3:                ELF 32-bit LSB
> shared
> > > object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-
> > > linux-armhf.so.3, for GNU/Linux 3.2.0,
> > > BuildID[sha1]=ac728b1687158229815b8b3458ff266db488d1b4, not stripped
> > > Benchmark.iperf3-poky-aarch64/src/iperf3:                ELF 64-bit LSB
> > executable,
> > > ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-
> > > aarch64.so.1, for GNU/Linux 3.14.0,
> > > BuildID[sha1]=c33fde2910981fb08f77b41e9e98631c953d5cd4, not stripped
> > > Benchmark.iperf3-x86_64/src/iperf3:                      ELF 64-bit LSB
> executable,
> > > x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-
> > > 64.so.2, for GNU/Linux 2.6.32,
> > > BuildID[sha1]=f1759fb987f125edbc640a36622bae3ad0c67b80, not stripped -
> > -
> > > Tim
> > >
> > > Note that I get dynamically linked binaries using any of the configure lines
> > > that were in previous and current versions of fuego_test.sh.
> >
> > Sorry, I am not a  expert of compile theory.
> 
> I'm not either.  I was basically just poking about trying stuff to see if
> it made a difference with the toolchains for my boards.
> 
> > Do u mean that u build with  static   option and  also  got a  dynamically
> linked
> > binarie ?
> 
> Yes.  I have built with the following combinations:
> 
> 1) ./configure --host=$HOST --prefix-$(pwd)/build --disable-shared
> 2) ./configure --host=$HOST --prefix-$(pwd)/build --enable-static --disable-shared
> 3) LDFLAGS=-static ./configure --host=$HOST --prefix-$(pwd)/build
> 4) LDFLAGS=-static ./configure --host=$HOST --prefix-$(pwd)/build
> --enable-static --disable-shared
> 
> 
> These all resulted in iperf3 being a program that dynamically linked to libm and libc.
> 
> Maybe I'm missing something, and the intent is just to statically link to libperf, and
> still dynamic link to libm and libc.   But I was expecting the entire binary to be static
> (and thus be something that could be put into a shared binary repository for Fuego
> users).
> 
> I think Daniel first raised this issue, so maybe he knows more.

Sorry for the late response, I was on summer vacation.

The intent was to produce a static file but depending on the build environment sometimes a dynamic binary is created (e.g.: my arm toolchains create a static file but my x86_64 toolchain creates a dynamic file). Having said that, when a dynamic binary is created the --disable-shared flag still limits the dynamic dependencies to only libm and libc (in other words, only libiperf is linked statically).

To force libm and libc to be statically compiled, we can add the -all-static
flag at src/Makefile.in. 

-    $(iperf3_LDFLAGS) $(LDFLAGS) -o $@
+    $(iperf3_LDFLAGS) $(LDFLAGS) -all-static -o $@

However, this warning appears:
"Using getaddrinfo in statically linked applications requires at runtime the shared libraries from the glibc version used for linking".

It seems that there are some limitations when you compile libc statically
https://www.akkadia.org/drepper/no_static_linking.html

Thanks,
Daniel



More information about the Fuego mailing list