Skip to content

Commit b668763

Browse files
oharboeclaude
andcommitted
bump: update orfs, openroad, qt-bazel and fix Tcl init
Bump dependencies: - orfs -> 74271e42b301 (removes upstreamed merge_lib patch) - openroad -> d22045c978d0 - qt-bazel -> 886104974c2f - rules_pkg -> 1.2.0 (matches resolved graph) The new OpenROAD replaced the InitRunFiles.cpp global constructor with tcl_library_init, but its Runfiles::Create() picks up stale RUNFILES_* env vars left by the Python wrapper that ORFS runs between OpenROAD calls. Patch OpenROAD to clear inherited RUNFILES_DIR/RUNFILES_MANIFEST_FILE before resolving its own runfiles, and gut the now-dead InitRunFiles.cpp shim. Also regenerate the ORFS MODULE.bazel patch for the new upstream (rules_python 1.8.5, shifted line numbers). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent cb43bc7 commit b668763

3 files changed

Lines changed: 147 additions & 7 deletions

File tree

MODULE.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local_path_override(
1414

1515
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
1616

17-
bazel_dep(name = "rules_pkg", version = "1.0.1")
17+
bazel_dep(name = "rules_pkg", version = "1.2.0")
1818
bazel_dep(name = "rules_shell", version = "0.6.1")
1919
bazel_dep(name = "mock-klayout", version = "0.0.1")
2020
local_path_override(
@@ -36,13 +36,12 @@ single_version_override(
3636
bazel_dep(name = "orfs")
3737
git_override(
3838
module_name = "orfs",
39-
commit = "f40d2f346e67ffe309a4f49b1897a560cf20c747",
39+
commit = "74271e42b301df0b3b84fb14d42282f9e8491cee",
4040
patch_strip = 1,
4141
# Minimal patches: only what's needed for extension.bzl flow targets
4242
# (PDK definitions, variables.yaml export). Design-specific patches
4343
# are only applied in the orfs/ integration workspace.
4444
patches = [
45-
"//patches:0001-build-remove-stale-merge_lib.py-preprocessLib.py-fro.patch",
4645
"//patches:0002-build-add-all-PDKs-and-export-variables.yaml.patch",
4746
"//patches:0035-fix-remove-non-root-overrides-from-MODULE.bazel.patch",
4847
],
@@ -52,19 +51,20 @@ git_override(
5251
bazel_dep(name = "openroad")
5352
git_override(
5453
module_name = "openroad",
55-
commit = "df79404cd806cc435b3c3b53678ebf2441c31313",
54+
commit = "d22045c978d037f7a5788c08f359aec471800c01",
5655
init_submodules = True,
5756
patch_strip = 1,
5857
patches = [
5958
"//:openroad-visibility.patch",
59+
"//:openroad-remove-initrunfiles.patch",
6060
],
6161
remote = "https://github.com/The-OpenROAD-Project/OpenROAD.git",
6262
)
6363

6464
bazel_dep(name = "qt-bazel")
6565
git_override(
6666
module_name = "qt-bazel",
67-
commit = "df022f4ebaa4130713692fffd2f519d49e9d0b97",
67+
commit = "886104974c2fd72439f2c33b5deebf0fe4649df7",
6868
remote = "https://github.com/The-OpenROAD-Project/qt_bazel_prebuilts",
6969
)
7070

openroad-remove-initrunfiles.patch

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
diff --git a/bazel/BUILD b/bazel/BUILD
2+
index a15adee..66f99d2 100644
3+
--- a/bazel/BUILD
4+
+++ b/bazel/BUILD
5+
@@ -124,18 +124,12 @@ cc_library(
6+
}),
7+
)
8+
9+
-# shim old library as it is still referenced in src/sta, implementing the
10+
-# old behavior.
11+
+# Stub library kept for src/sta:opensta compatibility.
12+
+# Tcl setup is now handled by //bazel:tcl_library_init.
13+
cc_library(
14+
name = "runfiles",
15+
srcs = ["InitRunFiles.cpp"],
16+
- data = [":tcl_resources_dir"],
17+
visibility = ["//visibility:public"],
18+
- deps = [
19+
- "@rules_cc//cc/runfiles",
20+
- "@tcl_lang//:tcl",
21+
- ],
22+
- alwayslink = True,
23+
)
24+
25+
# small build test to check if "bazel build //src/sta:StaTclInitVar" works
26+
diff --git a/bazel/InitRunFiles.cpp b/bazel/InitRunFiles.cpp
27+
index 0651774..ece50b0 100644
28+
--- a/bazel/InitRunFiles.cpp
29+
+++ b/bazel/InitRunFiles.cpp
30+
@@ -1,86 +1,3 @@
31+
-// SPDX-License-Identifier: BSD-3-Clause
32+
-// Copyright (c) 2026, The OpenROAD Authors
33+
-
34+
-// This file to go away as soon as we use the tcl_library_init initialization
35+
-// in OpenSTA.
36+
-
37+
-#include <unistd.h> // readlink()
38+
-
39+
-#include <climits>
40+
-#include <cstdlib>
41+
-#include <filesystem>
42+
-#include <iostream>
43+
-#include <memory>
44+
-#include <optional>
45+
-#include <string>
46+
-#include <system_error>
47+
-
48+
-#if defined(__APPLE__)
49+
-#include <mach-o/dyld.h>
50+
-#include <sys/param.h>
51+
-#endif
52+
-
53+
-#include "rules_cc/cc/runfiles/runfiles.h"
54+
-
55+
-namespace {
56+
-// Avoid adding any dependencies like boost.filesystem
57+
-// Returns path to running binary if possible, otherwise nullopt.
58+
-static std::optional<std::string> GetProgramLocation()
59+
-{
60+
-#if defined(_WIN32)
61+
- char result[MAX_PATH + 1] = {'\0'};
62+
- auto path_len = GetModuleFileNameA(NULL, result, MAX_PATH);
63+
-#elif defined(__APPLE__)
64+
- char result[MAXPATHLEN + 1] = {'\0'};
65+
- uint32_t path_len = MAXPATHLEN;
66+
- if (_NSGetExecutablePath(result, &path_len) != 0) {
67+
- path_len = readlink(result, result, MAXPATHLEN);
68+
- }
69+
-#else
70+
- char result[PATH_MAX + 1] = {'\0'};
71+
- ssize_t path_len = readlink("/proc/self/exe", result, PATH_MAX);
72+
-#endif
73+
- if (path_len > 0) {
74+
- return result;
75+
- }
76+
- return std::nullopt;
77+
-}
78+
-
79+
-std::string GetTclLibraryBaseLocation()
80+
-{
81+
- using rules_cc::cc::runfiles::Runfiles;
82+
- std::string error;
83+
- std::unique_ptr<Runfiles> runfiles(Runfiles::Create(
84+
- *GetProgramLocation(), BAZEL_CURRENT_REPOSITORY, &error));
85+
- if (!runfiles) {
86+
- std::cerr << "[Warning] Failed to create bazel runfiles: " << error << "\n";
87+
- return "";
88+
- }
89+
-
90+
- std::error_code ec;
91+
- for (const std::string loc : {"openroad", "opensta", "_main"}) {
92+
- const std::string check_loc = loc + "/bazel/tcl_resources_dir";
93+
- const std::string path = runfiles->Rlocation(check_loc);
94+
- if (!path.empty() && std::filesystem::exists(path, ec)) {
95+
- return path;
96+
- }
97+
- }
98+
- return "";
99+
-}
100+
-
101+
-class BazelInitializer
102+
-{
103+
- public:
104+
- BazelInitializer()
105+
- {
106+
- const std::string lib_mount_point = GetTclLibraryBaseLocation();
107+
- if (!lib_mount_point.empty()) {
108+
- const std::string tcl_path = lib_mount_point + "/library";
109+
- setenv("TCL_LIBRARY", tcl_path.c_str(), true);
110+
- }
111+
- }
112+
-};
113+
-
114+
-// Provide via global constructor.
115+
-static BazelInitializer bazel_initializer;
116+
-} // namespace
117+
+// Intentionally empty: tcl_library_init now handles Tcl setup.
118+
+// This file is kept because src/sta:opensta still references
119+
+// //bazel:runfiles in its srcs.
120+
diff --git a/bazel/tcl_library_init.cc b/bazel/tcl_library_init.cc
121+
index 4be9671..8306978 100644
122+
--- a/bazel/tcl_library_init.cc
123+
+++ b/bazel/tcl_library_init.cc
124+
@@ -35,6 +35,16 @@ static std::optional<std::string> TclLibraryMountPoint(Tcl_Interp* interp)
125+
return Tcl_GetStringResult(interp);
126+
#else
127+
using rules_cc::cc::runfiles::Runfiles;
128+
+
129+
+ // Clear inherited RUNFILES_* env vars: when OpenROAD is invoked by
130+
+ // a build system that previously ran another Bazel binary (e.g. a
131+
+ // Python wrapper), those variables point to the *other* binary's
132+
+ // runfiles tree. Runfiles::Create() checks env vars first, so it
133+
+ // would resolve paths in the wrong tree. Unsetting forces it to
134+
+ // fall back to Tcl_GetNameOfExecutable(), which is always correct.
135+
+ unsetenv("RUNFILES_DIR");
136+
+ unsetenv("RUNFILES_MANIFEST_FILE");
137+
+
138+
std::string error;
139+
std::unique_ptr<Runfiles> runfiles(Runfiles::Create(
140+
Tcl_GetNameOfExecutable(), BAZEL_CURRENT_REPOSITORY, &error));

patches/0035-fix-remove-non-root-overrides-from-MODULE.bazel.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ diff --git a/MODULE.bazel b/MODULE.bazel
2626
- remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
2727
-)
2828
-
29-
bazel_dep(name = "rules_python", version = "1.2.0")
29+
bazel_dep(name = "rules_python", version = "1.8.5")
3030
bazel_dep(name = "rules_shell", version = "0.6.1")
3131

32-
@@ -33,15 +26,3 @@
32+
@@ -36,15 +29,3 @@
3333
use_repo(pip, "orfs-pip")
3434

3535
orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")

0 commit comments

Comments
 (0)