Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ build --cxxopt "-std=c++20" --host_cxxopt "-std=c++20"
build --cxxopt "-xc++" --host_cxxopt "-xc++"
build --cxxopt "-DBAZEL_BUILD" --host_cxxopt "-DBAZEL_BUILD"

# Default to optimized build (-c opt), O3
# Default to optimized build (-c opt)
build -c opt
build:opt --copt=-O3

# Enable Full-LTO (Link Time Optimization)
# Settings for --config=opt build: Enable -O3 and Full-LTO for performance
build:opt --copt=-O3
build:opt --copt=-flto
build:opt --linkopt=-flto

Expand Down
18 changes: 18 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@openroad_rules_python//python:defs.bzl", "py_library")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//bazel:notification.bzl", "notification_rule")
load("//bazel:python_wrap_cc.bzl", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
Expand All @@ -18,6 +19,22 @@ package(
],
)

# Notification target to notify user if --config=opt (with LTO) is not used.
notification_rule(
name = "opt_notification",
is_opt = select(
{
":lto_on": True,
"//conditions:default": False,
},
),
)

config_setting(
name = "lto_on",
values = {"copt": "-flto"},
)

exports_files([
"LICENSE",
"src/Design.i",
Expand Down Expand Up @@ -153,6 +170,7 @@ cc_binary(
deps = [
":openroad_lib",
":openroad_version",
":opt_notification",
":ord",
"//bazel:runfiles",
"//src/cut",
Expand Down
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ cmake_policy(SET CMP0077 NEW)
# Let AUTOMOC and AUTOUIC process GENERATED files.
cmake_policy(SET CMP0071 NEW)

# Interfers with Qt so off by default.
option(LINK_TIME_OPTIMIZATION "Flag to control link time optimization: off by default" OFF)

if (LINK_TIME_OPTIMIZATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

# Allow to use external shared boost libraries
option(USE_SYSTEM_BOOST "Use system shared Boost libraries" OFF)

Expand Down
24 changes: 24 additions & 0 deletions bazel/notification.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2025, Precision Innovations Inc.

"""Rule to provide build-time notifications."""

load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

def _notification_impl(ctx):
if not ctx.attr.is_opt:
# buildifier: disable=print
print("\n" + "=" * 80 + "\n" +
" NOTIFICATION: Use --config=opt to build with LTO (Link Time Optimization)\n" +
" and get better performance at the expense of longer build time.\n" +
"=" * 80 + "\n")
return [CcInfo()]

notification_rule = rule(
implementation = _notification_impl,
attrs = {
# Set to True when the build configuration enables LTO (via --config=opt).
# When True, the notification message is suppressed.
"is_opt": attr.bool(default = False),
},
)