Skip to content

Issue Building OpenROAD on Arm Mac with Bazel #9529

@yanghuaxuan

Description

@yanghuaxuan

Describe the bug

There seems to be a minor issue with building OpenROAD with Bazel on Arm Macs. Specifically, the issue appears to be caused by not including the util/MachineApple.cc file in the Bazel BUILD file for building OpenSTA.

Expected Behavior

Running bazelisk run --//:platform=cli //:install --copt="-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED"
should install a locally built version of OpenROAD for Arm64 Mac.

Environment

[WARNING] Your current OpenROAD version is outdated.
It is recommened to pull the latest changes.
If problem persists, file a github issue with the re-producible test case.
kernel: Darwin 25.2.0
os: 		macOS 		26.2
cmake version 4.1.1
CMake Error at /opt/homebrew/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:227 (message):
  Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) (Required is at
  least version "4.0")
Call Stack (most recent call first):
  /opt/homebrew/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:591 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/share/cmake/Modules/FindSWIG.cmake:184 (find_package_handle_standard_args)
  src/CMakeLists.txt:141 (find_package)


-- The CXX compiler identification is AppleClang 17.0.0.17000404
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- OpenROAD version: 26Q1-1144-g809a904c3f
-- System name: Darwin
-- Compiler: AppleClang 17.0.0.17000404
-- Build type: RELEASE
-- Install prefix: /usr/local
-- C++ Standard: 20
-- C++ Standard Required: ON
-- C++ Extensions: OFF
-- LTO/IPO is enabled
-- The C compiler identification is AppleClang 17.0.0.17000404
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test C_COMPILER_SUPPORTS__-Wno-array-bounds
-- Performing Test C_COMPILER_SUPPORTS__-Wno-array-bounds - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-array-bounds
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-array-bounds - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-nonnull
-- Performing Test C_COMPILER_SUPPORTS__-Wno-nonnull - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-nonnull
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-nonnull - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-maybe-uninitialized
-- Performing Test C_COMPILER_SUPPORTS__-Wno-maybe-uninitialized - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-maybe-uninitialized
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-maybe-uninitialized - Failed
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format-overflow
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format-overflow - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format-overflow
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format-overflow - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-variable
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-variable - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-variable
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-variable - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-function
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-function - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-function
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-function - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-write-strings
-- Performing Test C_COMPILER_SUPPORTS__-Wno-write-strings - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-write-strings
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-write-strings - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-sign-compare
-- Performing Test C_COMPILER_SUPPORTS__-Wno-sign-compare - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-sign-compare
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-sign-compare - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-deprecated
-- Performing Test C_COMPILER_SUPPORTS__-Wno-deprecated - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-deprecated
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-deprecated - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-c++11-narrowing
-- Performing Test C_COMPILER_SUPPORTS__-Wno-c++11-narrowing - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-c++11-narrowing
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-c++11-narrowing - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-register
-- Performing Test C_COMPILER_SUPPORTS__-Wno-register - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-register
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-register - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal
-- Performing Test C_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-alloc-size-larger-than
-- Performing Test C_COMPILER_SUPPORTS__-Wno-alloc-size-larger-than - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-alloc-size-larger-than
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-alloc-size-larger-than - Failed
-- Performing Test C_COMPILER_SUPPORTS__-Wno-attributes
-- Performing Test C_COMPILER_SUPPORTS__-Wno-attributes - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-attributes
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-attributes - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-aggressive-loop-optimizations
-- Performing Test C_COMPILER_SUPPORTS__-Wno-aggressive-loop-optimizations - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-aggressive-loop-optimizations
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-aggressive-loop-optimizations - Failed
-- Performing Test C_COMPILER_SUPPORTS__-Wno-stringop-overflow
-- Performing Test C_COMPILER_SUPPORTS__-Wno-stringop-overflow - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-stringop-overflow
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-stringop-overflow - Failed
-- Performing Test C_COMPILER_SUPPORTS__-Wno-changes-meaning
-- Performing Test C_COMPILER_SUPPORTS__-Wno-changes-meaning - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-changes-meaning
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-changes-meaning - Failed
-- Performing Test C_COMPILER_SUPPORTS__-fpermissive
-- Performing Test C_COMPILER_SUPPORTS__-fpermissive - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-fpermissive
-- Performing Test CXX_COMPILER_SUPPORTS__-fpermissive - Success
-- Performing Test C_COMPILER_SUPPORTS__-x
-- Performing Test C_COMPILER_SUPPORTS__-x - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-x
-- Performing Test CXX_COMPILER_SUPPORTS__-x - Failed
-- Performing Test C_COMPILER_SUPPORTS__c++
-- Performing Test C_COMPILER_SUPPORTS__c++ - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__c++
-- Performing Test CXX_COMPILER_SUPPORTS__c++ - Failed
-- Performing Test C_COMPILER_SUPPORTS__-std=c++17
-- Performing Test C_COMPILER_SUPPORTS__-std=c++17 - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-std=c++17
-- Performing Test CXX_COMPILER_SUPPORTS__-std=c++17 - Success
-- Performing Test C_COMPILER_SUPPORTS__-fno-exceptions
-- Performing Test C_COMPILER_SUPPORTS__-fno-exceptions - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-fno-exceptions
-- Performing Test CXX_COMPILER_SUPPORTS__-fno-exceptions - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-but-set-variable
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-but-set-variable - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-but-set-variable
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-but-set-variable - Success
-- TCL library: TCL_LIBRARY-NOTFOUND
-- TCL header: TCL_HEADER-NOTFOUND
-- Configuring incomplete, errors occurred!

To Reproduce

  1. Clone The-OpenROAD-Project/OpenROAD at commit 809a904c3ff84c945ebd200f565344facf1c4f58
  2. Build with Bazel
    bazelisk run --//:platform=cli //:install --copt="-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED"

Relevant log output

INFO: Invocation ID: 6db7da4d-4f4f-4858-8fd2-c4ae228d9b17
INFO: Analyzed target //:install (1 packages loaded, 971 targets configured).
ERROR: /Users/raph/OpenROAD/src/sta/BUILD:303:11: Compiling src/sta/util/Machine.cc failed: (Exit 1): cc_wrapper.sh failed: error executing CppCompile command (from target //src/sta:opensta_lib) external/toolchains_llvm++llvm+llvm_toolchain/bin/cc_wrapper.sh -U_FORTIFY_SOURCE '--target=aarch64-apple-macosx' -U_FORTIFY_SOURCE -fstack-protector -fno-omit-frame-pointer -fcolor-diagnostics -Wall ... (remaining 190 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
src/sta/util/Machine.cc:28:12: fatal error: 'MachineApple.cc' file not found
   28 |   #include "MachineApple.cc"
      |            ^~~~~~~~~~~~~~~~~
1 error generated.
Target //:install failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 65.188s, Critical Path: 62.18s
INFO: 267 processes: 6061 action cache hit, 10 disk cache hit, 202 internal, 55 darwin-sandbox.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

Screenshots

No response

Additional Context

The --copt="-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED" was to fix another issue encountered while building with MacOS due to Boost.Stacktrace requiring _GNU_SOURCE macro.

Appending util/MachineApple.cc to textual_hdrs to BUILD seems to fix building locally with Bazel for me. See The-OpenROAD-Project/OpenSTA#292

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions