Check for undefined symbols at link-time
Description
Taken from the commit message:
By default no check for undefined symbols is performed at link-time for
shared libraries. This is a sane default since the environment can be
different at link-time and run-time. However, in our case, the proper
functioning of our system relies only on shared objects. They can be
considered as our binaries.
This commit sets the -Wl,--no-undefined flag if the compiler and
linker support it.
Enabling this new check, triggered an issue with undefined symbols in
the AMC13Manager which missed some dependencies: Boost.System and
uhal::log The missing dependencies have been added to both the build
system and source code.
Related Issue
Fixes #29 (closed).
How Has This Been Tested?
The code still compiles; no change in the output binaries are expected.
Removing the definition of an random function triggers a (more or less) explicit error:
[lpetre@gem904daq04 cmsgemos]$ cmake3 --build _build
[2/2] Linking CXX shared library gemcalibration/libgemcalibration.so
FAILED: gemcalibration/libgemcalibration.so
: && /opt/rh/devtoolset-8/root/usr/bin/c++ -fPIC -DGIT_VERSION=\"e22ed8a\" -DGEMDEVELOPER=\"lpetre\" -flto -fno-fat-lto-objects -Wl,--no-undefined -shared -Wl,-soname,libgemcalibration.so -o gemcalibration/libgemcalibration.so gemcalibration/CMakeFiles/gemcalibration.dir/src/version.cpp.o gemcalibration/CMakeFiles/gemcalibration.dir/src/Calibration.cpp.o gemcalibration/CMakeFiles/gemcalibration.dir/src/CalibrationWeb.cpp.o -L/opt/xdaq/lib -Wl,-rpath,/afs/cern.ch/user/l/lpetre/GEM/cmsgemonline/cmsgemos/_build/gembase:/afs/cern.ch/user/l/lpetre/GEM/cmsgemonline/cmsgemos/_build/gemutils:/opt/xdaq/lib: gembase/libgembase.so gemutils/libgemutils.so -lxdaq -lxdata /opt/xdaq/lib/libmimetic.so -lxgi -llogudpappender -llogxmlappender -lpeer -lxoap -lconfig -lxcept -ltoolbox /opt/xdaq/lib/libcgicc.so -lpthread /opt/xdaq/lib/libasyncresolv.a /usr/lib64/libuuid.so /opt/xdaq/lib/libxerces-c.so /opt/xdaq/lib/liblog4cplus.so && :
/tmp/lpetre/cc7yfCFF.ltrans0.ltrans.o: In function `gem::calibration::Calibration::Calibration(xdaq::ApplicationStub*)':
<artificial>:(.text+0x8075): undefined reference to `gem::calibration::Calibration::setCalType(xgi::Input*, xgi::Output*)'
/tmp/lpetre/cc7yfCFF.ltrans0.ltrans.o: In function `gem::calibration::Calibration::Calibration(xdaq::ApplicationStub*)':
<artificial>:(.text+0xb9c6): undefined reference to `gem::calibration::Calibration::setCalType(xgi::Input*, xgi::Output*)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
-
My code follows the code style of this project. -
My change requires a change to the documentation. -
I have updated the documentation accordingly. -
I have read the CONTRIBUTING document. -
I have added tests to cover my changes. -
All new and existing tests passed.