From 63b47b0d028d13f08efe85ce37a79a211fbb5d11 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Thu, 11 Jun 2026 00:16:36 +0200 Subject: [PATCH 1/4] We're not using runfiles anymore, don't use associated macro define. We used to use runfiles to work with tcl dependencies. Since we don't need that anymore, just add a regular `BAZEL_BUILD` define to choose the behavior in the bazel build and remove the unneeded dependency. Signed-off-by: Henner Zeller --- BUILD.bazel | 1 + src/Main.cc | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 564da02b8a6..dab7a38f033 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -143,6 +143,7 @@ OPENROAD_COPTS = [ OPENROAD_DEFINES = [ "BUILD_TYPE=\\\"$(COMPILATION_MODE)\\\"", + "BAZEL_BUILD", "GPU=false", "BUILD_PYTHON=false", "ABC_NAMESPACE=abc", diff --git a/src/Main.cc b/src/Main.cc index 6fc1d8fcc80..fb702493e12 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -44,7 +44,7 @@ #include "utl/decode.h" #include "web/web.h" -#ifdef BAZEL_CURRENT_REPOSITORY +#ifdef BAZEL_BUILD #include "bazel/tcl_library_init.h" #include "boost/dll/runtime_symbol_info.hpp" #endif @@ -185,7 +185,7 @@ static void initPython() static volatile sig_atomic_t fatal_error_in_progress = 0; -#ifdef BAZEL_CURRENT_REPOSITORY +#ifdef BAZEL_BUILD // Point RUNFILES_DIR at the runfiles tree next to the installed binary so it // can find its Tcl resources. boost::dll::program_location() asks the OS for // the absolute path of the running executable (/proc/self/exe on Linux, etc.), @@ -260,7 +260,7 @@ int main(int argc, char* argv[]) signal(SIGILL, handler); signal(SIGSEGV, handler); -#ifdef BAZEL_CURRENT_REPOSITORY +#ifdef BAZEL_BUILD setupBazelRunfilesEnvironment(); #endif @@ -385,7 +385,7 @@ static int tclAppInit(int& argc, // Initialize tcl interpreter and readline. exit_after_cmd_file = findCmdLineFlag(argc, argv, "-exit"); -#ifdef BAZEL_CURRENT_REPOSITORY +#ifdef BAZEL_BUILD if (in_bazel::SetupTclEnvironment(interp) == TCL_ERROR) { return TCL_ERROR; } @@ -616,7 +616,7 @@ static void showSplash() ord::OpenRoad::getGPUCompileOption() ? "+" : "-", ord::OpenRoad::getGUICompileOption() ? "+" : "-", ord::OpenRoad::getPythonCompileOption() ? "+" : "-", -#ifdef BAZEL_CURRENT_REPOSITORY +#ifdef BAZEL_BUILD strcasecmp(BUILD_TYPE, "opt") == 0 #else strcasecmp(BUILD_TYPE, "release") == 0 From 40677ea511baddd8115992f97c798aa33a8b55fd Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Thu, 11 Jun 2026 09:18:47 +0200 Subject: [PATCH 2/4] Don't use runfile setup anymore. Since tcl resources are compmiled-in, we don't need that anymore. Signed-off-by: Henner Zeller --- BUILD.bazel | 3 --- MODULE.bazel | 1 - MODULE.bazel.lock | 6 ------ src/Main.cc | 31 ---------------------------- test/install/install_test.sh | 39 ------------------------------------ 5 files changed, 80 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index dab7a38f033..3bc04634456 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -179,7 +179,6 @@ cc_library( # headers to consumers, so direct binary deps are what each Main.cc # include needs to see. OPENROAD_MAIN_DEPS = [ - ":openroad_version", ":ord", ":tcl_readline_setup", "//bazel:tcl_library_init", @@ -188,9 +187,7 @@ OPENROAD_MAIN_DEPS = [ "//src/utl", "//src/web", "@abseil-cpp//absl/base:no_destructor", - "@boost.dll", "@boost.stacktrace", - "@rules_cc//cc/runfiles", # sets BAZEL_CURRENT_REPOSITORY "@tcl_lang//:tcl", ] diff --git a/MODULE.bazel b/MODULE.bazel index 697f56d3f18..f47db8c43e0 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -43,7 +43,6 @@ bazel_dep(name = "boost.bind", version = BOOST_VERSION) bazel_dep(name = "boost.config", version = BOOST_VERSION) bazel_dep(name = "boost.container", version = BOOST_VERSION) bazel_dep(name = "boost.container_hash", version = BOOST_VERSION) -bazel_dep(name = "boost.dll", version = BOOST_VERSION) bazel_dep(name = "boost.format", version = BOOST_VERSION) bazel_dep(name = "boost.fusion", version = BOOST_VERSION) bazel_dep(name = "boost.geometry", version = BOOST_VERSION) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 02ca0e7a2fd..c092906c38d 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -175,8 +175,6 @@ "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.detail/1.87.0/MODULE.bazel": "64ed391c2b60b226263de4f486fad690414afc6a68d1a5e58eed70e4a63f2d80", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.detail/1.89.0.bcr.2/MODULE.bazel": "d316fd4bcf6bc5d84edc0b15d447da5c5af571992cc9e0c07db544e8f6ccd9a1", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.detail/1.89.0.bcr.2/source.json": "dbfd712fa8277eb303f312be503d4596a650f787d723aca19e0fd2020e85dfc7", - "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.dll/1.89.0.bcr.2/MODULE.bazel": "c3485afb0d07d2a8318cebe01d0c88febce56988251d14bd7af92037ff518f14", - "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.dll/1.89.0.bcr.2/source.json": "1c977ea69075820d06a6a455ff1c62f722fd98b9ab2996b1c78df9f0f306c232", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.dynamic_bitset/1.87.0/MODULE.bazel": "542b8afeb7534c248e9f28fdef589ba8a443d18c253a7ea06e283848bb06a237", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.dynamic_bitset/1.89.0.bcr.2/MODULE.bazel": "9576e39e6bb2429c43d83a290a4fd6e90a3403b048a31232502097a66d54f009", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.dynamic_bitset/1.89.0.bcr.2/source.json": "b40e7e49c2bf6243c22ea0f7c2015d5021b89b482d6a467017c1914877378cb3", @@ -186,8 +184,6 @@ "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.exception/1.87.0/MODULE.bazel": "2bc7bfa2166bccb25c8b814ad8d5bf462448349ffd41e9541cfa7b849bd15ca8", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.exception/1.89.0.bcr.2/MODULE.bazel": "602cd716068438f492e424de704dbfa8c6de21a7fcb676394fd784f0cc99b045", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.exception/1.89.0.bcr.2/source.json": "ce2c164e4d36a90bab9433987e1b0be5668e8a80343c40a00740ae8e13628995", - "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.filesystem/1.89.0.bcr.2/MODULE.bazel": "87eac947dde0399d3ebd7b22b68584cb0b2563beb69dbb0065194f6f0790937b", - "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.filesystem/1.89.0.bcr.2/source.json": "1af84a53fcf63bc71b55a3601ab321649f3d1345a3b51e24c1a6a6985c414437", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.foreach/1.89.0.bcr.2/MODULE.bazel": "e8d4c5806a8a8d7f2033f35efeef79e97367ac89ef6ae7a094a12b93cf63170d", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.foreach/1.89.0.bcr.2/source.json": "a996607ee5e07a590794b3afe9a8fddd3f029b78858ab1f9c4886b4ada559e45", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.format/1.89.0.bcr.2/MODULE.bazel": "f2eb73379af549fb1a053050022a7056cf893510c63ad8179e4f5b1a3696d0a8", @@ -300,8 +296,6 @@ "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.regex/1.87.0/MODULE.bazel": "b91f176af90ce5ad96c8be6f83c4fb253fc8b391055e23a349f35e76e679e302", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.regex/1.89.0.bcr.2/MODULE.bazel": "40f9f43e11d6770e32f3823a68c47550fb599025896a1a44161c0afab1568753", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.regex/1.89.0.bcr.2/source.json": "3e1562878b359d9ea3df7b2e6ecb6e1eb3857d3d6628959790fa113fe6db4b0c", - "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.scope/1.89.0.bcr.2/MODULE.bazel": "8175df9769301998e6ab173662e8eb1c9d7c1754d868a3e1d13cb8189c3ed092", - "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.scope/1.89.0.bcr.2/source.json": "bccd896a3fc01315f827930290c0c34a58ea75868d70db00a99a2ffdd5858575", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.serialization/1.87.0/MODULE.bazel": "b1d3c48e3287036825f7ea649ff59382558478e913adcc86d10cf38d56a82cab", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.serialization/1.89.0.bcr.2/MODULE.bazel": "b5f0866ba61043356d7ed18629814258ad443c8d3729dfe01e96e801650b3d1d", "https://raw.githubusercontent.com/oharboe/bazel-central-registry/1beaf797951046d93a2f656d4238c954a21833e5/modules/boost.serialization/1.89.0.bcr.2/source.json": "9604532795be9515e4324d32b608f5fb62cb5726a80f19182f26f07529f40cbf", diff --git a/src/Main.cc b/src/Main.cc index fb702493e12..278d02e5bbf 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -46,7 +46,6 @@ #ifdef BAZEL_BUILD #include "bazel/tcl_library_init.h" -#include "boost/dll/runtime_symbol_info.hpp" #endif #include "tcl_readline_setup.h" @@ -185,32 +184,6 @@ static void initPython() static volatile sig_atomic_t fatal_error_in_progress = 0; -#ifdef BAZEL_BUILD -// Point RUNFILES_DIR at the runfiles tree next to the installed binary so it -// can find its Tcl resources. boost::dll::program_location() asks the OS for -// the absolute path of the running executable (/proc/self/exe on Linux, etc.), -// which is robust regardless of how it was launched -- a relative path, a bare -// name resolved via PATH, or through a symlink -- unlike reconstructing it from -// argv[0]. -static void setupBazelRunfilesEnvironment() -{ - if (getenv("RUNFILES_DIR") != nullptr) { - return; - } - - boost::dll::fs::error_code ec; - boost::dll::fs::path exe_path = boost::dll::program_location(ec); - if (ec) { - return; - } - - exe_path += ".runfiles"; - if (boost::dll::fs::exists(exe_path)) { - setenv("RUNFILES_DIR", exe_path.string().c_str(), /* override */ 0); - } -} -#endif - // When we enter through main() we have a single tech and design. // Custom applications using OR as a library might define multiple. // Such applications won't allocate or use these objects. @@ -260,10 +233,6 @@ int main(int argc, char* argv[]) signal(SIGILL, handler); signal(SIGSEGV, handler); -#ifdef BAZEL_BUILD - setupBazelRunfilesEnvironment(); -#endif - if (argc == 2 && stringEq(argv[1], "-help")) { showUsage(argv[0], init_filename); return 0; diff --git a/test/install/install_test.sh b/test/install/install_test.sh index 747af45cd04..49755fc7e4d 100755 --- a/test/install/install_test.sh +++ b/test/install/install_test.sh @@ -26,10 +26,6 @@ if [ -e openroad.repo_mapping ]; then rm -rf openroad.repo_mapping fi -# Clear Bazel runfiles env vars so the installed binary resolves its own -# runfiles tree (not the test runner's). -unset RUNFILES_DIR RUNFILES_MANIFEST_FILE TEST_SRCDIR - # Verify CLI startup and trivial Tcl evaluation works. echo 'puts "install_test_ok"' > test_script.tcl if OUTPUT=$(./openroad -no_init -no_splash -exit test_script.tcl 2>&1) && echo "$OUTPUT" | grep -q "install_test_ok"; then @@ -40,41 +36,6 @@ else exit 1 fi -# Verify Main.cc runfiles initialization: RUNFILES_DIR should be present even -# though it was cleared in this test process. -cat > runfiles_env_test.tcl <<'EOF' -if {![info exists ::env(RUNFILES_DIR)]} { - puts "runfiles_env_missing" - exit 1 -} -if {![file isdirectory $::env(RUNFILES_DIR)]} { - puts "runfiles_dir_not_found" - exit 1 -} -puts "runfiles_env_ok" -EOF - -if OUTPUT=$(./openroad -no_init -no_splash -exit runfiles_env_test.tcl 2>&1) && echo "$OUTPUT" | grep -q "runfiles_env_ok"; then - echo "PASS: RUNFILES_DIR initialized by openroad" -else - echo "FAIL: RUNFILES_DIR was not initialized as expected" - echo "Output was: $OUTPUT" - exit 1 -fi - -# Verify runfiles resolution when launched via PATH from an unrelated working -# directory. argv[0] is then just "openroad" (no path component); the binary -# must resolve the runfiles tree next to the installed executable found on -# PATH, not $PWD/openroad.runfiles. WORK_DIR deliberately has no runfiles tree. -cp runfiles_env_test.tcl "$WORK_DIR"/ -if OUTPUT=$(cd "$WORK_DIR" && PATH="$DEST_DIR:$PATH" openroad -no_init -no_splash -exit runfiles_env_test.tcl 2>&1) && echo "$OUTPUT" | grep -q "runfiles_env_ok"; then - echo "PASS: RUNFILES_DIR initialized when launched via PATH from another dir" -else - echo "FAIL: RUNFILES_DIR not initialized when launched via PATH from another dir" - echo "Output was: $OUTPUT" - exit 1 -fi - # --------------------------------------------------------------------------- # install.sh artifact cleanup test. # From 448f3d3ea7251ba373cd091b9a4cc17b6d5fd4eb Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Thu, 11 Jun 2026 09:59:13 +0200 Subject: [PATCH 3/4] DWYU: remove unused boost dependencies. Signed-off-by: Henner Zeller --- src/par/BUILD | 7 ------- src/syn/BUILD | 1 - 2 files changed, 8 deletions(-) diff --git a/src/par/BUILD b/src/par/BUILD index 87c8e3f99e8..8018c424b50 100644 --- a/src/par/BUILD +++ b/src/par/BUILD @@ -58,14 +58,7 @@ cc_library( "//src/odb/src/db", "//src/sta:opensta_lib", "//src/utl", - "@boost.format", - "@boost.geometry", - "@boost.polygon", - "@boost.property_tree", - "@boost.random", "@boost.range", - "@boost.tokenizer", - "@boost.utility", "@or-tools//ortools/linear_solver", "@or-tools//ortools/linear_solver:linear_solver_base", ], diff --git a/src/syn/BUILD b/src/syn/BUILD index 2587717e93c..c12d2576a01 100644 --- a/src/syn/BUILD +++ b/src/syn/BUILD @@ -48,7 +48,6 @@ cc_library( "//src/syn/src/ir", "//src/utl", "@abc", - "@boost.stacktrace", ], ) From 64f3171c515fd243c05e585d3b421ed6a3b7200e Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Thu, 11 Jun 2026 16:03:07 +0200 Subject: [PATCH 4/4] Don't include empty runfiles in installation. Signed-off-by: Henner Zeller --- bazel/install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bazel/install.sh b/bazel/install.sh index 971b1a63976..09b2a933bf0 100755 --- a/bazel/install.sh +++ b/bazel/install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -eu # Install binary and runfiles from bazel build @@ -32,6 +32,8 @@ tar -xf "$TARFILE" -C "$DEST_DIR/bin" if [ -e "$DEST_DIR/bin/openroad.repo_mapping" ]; then chmod u+w "$DEST_DIR/bin/openroad.repo_mapping" rm -rf "$DEST_DIR/bin/openroad.repo_mapping" + chmod u+w "$DEST_DIR/bin/openroad.runfiles" + rm -rf "$DEST_DIR/bin/openroad.runfiles" fi ABS_DEST="$(realpath "$DEST_DIR")"