EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Issues building statically linked IOC
From: Érico Nogueira Rolim via Tech-talk <tech-talk at aps.anl.gov>
To: Mark Rivers <rivers at cars.uchicago.edu>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Tue, 18 Oct 2022 14:23:54 +0000
On 17/10/2022 20:09, Mark Rivers wrote:
> It should work fine to just set STATIC_BUILD=YES in the CONFIG_SITE file of your IOC application.  I do this all the time.
>
> The resulting binary will be linked statically against all of the EPICS libraries.  However, it will still be linked dynamically against the system libraries.  Here is an example of the ldd output for such an IOC application:
>
> corvette:CARS/bin/linux-x86_64>ldd CARSApp
>          linux-vdso.so.1 =>  (0x00007ffe41ba1000)
>          libusb-0.1.so.4 => /lib64/libusb-0.1.so.4 (0x00007f81871e0000)
>          libuldaq.so.1 => /usr/local/lib/libuldaq.so.1 (0x00007f8186c67000)
>          libusb-1.0.so.0 => /lib64/libusb-1.0.so.0 (0x00007f8186a4e000)
>          libnet.so.1 => /lib64/libnet.so.1 (0x00007f8186834000)
>          libpcap.so.1 => /lib64/libpcap.so.1 (0x00007f81865f3000)
>          libboost_system.so.1.53.0 => /lib64/libboost_system.so.1.53.0 (0x00007f81863ef000)
>          libX11.so.6 => /lib64/libX11.so.6 (0x00007f81860b1000)
>          libXext.so.6 => /lib64/libXext.so.6 (0x00007f8185e9f000)
>          libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8185c83000)
>          libreadline.so.6 => /lib64/libreadline.so.6 (0x00007f8185a3d000)
>          librt.so.1 => /lib64/librt.so.1 (0x00007f8185835000)
>          libdl.so.2 => /lib64/libdl.so.2 (0x00007f8185631000)
>          libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f8185329000)
>          libm.so.6 => /lib64/libm.so.6 (0x00007f8185027000)
>          libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f8184e11000)
>          libc.so.6 => /lib64/libc.so.6 (0x00007f8184a43000)
>          libudev.so.1 => /lib64/libudev.so.1 (0x00007f818482d000)
>          libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f8184605000)
>          /lib64/ld-linux-x86-64.so.2 (0x00007f81873e6000)
>          libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f81843db000)
>          libcap.so.2 => /lib64/libcap.so.2 (0x00007f81841d6000)
>          libdw.so.1 => /lib64/libdw.so.1 (0x00007f8183f85000)
>          libXau.so.6 => /lib64/libXau.so.6 (0x00007f8183d81000)
>          libattr.so.1 => /lib64/libattr.so.1 (0x00007f8183b7c000)
>          libelf.so.1 => /lib64/libelf.so.1 (0x00007f8183964000)
>          libz.so.1 => /lib64/libz.so.1 (0x00007f818374e000)
>          liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f8183528000)
>          libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f8183318000)
>
> What do you see with ldd?  Are you seeing it linked dynamically against the EPICS libraries, i.e. libca.so, libCom.so, etc.?


That would explain it, then. I expected STATIC_BUILD=YES to get me a 
fully static executable, not just one linked statically against the 
EPICS libraries. Thank you for the explanation.

The reason I am interested in full static linking is, among others, that 
I'm using C++17, which the compiler and libstdc++ from my device don't 
even support, but my development machine does. And linking only 
libstdc++ itself statically is not enough, because glibc on the 
development machine is newer and I'd be linking against newer versioned 
symbols which aren't available on my device.


Do you think it would be interesting for the EPICS build system to 
support fully static builds as well? I could look into contributing that.


>
> Mark
>
>
>
> -----Original Message-----
> From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Érico Nogueira Rolim via Tech-talk
> Sent: Monday, October 17, 2022 1:08 PM
> To: tech-talk at aps.anl.gov
> Subject: Issues building statically linked IOC
>
> Hi!
>
> I'm developing an IOC to be deployed on a device running an older Linux distro, so I'm building the application statically in order to simplify my deployment process, at least until we can update the distro on the device. For this purpose, I'm starting out with epics base 3.15.9, which is giving me some issues.
>
>
> - I added "STATIC_BUILD=YES" to my CONFIG_SITE file
>
> - I ran "make" and the resulting binary was dynamic (per ldd output)
>
> - I removed the contents of "STATIC_LDFLAGS_YES= -Wl,-Bstatic" and "STATIC_LDLIBS_YES= -Wl,-Bdynamic" in
> configure/os/CONFIG.linux-x86.linux-x86 and the build was completed successfully but the resulting binary was still dynamic. Removing only the LDLIBS one lead to a linking error: "/usr/bin/ld: cannot find -lgcc_s"
>
> - I changed "GNU_LDLIBS_YES = -lgcc" to "GNU_LDLIBS_YES = -lgcc -static"
> in configure/CONFIG.gnuCommon
>
> - I removed the contents of "STATIC_LDFLAGS_YES= -Wl,-Bstatic" and "STATIC_LDLIBS_YES= -Wl,-Bdynamic" in configure/os/CONFIG.Common.linuxCommon as well (the content from
> CONFIG.linux-x86 seems to be partly duplicated)
>
> - I added "COMMANDLINE_LIBRARY = READLINE_NCURSES" to CONFIG_SITE and changed "*LDLIBS_READLINE_NCURSES = -lreadline -lncurses" **to "*LDLIBS_READLINE_NCURSES = -lreadline -lncurses -ltinfo"* *in configure/os/CONFIG.Common.linuxCommon (in epics-base) to fix the linking errors due to missing functions from libtinfo (I feel like this should be handled by the build system, but I'm not sure how it would happen)
>
> - the resulting binary was finally static
>
>
> Did I miss something about building a static IOC? Having to mess around in the epics-base files doesn't seem ideal... To cover all my bases, I also tried doing this on epics-base 7.0.7, which required the same steps to spit out a static executable.
>
>
> Thank you,
>
> Érico
>
>
> Aviso Legal: Esta mensagem e seus anexos podem conter informações confidenciais e/ou de uso restrito. Observe atentamente seu conteúdo e considere eventual consulta ao remetente antes de copiá-la, divulgá-la ou distribuí-la. Se você recebeu esta mensagem por engano, por favor avise o remetente e apague-a imediatamente.
>
> Disclaimer: This email and its attachments may contain confidential and/or privileged information. Observe its content carefully and consider possible querying to the sender before copying, disclosing or distributing it. If you have received this email by mistake, please notify the sender and delete it immediately.

References:
Issues building statically linked IOC Érico Nogueira Rolim via Tech-talk
RE: Issues building statically linked IOC Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: Streamdevice discards part of message Brown, Garth via Tech-talk
Next: Modbus TIMEOUT_ALARM John Dobbins via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
Navigate by Thread:
Prev: RE: Issues building statically linked IOC Mark Rivers via Tech-talk
Next: I/O interrupts documentation Pierrick M Hanlet via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
ANJ, 18 Oct 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·