Skip to content

storypku/llvm-x-toolchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unified Clang-based Bazel Toolchains w/ CUDA and X-Compilation Support

Introduction

Cross compilation is a common practice for embedded and autonomous driving systems. As the time of this writing, configuration of Clang-based Bazel toolchains w/ CUDA support on Linux was still challenging. As John Millikin pointed out(Ref):

It assumes background knowledge in cross compilation, plus experience with Bazel's Starlark extension language, build rules, and repository definitions. Most users of Bazel shouldn't need to care about the details of compiler toolchains, but this is important stuff for maintainers of language rules.

This project was an attempt to address this issue, by integrating existing work by grailbio/bazel-toolchain and tf_runtime/rules_cuda.

Examples

Please refer to scripts in the tests/scripts/run_tests directory for examples.

Requirements

Bazel 5.3 or newer (might work with older versions). This project was tested w/ Bazel 5.3.2 on Ubuntu 18.04 and 20.04.

Known Issues

For my own use case, this project was tailored to work w/ LLVM/Clang >= 13.0.1 on Ubuntu releases >= 18.04 (Windows and MacOS Support present in grailbio/bazel-toolchain was removed).

Future Work

It seems the rules_cuda project inside tensorflow/runtime has evolved into an independent, full-fedged CUDA rules for Bazel project. So we might switch to using this repo as cuda_library implementation if possible.

Credits

This work was impossible without these excellent projects besides Bazel.

  1. The LLVM toolchain for Bazel project
  2. The tf_runtime/rules_cuda: CUDA rules for Bazel project.