Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel build includes unused LLVM targets #16915

Closed
ScottTodd opened this issue Mar 27, 2024 · 2 comments · Fixed by #18533
Closed

Bazel build includes unused LLVM targets #16915

ScottTodd opened this issue Mar 27, 2024 · 2 comments · Fixed by #18533
Labels
infrastructure Relating to build systems, CI, or testing quality of life 😊 Nice things are nice; let's have some

Comments

@ScottTodd
Copy link
Member

The upstream LLVM Bazel build has a list of LLVM targets that get unconditionally included in our builds: https://github.com/llvm/llvm-project/blob/009f88fc0e3a036be97ef7b222b90af342bae0b7/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel#L1857-L2189 . These dramatically inflate build times, as compiling these targets is one of the slowest parts of an LLVM source build.

  • AArch64
  • ARM
  • AMDGPU
  • AVR
  • BPF
  • Hexagon
  • Lanai
  • LoongArch
  • Mips
  • MSP430
  • NVPTX
  • PowerPC
  • Sparc
  • SystemZ
  • RISCV
  • VE
  • WebAssembly
  • X86
  • XCore

I'm seeing those targets get built with bazel build //tools:iree-opt. Could run some queries to see how the targets are specifically getting pulled in.

In our CMake build we conditionally enable targets based on configuration settings: https://github.com/openxla/iree/blob/d6357b4bbc55c9be36aa3bbe4c55f0fe1c2a010f/build_tools/cmake/iree_llvm.cmake#L128-L130
Bazel could either do the same with configs/selects, or it could at least be trimmed to just the set of targets that we use/support: https://github.com/openxla/iree/blob/d6357b4bbc55c9be36aa3bbe4c55f0fe1c2a010f/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp#L486-L494

@ScottTodd ScottTodd added infrastructure Relating to build systems, CI, or testing quality of life 😊 Nice things are nice; let's have some labels Mar 27, 2024
@ScottTodd ScottTodd changed the title LLVM Bazel build includes unused LLVM targets Bazel build includes unused LLVM targets Mar 27, 2024
@benvanik
Copy link
Collaborator

lol sparc and systemz

@ScottTodd
Copy link
Member Author

Found where we can configure this: https://github.com/llvm/llvm-project/blob/main/utils/bazel/configure.bzl

DEFAULT_TARGETS = [
    "AArch64",
    "AMDGPU",
    "ARM",
    "AVR",
    "BPF",
    "Hexagon",
    "Lanai",
    "LoongArch",
    "Mips",
    "MSP430",
    "NVPTX",
    "PowerPC",
    "RISCV",
    "Sparc",
    "SystemZ",
    "VE",
    "WebAssembly",
    "X86",
    "XCore",
]
...

llvm_configure = repository_rule(
    implementation = _llvm_configure_impl,
    local = True,
    configure = True,
    attrs = {
        "targets": attr.string_list(default = DEFAULT_TARGETS),
    },
)

Called here:

iree/WORKSPACE

Line 42 in 7d823d2

llvm_configure(name = "llvm-project")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Relating to build systems, CI, or testing quality of life 😊 Nice things are nice; let's have some
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants