Skip to content

Commit 681f0d5

Browse files
authored
Merge pull request #10865 from The-OpenROAD-Project-staging/odb-test-minimal-deps
Trim odb test binary bloat: minimal deps, fixture split, debug compression
2 parents c88e270 + 1556567 commit 681f0d5

25 files changed

Lines changed: 541 additions & 289 deletions

.bazelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ build:asan --copt=-DADDRESS_SANITIZER
111111
build:asan --copt=-O1
112112
build:asan --copt=-g
113113
build:asan --copt=-fno-omit-frame-pointer
114+
# Compress the DWARF debug sections (transparent to gdb/perf/addr2line).
115+
build:asan --copt=-gz=zlib
116+
build:asan --linkopt=-gz=zlib
114117
build:asan --linkopt=-fsanitize=address
115118
# TCMalloc is incompatible with ASan: __asan_init's interceptor setup calls
116119
# dlsym -> malloc before TCMalloc is initialized, segfaulting at startup.
@@ -123,6 +126,9 @@ build:profile --strip=never
123126
build:profile --copt -g --host_copt -g
124127
build:profile --copt -gmlt --host_copt -gmlt
125128
build:profile --copt -fno-omit-frame-pointer --host_copt -fno-omit-frame-pointer
129+
# Compress the DWARF debug sections (transparent to gdb/perf/addr2line).
130+
build:profile --copt=-gz=zlib --host_copt=-gz=zlib
131+
build:profile --linkopt=-gz=zlib
126132

127133
# Improve hermeticity by disallowing user envars and network access
128134
build --incompatible_strict_action_env

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,25 @@ if (LINK_TIME_OPTIMIZATION AND NOT LTO_UNSUPPORTED_OS)
183183
endif()
184184
message(STATUS "LTO/IPO is ${LTO_STATUS}")
185185

