cmssw
cmssw copied to clipboard
IBs with --as-needed flag and CondFormatsDataRecord
Hi,
Yesterday we have built an IB where we pass -Wl,--as-needed
linker flag to not link any libraries which are not explicitly needed. IB itself has built without any build/link errors but all relvals/unit-tests failed due to errors like [a]. Looks like in this case libCondFormatsDataRecord.so
was needed . LD_PRELOAD=libCondFormatsDataRecord.so
or force linking this library[b] to CondCore/BeamSpotPlugins fixed the testReadWriteBSFromDB
unit test.
One way of fixing this is to add a BuildFile flag to let scram force link (not implementaed yet) a library e.g. <use name="System/Package" force_link="1"/>
and then scram can change -lSystemPackage
to -Wl,--no-as-needed -lSystemPackage -Wl,-as-needed
and we have to fix all BuildFiles where this is needed.
For CondFormatsDataRecord
which is needed by many plugins, can we add some symbol which is used by all plugins (which depend on it) and compiler do not drop this dependency?
[a] https://cmssdt.cern.ch/SDT/cgi-bin/logreader/el8_amd64_gcc12/CMSSW_14_1_ASNEEDED_X_2024-06-26-1200/unitTestLogs/RecoVertex/BeamSpotProducer#/26-26
----- Begin Fatal Exception 26-Jun-2024 22:28:34 CEST-----------------------
An exception of category 'NoRecord' occurred while
[0] Processing Event run: 1 lumi: 1 event: 1 stream: 0
[1] Running path 'p'
[2] Calling method for module BeamSpotFromDB/'beamspot'
Exception Message:
No "BeamSpotObjectsRcd" record found in the EventSetup.
Please add an ESSource or ESProducer that delivers such a record.
----- End Fatal Exception -------------------------------------------------
[b]
diff --git a/CondCore/BeamSpotPlugins/BuildFile.xml b/CondCore/BeamSpotPlugins/BuildFile.xml
index 75062988214..041cf41ff8f 100644
--- a/CondCore/BeamSpotPlugins/BuildFile.xml
+++ b/CondCore/BeamSpotPlugins/BuildFile.xml
@@ -1,4 +1,5 @@
<use name="CondFormats/BeamSpotObjects"/>
<use name="CondFormats/DataRecord"/>
<use name="CondCore/ESSources"/>
+<flags LDFLAGS="-Wl,--no-as-needed -lCondFormatsDataRecord -Wl,-as-needed"/>
<flags EDM_PLUGIN="1"/>