Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ OPENROAD_COPTS = [

OPENROAD_DEFINES = [
"BUILD_TYPE=\\\"$(COMPILATION_MODE)\\\"",
"BAZEL_BUILD",
Comment thread
hzeller marked this conversation as resolved.
"GPU=false",
"BUILD_PYTHON=false",
"ABC_NAMESPACE=abc",
Expand Down Expand Up @@ -178,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",
Expand All @@ -187,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",
]

Expand Down
1 change: 0 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion bazel/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -eu

# Install binary and runfiles from bazel build

Expand Down Expand Up @@ -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")"
Expand Down
37 changes: 3 additions & 34 deletions src/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
#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
Comment thread
hzeller marked this conversation as resolved.

#include "tcl_readline_setup.h"
Expand Down Expand Up @@ -185,32 +184,6 @@ static void initPython()

static volatile sig_atomic_t fatal_error_in_progress = 0;

#ifdef BAZEL_CURRENT_REPOSITORY
// 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.
Expand Down Expand Up @@ -260,10 +233,6 @@ int main(int argc, char* argv[])
signal(SIGILL, handler);
signal(SIGSEGV, handler);

#ifdef BAZEL_CURRENT_REPOSITORY
setupBazelRunfilesEnvironment();
#endif

if (argc == 2 && stringEq(argv[1], "-help")) {
showUsage(argv[0], init_filename);
return 0;
Expand Down Expand Up @@ -385,7 +354,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;
}
Expand Down Expand Up @@ -616,7 +585,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
Expand Down
7 changes: 0 additions & 7 deletions src/par/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
1 change: 0 additions & 1 deletion src/syn/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ cc_library(
"//src/syn/src/ir",
"//src/utl",
"@abc",
"@boost.stacktrace",
],
)

Expand Down
39 changes: 0 additions & 39 deletions test/install/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
#
Expand Down
Loading