186+
# Compress DWARF debug sections in builds that emit debug info. This is a
187+
# large on-disk win for template-heavy C++ (debug info dominates these
188+
# binaries) and is transparent to gdb/readelf/addr2line/lldb. It is a no-op
189+
# for builds without -g (e.g. Release), so it is safe to apply globally.
190+
# Excluded on Apple platforms: Mach-O does not support -gz=zlib and AppleClang
191+
# (which CMAKE_CXX_COMPILER_ID matches as "Clang") would fail the build.
192+
# The compile flag is scoped to C/C++: -gz is a GCC/Clang host-compiler flag
193+
# that nvcc does not accept (it would need explicit -Xcompiler forwarding), so
194+
# applying it directory-wide would break CUDA (ENABLE_GPU) debug builds where
195+
# gpl marks GPU sources as LANGUAGE CUDA. The link flag needs no such guard:
196+
# linking is driven by the host C++ compiler.
197+
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
198+
AND NOT APPLE)
199+
set(DEBUG_CONFIG_GENEX "$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>")
200+
add_compile_options(
201+
"$<$<AND:${DEBUG_CONFIG_GENEX},$<COMPILE_LANGUAGE:CXX,C>>:-gz=zlib>")
202+
add_link_options("$<${DEBUG_CONFIG_GENEX}:-gz=zlib>")
203+
endif()
204+
186205
# configure a header file to pass some of the CMake settings
187206
configure_file(
188207
${OPENROAD_HOME}/include/ord/Version.hh.cmake

src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ if (NOT USE_SYSTEM_OPENSTA)
255255
endif()
256256
add_subdirectory(dbSta)
257257
add_subdirectory(rsz)
258-
add_subdirectory(tst)
258+
if(ENABLE_TESTS)
259+
# tst provides gtest-based fixture libraries used only by test targets, and
260+
# links GTest::gtest, which only exists when ENABLE_TESTS is on.
261+
add_subdirectory(tst)
262+
endif()
259263
add_subdirectory(stt)
260264
add_subdirectory(gpl)
261265
add_subdirectory(dpl)

src/dbSta/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ target_include_directories(dbSta_lib
2222

2323
target_link_libraries(dbSta_lib
2424
PUBLIC
25-
odb
25+
db
2626
OpenSTA
2727
PRIVATE
2828
utl_lib

src/dbSta/test/cpp/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ target_link_libraries(TestDbSta
3838
dpl_lib
3939
stt_lib
4040
odb
41-
tst
41+
tst_integrated_fixture
4242
${TCL_LIBRARY}
4343
)
4444

@@ -67,7 +67,7 @@ target_link_libraries(TestReadVerilog
6767
dpl_lib
6868
stt_lib
6969
odb
70-
tst
70+
tst_integrated_fixture
7171
${TCL_LIBRARY}
7272
)
7373

@@ -96,7 +96,7 @@ target_link_libraries(TestWriteVerilog
9696
dpl_lib
9797
stt_lib
9898
odb
99-
tst
99+
tst_integrated_fixture
100100
${TCL_LIBRARY}
101101
)
102102

src/est/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ target_link_libraries(TestEstimateParasitics
2626
dpl_lib
2727
stt_lib
2828
odb
29-
tst
29+
tst_integrated_fixture
3030
${TCL_LIBRARY}
3131
)
3232

src/odb/src/3dblox/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ target_link_libraries(3dblox
2323
utl_lib
2424
yaml-cpp
2525
OpenSTA
26+
PRIVATE
27+
defin
28+
defout
29+
lefin
30+
lefout
2631
)
2732

2833
target_include_directories(3dblox

src/odb/test/cpp/BUILD

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cc_test(
4747
deps = [
4848
"//src/odb/src/db",
4949
"//src/odb/test/cpp/helper",
50-
"//src/tst",
50+
"//src/tst:db_fixture",
5151
"@googletest//:gtest",
5252
"@googletest//:gtest_main",
5353
"@spdlog",
@@ -102,7 +102,7 @@ cc_test(
102102
"//src/odb/src/db",
103103
"//src/odb/src/gdsin",
104104
"//src/odb/src/gdsout",
105-
"//src/tst",
105+
"//src/tst:db_fixture",
106106
"//src/utl",
107107
"@googletest//:gtest",
108108
"@googletest//:gtest_main",
@@ -235,7 +235,7 @@ cc_test(
235235
srcs = ["TestObjectType.cpp"],
236236
deps = [
237237
"//src/odb/src/db",
238-
"//src/tst",
238+
"//src/tst:db_fixture",
239239
"@googletest//:gtest",
240240
"@googletest//:gtest_main",
241241
],
@@ -271,7 +271,7 @@ cc_test(
271271
"//src/odb/src/3dblox",
272272
"//src/odb/src/db",
273273
"//src/odb/test/cpp/helper",
274-
"//src/tst",
274+
"//src/tst:db_fixture",
275275
"@googletest//:gtest",
276276
"@googletest//:gtest_main",
277277
],
@@ -292,7 +292,7 @@ cc_test(
292292
deps = [
293293
"//src/odb/src/3dblox",
294294
"//src/odb/src/db",
295-
"//src/tst",
295+
"//src/tst:db_fixture",
296296
"@googletest//:gtest",
297297
"@googletest//:gtest_main",
298298
],
@@ -309,7 +309,7 @@ cc_test(
309309
deps = [
310310
"//src/odb/src/3dblox",
311311
"//src/odb/src/db",
312-
"//src/tst",
312+
"//src/tst:db_fixture",
313313
"@googletest//:gtest",
314314
"@googletest//:gtest_main",
315315
],

src/odb/test/cpp/CMakeLists.txt

Lines changed: 130 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
include(openroad)
22

3-
set(TEST_LIBS
4-
odb
5-
lef
6-
defin
7-
defout
8-
lefin
9-
lefout
10-
cdl
11-
3dblox
12-
${TCL_LIBRARY}
13-
Boost::boost
14-
utl_lib
15-
odb_test_helper
16-
gdsin
17-
tst
3+
# Each executable links only the libraries it actually needs to avoid bloated
4+
# binaries. src/odb/test/cpp/BUILD is the reference for the minimal dependency
5+
# set of each test. GTEST_LIBS is the one group shared by every test.
6+
set(GTEST_LIBS
187
GTest::gtest
198
GTest::gtest_main
20-
GTest::gmock
219
)
2210

2311
add_executable(OdbGTests TestDbWire.cc TestDbNet.cpp TestDesignIsRouted.cpp TestAbstractLef.cc TestPolygonalFloorplan.cc)
@@ -42,27 +30,132 @@ add_executable(TestSwapMasterUnusedPort TestSwapMasterUnusedPort.cpp)
4230
add_executable(TestWriteReadDbHier TestWriteReadDbHier.cpp)
4331
add_executable(TestObjectType TestObjectType.cpp)
4432

45-
target_link_libraries(OdbGTests ${TEST_LIBS})
46-
target_link_libraries(TestCallBacks ${TEST_LIBS})
47-
target_link_libraries(TestGeom ${TEST_LIBS})
48-
target_link_libraries(TestModule ${TEST_LIBS})
49-
target_link_libraries(TestLef58Properties ${TEST_LIBS})
50-
target_link_libraries(TestGroup ${TEST_LIBS})
51-
target_link_libraries(TestGCellGrid ${TEST_LIBS})
52-
target_link_libraries(TestJournal ${TEST_LIBS})
53-
target_link_libraries(TestAccessPoint ${TEST_LIBS})
54-
target_link_libraries(TestGuide ${TEST_LIBS})
55-
target_link_libraries(TestNetTrack ${TEST_LIBS})
56-
target_link_libraries(TestMaster ${TEST_LIBS})
57-
target_link_libraries(TestGDSIn ${TEST_LIBS})
58-
target_link_libraries(TestChips ${TEST_LIBS})
59-
target_link_libraries(Test3DBloxParser ${TEST_LIBS})
60-
target_link_libraries(Test3DBloxChecker ${TEST_LIBS})
61-
target_link_libraries(Test3DBloxVerilogWriter ${TEST_LIBS})
62-
target_link_libraries(TestSwapMaster ${TEST_LIBS})
63-
target_link_libraries(TestSwapMasterUnusedPort ${TEST_LIBS})
64-
target_link_libraries(TestWriteReadDbHier ${TEST_LIBS})
65-
target_link_libraries(TestObjectType ${TEST_LIBS})
33+
target_link_libraries(OdbGTests
34+
db
35+
defin
36+
lefin
37+
lefout
38+
OpenSTA
39+
tst
40+
utl_lib
41+
GTest::gmock
42+
${GTEST_LIBS}
43+
)
44+
target_link_libraries(TestCallBacks
45+
db
46+
odb_test_helper
47+
tst_base
48+
spdlog::spdlog
49+
${GTEST_LIBS}
50+
)
51+
target_link_libraries(TestGeom
52+
db
53+
${GTEST_LIBS}
54+
)
55+
target_link_libraries(TestModule
56+
db
57+
odb_test_helper
58+
${GTEST_LIBS}
59+
)
60+
target_link_libraries(TestLef58Properties
61+
db
62+
defin
63+
defout
64+
lefin
65+
lefout
66+
tst
67+
${GTEST_LIBS}
68+
)
69+
target_link_libraries(TestGroup
70+
db
71+
odb_test_helper
72+
${GTEST_LIBS}
73+
)
74+
target_link_libraries(TestGCellGrid
75+
db
76+
odb_test_helper
77+
${GTEST_LIBS}
78+
)
79+
target_link_libraries(TestJournal
80+
db
81+
odb_test_helper
82+
${GTEST_LIBS}
83+
)
84+
target_link_libraries(TestAccessPoint
85+
db
86+
odb_test_helper
87+
${GTEST_LIBS}
88+
)
89+
target_link_libraries(TestGuide
90+
db
91+
odb_test_helper
92+
${GTEST_LIBS}
93+
)
94+
target_link_libraries(TestNetTrack
95+
db
96+
odb_test_helper
97+
${GTEST_LIBS}
98+
)
99+
target_link_libraries(TestMaster
100+
db
101+
odb_test_helper
102+
${GTEST_LIBS}
103+
)
104+
target_link_libraries(TestGDSIn
105+
db
106+
gdsin
107+
gdsout
108+
tst_base
109+
utl_lib
110+
${GTEST_LIBS}
111+
)
112+
target_link_libraries(TestChips
113+
db
114+
odb_test_helper
115+
${GTEST_LIBS}
116+
)
117+
target_link_libraries(Test3DBloxParser
118+
3dblox
119+
db
120+
odb_test_helper
121+
tst_base
122+
${GTEST_LIBS}
123+
)
124+
target_link_libraries(Test3DBloxChecker
125+
3dblox
126+
db
127+
tst_base
128+
${GTEST_LIBS}
129+
)
130+
target_link_libraries(Test3DBloxVerilogWriter
131+
3dblox
132+
db
133+
tst_base
134+
${GTEST_LIBS}
135+
)
136+
target_link_libraries(TestSwapMaster
137+
db
138+
dbSta_lib
139+
tst
140+
${GTEST_LIBS}
141+
)
142+
target_link_libraries(TestSwapMasterUnusedPort
143+
db
144+
dbSta_lib
145+
tst
146+
utl_lib
147+
${GTEST_LIBS}
148+
)
149+
target_link_libraries(TestWriteReadDbHier
150+
db
151+
tst_integrated_fixture
152+
${GTEST_LIBS}
153+
)
154+
target_link_libraries(TestObjectType
155+
db
156+
tst_base
157+
${GTEST_LIBS}
158+
)
66159

67160
# Skip the tests from being registered here, since they are called via
68161
# cpp_tests.tcl and don't need to be executed twice. The cpp_tests.tcl

src/odb/test/cpp/Test3DBloxCheckerFixture.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#include "odb/db.h"
1010
#include "odb/dbWireCodec.h"
1111
#include "odb/geom.h"
12-
#include "tst/fixture.h"
12+
#include "tst/db_fixture.h"
1313

1414
namespace odb {
15-
class CheckerFixture : public tst::Fixture
15+
class CheckerFixture : public tst::DbFixture
1616
{
1717
protected:
1818
CheckerFixture()

0 commit comments

Comments
 (0)