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: Static Build on armv7
From: Michael Davidsaver via Tech-talk <tech-talk at aps.anl.gov>
To: Florian Feldbauer <florian at ep1.ruhr-uni-bochum.de>
Cc: tech-talk at aps.anl.gov
Date: Thu, 31 Mar 2022 14:10:34 -0700
On 3/31/22 01:50, Florian Feldbauer wrote:
...
$ cat configure/os/CONFIG.linux-arm.linux-arm
# CONFIG.linux-arm.linux-arm
#
# Definitions for native linux-arm builds
# Sites may override these definitions in CONFIG_SITE.linux-arm.linux-arm
#-------------------------------------------------------

# Include common gnu compiler definitions
include $(CONFIG)/CONFIG.gnuCommon
$ cat configure/os/CONFIG.linux-x86.linux-x86
#  CONFIG.linux-x86.linux-x86
#
# Definitions for linux-x86 host - linux-x86 target builds
# Sites may override these definitions in CONFIG_SITE.linux-x86.linux-x86
#-------------------------------------------------------

# Include common gnu compiler definitions
include $(CONFIG)/CONFIG.gnuCommon

STATIC_LDFLAGS_YES= -Wl,-Bstatic
STATIC_LDFLAGS_NO=
STATIC_LDLIBS_YES= -Wl,-Bdynamic
STATIC_LDLIBS_NO=


Adding those 4 last rows from CONFIG_SITE.linux-x86.linux-x86 to CONFIG_SITE.linux-arm.linux-arm solved my issue.
Now static build also works on armv7.

I think you are correct that passing both '-static' and '-Wl,-Bdynamic'
is a contradiction, which GCC unfortunately does not flag as an error.

Do you want to formulate this change as a pull request?

https://github.com/epics-base/epics-base/


I can't see exactly where, but "/lib/ld.so.1" must be used as a default
when no "-dynamic-linker ..." is passed to "ld".  The valid values
for ARM are given here:

https://github.com/gcc-mirror/gcc/blob/0abc1cbad1687a887d754917927b6023e4dba3ce/gcc/config/arm/linux-eabi.h#L59-L65

fyi. these names actually appears in GCC's generated spec file(s), where
it can presumably be overwritten, if you understand spec files better than
I do...

https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html

gcc -dumpspecs|grep dynamic-linker

As I understand it, on amd64 it looks like all of the "-dynamic-linker ..."
are wrapped in a conditional "%{!static: ...}".  So '-static' prevents
any from being passed to "ld".


Cheers,
Florian



Alternately, you could path Base to remove references to "-Wl,-Bdynamic",
which would result in a fully static executable (with the limitations
which this implies).

/usr/bin/g++ -o antelope -static -L/epics/base/lib/linux-arm -Wl,-rpath,/epics/base/lib/linux-arm          -rdynamic closure.o error.o lalr.o lr0.o antelope.o mkpar.o output.o reader.o skeleton.o symtab.o verbose.o warshall.o -Wl,-Bdynamic  -lpthread   -lreadline -lm -lrt -ldl -lgcc

However, you may later encounter strange linker errors and/or crashes
if object code from different, somewhat incompatible, toolchains are
being linked together.  So I would encourage you to investigate the
toolchain(s) first.


Cheers,
Florian


Am 30.03.2022 um 17:47 schrieb Michael Davidsaver:
On 3/30/22 07:15, Florian Feldbauer via Tech-talk wrote:
Hey all,

we use docker images to easily deploy our IOCs for our detector control system.
The images are build for amd64, arm64/aarch64 and armv7.

To reduce the size of those images, I recently switched from dynamic to static linking by adding the line
 >      && echo "STATIC_BUILD=YES" >> configure/CONFIG_SITE.local \
to our Dockerfile.

When compiling base7 for amd64 and aarch64 this is working just fine, but I get an error on arm/v7:

#0 189.7 Installing created executable /epics/base/bin/linux-arm/antelope
#0 190.1 /epics/base/bin/linux-arm/antelope -bparse -l -d ../flex/parse.y
#0 190.1 /usr/lib/ld.so.1: No such file or directory
#0 198.7 Expanding ../libComVersion.h@ to ../O.Common/libComVersion.h

I investigated the issue a bit closer and found the following:

root@195e454a8580:/epics/src/base# ldd /epics/base/bin/linux-arm/antelope
  linux-vdso.so.1 (0x7ef10000)
  libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76e71000)
  /usr/lib/ld.so.1 => /lib/ld-linux-armhf.so.3 (0x76f70000)

It looks like "STATIC_BUILD=YES" was ignored.

root@195e454a8580:/epics/src/base# ls /usr/lib/ld.so.1
ls: cannot access '/usr/lib/ld.so.1': No such file or directory

For some reason antelope gets linked against /usr/lib/ld.so.1 on armv7 but this file does not exist.
Does anyone know what causes this issue?

It would help if you could attach, or post somewhat, the complete
output of a clean 'make'.

Also the output of:

readelf -aW /epics/base/bin/linux-arm/antelope



Cheers,
Florian





References:
Static Build on armv7 Florian Feldbauer via Tech-talk
Re: Static Build on armv7 Michael Davidsaver via Tech-talk
Re: Static Build on armv7 Florian Feldbauer via Tech-talk
Re: Static Build on armv7 Michael Davidsaver via Tech-talk
Re: Static Build on armv7 Florian Feldbauer via Tech-talk

Navigate by Date:
Prev: Re: caQtDM caCamera widget not rendering images Mark Rivers via Tech-talk
Next: asyn trace masks on modbus reconnect 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: Static Build on armv7 Florian Feldbauer via Tech-talk
Next: caQtDM caCamera widget not rendering images Ashish Sharma 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, 14 Sep 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·