Skip to content

fix: unsetenv RUNFILES_* in tcl_library_init#10173

Merged
maliberty merged 2 commits intoThe-OpenROAD-Project:masterfrom
oharboe:fix-runfiles
Apr 18, 2026
Merged

fix: unsetenv RUNFILES_* in tcl_library_init#10173
maliberty merged 2 commits intoThe-OpenROAD-Project:masterfrom
oharboe:fix-runfiles

Conversation

@oharboe
Copy link
Copy Markdown
Collaborator

@oharboe oharboe commented Apr 17, 2026

When OpenROAD is invoked by a build system that previously ran another Bazel binary (e.g. a Python wrapper in a Bazel action), the inherited RUNFILES_DIR / RUNFILES_MANIFEST_FILE env vars point to the other binary's runfiles tree. Runfiles::Create() checks those env vars first, so it resolves paths in the wrong tree.

Unsetenv the three RUNFILES_* variables before Runfiles::Create() so it falls back to the exe_path derived from /proc/self/exe.

When OpenROAD is invoked by a build system that previously ran another
Bazel binary (e.g. a Python wrapper in a Bazel action), the inherited
RUNFILES_DIR / RUNFILES_MANIFEST_FILE env vars point to the *other*
binary's runfiles tree.  Runfiles::Create() checks those env vars
first, so it resolves paths in the wrong tree.

Unsetenv the three RUNFILES_* variables before Runfiles::Create() so
it falls back to the exe_path derived from /proc/self/exe.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe oharboe requested a review from maliberty April 17, 2026 15:22
Copy link
Copy Markdown
Contributor

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

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 modifies bazel/tcl_library_init.cc to clear inherited Bazel environment variables before initializing the runfiles library, ensuring correct path resolution. A review comment points out that unsetenv is a POSIX-specific function that will cause build failures on Windows, and suggests wrapping the calls in a platform-specific guard.

Comment thread bazel/tcl_library_init.cc
@maliberty maliberty enabled auto-merge April 17, 2026 15:25
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@oharboe
Copy link
Copy Markdown
Collaborator Author

oharboe commented Apr 18, 2026

@vvbandeira @maliberty Stuck?

image

@maliberty
Copy link
Copy Markdown
Member

Odd it seems to have never started. pr-head does show //test/orfs/gcd:gcd_whittle_test failed.

The previous change unconditionally unset the RUNFILES_* env vars and
relied on the /proc/self/exe fallback to find OpenROAD's runfiles.
That breaks tests where OpenROAD is invoked via a wrapper (e.g.
sh_test/whittle.py) whose runfiles tree already contains OpenROAD's
tcl_resources_dir, because in remote-cache CI runs the real binary
in execroot doesn't have an openroad.runfiles/ next to it, so the
exe_path fallback fails.

Probe the inherited RUNFILES_* tree for tcl_resources_dir first; only
if it isn't there (the Python-wrapper case the previous commit fixed)
unset the env vars and retry via exe_path.

Fixes //test/orfs/gcd:gcd_whittle_test in CI.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
auto-merge was automatically disabled April 18, 2026 08:07

Head branch was pushed to by a user without write access

@oharboe
Copy link
Copy Markdown
Collaborator Author

oharboe commented Apr 18, 2026

@maliberty bazel runfiles papercuts... 😿

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@oharboe oharboe requested a review from maliberty April 18, 2026 08:54
@maliberty maliberty merged commit bf6f201 into The-OpenROAD-Project:master Apr 18, 2026
16 checks passed
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.

2 participants