Aniss Lan

A place to record life

Set up llvm lit test with bazel

Lit is an important tool in llvm project to do text-based tests. This post records how to use lit in a bazel project. Most of the code are pulled from Tensorflow. I did some modification to make it more convinent to use them in a new project. For Setting up project based on llvm, please see my previous post: https://anissl93.github.io/posts/proj_llvm_bazel/, The full code is in build_llvm_with_bazel, and the bazel helpers here bazel_tools...

<span title='2023-11-21 00:44:05 +0800 +0800'>November 21, 2023</span>

Setup a project depending on llvm using bazel

Create your repo, such as "BuildWithLLVM" To add a local repo, copy following files to BuildWithLLVM llvm-project/utils/bazel/WORKSPACE .bazelrc .bazelversion .bazelignore Add workspace name to the start of WORKSPACE file workspace(name = "build_with_llvm") Change path in WORKSPACE new_local_repository( name = "llvm-raw", build_file_content = "# empty", # change path pointing to your llvm-project path = "/path/to/llvm-project", ) Test the build bazel build --config=generic_gcc @llvm-project//llvm:all Build something depending on llvm Add a c++ source file main....

<span title='2023-11-16 22:28:34 +0800 +0800'>November 16, 2023</span>