Skip to content

Commit cf98a12

Browse files
authored
Merge pull request #10116 from oharboe/install-fix
bazel: fix installed binary Tcl init failure
2 parents d43d716 + 85e0e57 commit cf98a12

5 files changed

Lines changed: 76 additions & 1 deletion

File tree

bazel/install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ if [ -e openroad.repo_mapping ]; then
1818
chmod u+w openroad.repo_mapping
1919
rm -rf openroad.repo_mapping
2020
fi
21-
rm -rf openroad.runfiles/_main
2221

2322
echo "OpenROAD binary installed to $(realpath "$DEST_DIR")"

packaging/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ pkg_tar(
1515
srcs = ["//:openroad"],
1616
include_runfiles = True,
1717
package_file_name = "openroad.tar",
18+
visibility = ["//test:__subpackages__"],
1819
)

test/install/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) 2026, The OpenROAD Authors
3+
4+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
5+
6+
sh_test(
7+
name = "install_test",
8+
srcs = ["install_test.sh"],
9+
args = ["$(rootpath //packaging:tarfile)"],
10+
data = ["//packaging:tarfile"],
11+
tags = ["local"],
12+
)

test/install/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Install smoke test
2+
3+
Verifies that the binary produced by `//packaging:tarfile` starts correctly
4+
after extraction (Tcl initialisation, runfiles resolution, etc.).
5+
6+
## Running
7+
8+
```sh
9+
bazelisk test //test/install/...
10+
```
11+
12+
## What it checks
13+
14+
1. Extracts the packaging tarball into a temporary directory (same layout
15+
that `bazelisk run //packaging:install` produces).
16+
2. Launches the binary with a trivial Tcl script (`puts "install_test_ok"`).
17+
3. Asserts the expected output appears, proving Tcl initialised and the
18+
interpreter is functional.
19+
20+
## Background
21+
22+
The installed binary relies on Bazel runfiles for Tcl library files
23+
(`init.tcl`, tclreadline, etc.). These live under
24+
`openroad.runfiles/_main/bazel/tcl_resources_dir/`. If the runfiles
25+
tree is damaged during packaging or installation the binary fails with
26+
`application-specific initialization failed:` (GitHub issue #10115).

test/install/install_test.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
# Copyright (c) 2026, The OpenROAD Authors
4+
#
5+
# Smoke test: extract the packaging tarball and verify the installed
6+
# binary can start (Tcl initialisation succeeds).
7+
set -euo pipefail
8+
9+
TARFILE="$1"
10+
11+
DEST_DIR=$(mktemp -d)
12+
trap 'rm -rf "$DEST_DIR"' EXIT
13+
14+
cp "$TARFILE" "$DEST_DIR"
15+
cd "$DEST_DIR"
16+
tar -xf openroad.tar
17+
rm -f openroad.tar
18+
19+
# Remove repo_mapping (same as install.sh)
20+
if [ -e openroad.repo_mapping ]; then
21+
chmod u+w openroad.repo_mapping
22+
rm -rf openroad.repo_mapping
23+
fi
24+
25+
# Clear Bazel runfiles env vars so the installed binary resolves its own
26+
# runfiles tree (not the test runner's).
27+
unset RUNFILES_DIR RUNFILES_MANIFEST_FILE TEST_SRCDIR
28+
29+
# Verify the binary starts and can evaluate a trivial Tcl expression.
30+
echo 'puts "install_test_ok"' > test_script.tcl
31+
if OUTPUT=$(./openroad -no_init -no_splash -exit test_script.tcl 2>&1) && echo "$OUTPUT" | grep -q "install_test_ok"; then
32+
echo "PASS: installed binary started successfully"
33+
else
34+
echo "FAIL: installed binary failed to start or produced unexpected output"
35+
echo "Output was: $OUTPUT"
36+
exit 1
37+
fi

0 commit comments

Comments
 (0)