Skip to content

build: archive ord singleton symbols to fix CutGTests strict-link failure (#9563)#10725

Open
saurav-fermions wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
Fermions-ASI:fix/9563
Open

build: archive ord singleton symbols to fix CutGTests strict-link failure (#9563)#10725
saurav-fermions wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
Fermions-ASI:fix/9563

Conversation

@saurav-fermions

Copy link
Copy Markdown
Contributor

Summary

CutGTests failed to link under strict symbol resolution (Nix / static linking / -Wl,-z,defs) with an undefined reference to ord::OpenRoad::openRoad(). This archives the ord singleton symbols so the symbol is defined in libord_app.a.

Type of Change

  • Bug fix

Impact

Fixes strict-link builds; no runtime behavior change.

Verification

  • Local build succeeds.
  • Relevant tests pass (rebuilt from source): Rebuilt; nm -C build/src/libord_app.a shows ord::OpenRoad::openRoad() DEFINED (T).
  • Code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

Fixes #9563


Developed with SAIGE, Fermions' autonomous RTL/EDA debugging agent; root-caused, tested, and signed off by the submitter (@saurav-fermions).

…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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/OpenRoadSingleton.cc
Comment on lines +50 to +53
sta::dbNetwork* OpenRoad::getDbNetwork()
{
return sta_->getDbNetwork();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
sta::dbNetwork* OpenRoad::getDbNetwork()
{
return sta_->getDbNetwork();
}
sta::dbNetwork* OpenRoad::getDbNetwork()
{
return sta_ ? sta_->getDbNetwork() : nullptr;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CutGTests fails to link in strict/static environments due to missing ord::OpenRoad symbols

1 participant