Skip to content

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

@gonsolo

Description

@gonsolo

Describe the bug

The CutGTests executable fails to link in environments that enforce strict symbol resolution (e.g., Nix builds or static linking with -z defs).

The issue is caused by a functional dependency in dbSta (specifically within the SWIG-generated dbStaTCL_wrap.cxx) on the ord namespace. The wrapper calls ord::OpenRoad::openRoad(), but the implementation of the OpenRoad class (found in src/OpenRoad.cc) is not archived into any static library. Instead, it is added directly to the openroad executable target.

While workstation builds using shared libraries and lazy linking may resolve these symbols at runtime, strict static linking fails because the symbols are missing from the available .a archives.

Linker Error Output:
Plaintext

ld: src/dbSta/src/libdbSta_lib.a(dbStaTCL_wrap.cxx.o): in function _wrap_get_open_road': dbStaTCL_wrap.cxx:(.text+0x...): undefined reference to ord::OpenRoad::openRoad()'
collect2: error: ld returned 1 exit status

Root Cause:
In the top-level CMakeLists.txt, the core application manager logic is defined as a source list for the executable only:
CMake

set(OPENROAD_SOURCE
Design.cc
Timing.cc
Tech.cc
OpenRoad.cc
Main.cc
)

add_executable(openroad ${OPENROAD_SOURCE})

Since CutGTests links against dbSta (which requires ord), but OpenRoad.cc is not part of a shared library target, the test remains an "incomplete" binary.

Suggested Fix:
Move the core application logic (excluding Main.cc) into a library target (e.g., an OBJECT library or a STATIC library) that can be linked by both the main executable and the test suites.

Example change:
CMake

add_library(openroad_core STATIC
Design.cc
Timing.cc
Tech.cc
OpenRoad.cc
)
target_link_libraries(openroad PRIVATE openroad_core)
target_link_libraries(CutGTests PRIVATE openroad_core)

Expected Behavior

The CutGTests target (and other C++ unit tests) should link successfully in static environments. The core manager logic (e.g., ord::OpenRoad) should be encapsulated in a library target so that it can be linked by both the main openroad executable and any internal test suites that depend on the OpenROAD database or timing engine.

Environment

The most reliable way to reproduce this failure is via the Nix package manager, which provides a strictly sandboxed, static-link-heavy environment that exposes the missing dependencies.

    Install Nix: curl -L https://nixos.org/nix/install | sh

    Clone the repository containing the OpenROAD flake (or point to yours):
    git clone https://github.com/your-username/nixpkgs

    Run the build:
    nix build .#openroad

    The build will fail during the CutGTests linking phase due to the undefined ord::OpenRoad symbols.

To Reproduce

The most reliable way to reproduce this failure is via the Nix package manager, which provides a strictly sandboxed, static-link-heavy environment that exposes the missing dependencies.

Install Nix: curl -L https://nixos.org/nix/install | sh

Clone the repository containing the OpenROAD flake (or point to yours):
git clone https://github.com/your-username/nixpkgs

Run the build:
nix build .#openroad

The build will fail during the CutGTests linking phase due to the undefined ord::OpenRoad symbols.

Relevant log output

Screenshots

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions