build: archive ord singleton symbols to fix CutGTests strict-link failure (#9563)#10725
build: archive ord singleton symbols to fix CutGTests strict-link failure (#9563)#10725saurav-fermions wants to merge 1 commit into
Conversation
…he-OpenROAD-Project#9563) The SWIG-generated dbStaTCL_wrap.cxx (in dbSta.a) references ord::OpenRoad::openRoad(), ord::OpenRoad::getDbNetwork() and ord::getOpenRoad(), but those symbols were defined only in objects compiled directly into the openroad executable (OpenRoad.cc) and the ord SWIG library (OpenRoad.i) -- never into a static archive. Lazy/ shared workstation links resolve them at runtime, but strict static linking (Nix, -Wl,-z,defs) fails with an undefined reference. Split the small, low-dependency singleton accessors into a new OpenRoadSingleton.cc, built as a static ord_app library, and link it from the openroad executable, the ord SWIG lib, and (PUBLIC) the dbSta SWIG lib so consumers of dbSta.a can resolve the symbols. ord_app depends only on dbSta_lib (a leaf), so no library dependency cycle is introduced; the heavyweight OpenRoad.cc stays in the executable. Verified: the symbols now live in libord_app.a; a strict re-link of CutGTests with -Wl,-z,defs and --whole-archive on dbSta.a succeeds with 0 undefined references and all 14 tests pass; the full openroad build still succeeds with exactly one definition of each symbol. Signed-off-by: Saurav Singh <saurav.singh@fermions.co>
There was a problem hiding this comment.
Code Review
This pull request extracts the core ord::OpenRoad singleton accessors and the getOpenRoad free function into a new static library ord_app (defined in OpenRoadSingleton.cc). This change ensures that strict-linking consumers can resolve these symbols, preventing linking failures in targets like CutGTests. Feedback is provided to add a defensive check in OpenRoad::getDbNetwork() to prevent potential null pointer dereferences on sta_ during early initialization or testing.
| sta::dbNetwork* OpenRoad::getDbNetwork() | ||
| { | ||
| return sta_->getDbNetwork(); | ||
| } |
There was a problem hiding this comment.
To prevent potential null pointer dereferences, it is safer to add a defensive check to ensure sta_ is non-null before calling getDbNetwork(). This is especially important during early initialization phases or in unit testing environments where sta_ might not be fully initialized.
| sta::dbNetwork* OpenRoad::getDbNetwork() | |
| { | |
| return sta_->getDbNetwork(); | |
| } | |
| sta::dbNetwork* OpenRoad::getDbNetwork() | |
| { | |
| return sta_ ? sta_->getDbNetwork() : nullptr; | |
| } |
Summary
CutGTestsfailed to link under strict symbol resolution (Nix / static linking /-Wl,-z,defs) with an undefined reference toord::OpenRoad::openRoad(). This archives the ord singleton symbols so the symbol is defined inlibord_app.a.Type of Change
Impact
Fixes strict-link builds; no runtime behavior change.
Verification
nm -C build/src/libord_app.ashowsord::OpenRoad::openRoad()DEFINED (T).Related Issues
Fixes #9563
Developed with SAIGE, Fermions' autonomous RTL/EDA debugging agent; root-caused, tested, and signed off by the submitter (@saurav-fermions).