Skip to content

Commit

Permalink
Use a prebuilt clang/LLVM to make the build hermetic
Browse files Browse the repository at this point in the history
LLVM version 16.0.4 was chosen for parity with our current developer
desktop setup. This can be changed later.

Upsides:
- Consistent compiler behavior across OS versions, supporting our ubuntu
  20.04 and debian 11 users.
- We can upgrade on our own schedule to a newer clang and access fancy
  new features such as c++20 and newer clang-tidy lints.

Downsides:
- Extra time / bandwidth on a fresh (`bazel clean --expunge`) build.
- We move one step further away from being a "regular debian citizen" as
  we fetch more dependencies outside of debian's own package graph.
  • Loading branch information
Databean committed Dec 14, 2024
1 parent 2fb78e8 commit 2f9a158
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Setup apt
run: apt update -y && apt upgrade -y
- name: Install dependencies
run: apt install -y git clang libcurl4-openssl-dev clang-tidy
run: apt install -y git clang libcurl4-openssl-dev clang-tidy libtinfo5
- name: Install bazel
run: bash tools/buildutils/installbazel.sh
- name: Build cvd
Expand Down
2 changes: 1 addition & 1 deletion base/cvd/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build --copt=-fdiagnostics-color=always
build --repo_env=CC=clang

build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
build:clang-tidy --output_groups=report
build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config
build:clang-tidy --@bazel_clang_tidy//:clang_tidy_executable=@llvm_toolchain//:clang-tidy
12 changes: 12 additions & 0 deletions base/cvd/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ git_override(
commit = "f23d924918c581c68cd5cda5f12b4f8198ac0c35",
remote = "https://github.com/erenon/bazel_clang_tidy.git",
)

bazel_dep(name = "toolchains_llvm", version = "1.2.0")

# Configure and register the toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
llvm_version = "16.0.4",
)

use_repo(llvm, "llvm_toolchain")

register_toolchains("@llvm_toolchain//:all")
77 changes: 77 additions & 0 deletions base/cvd/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions base/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ Source: cuttlefish-common
Maintainer: Cuttlefish Team
Section: misc
Priority: optional
Build-Depends: config-package-dev,
debhelper-compat (= 12),
Build-Depends: bazel [amd64],
clang,
pkg-config,
config-package-dev,
debhelper-compat (= 12),
git,
libcurl4-openssl-dev,
libfmt-dev,
libgflags-dev,
libjsoncpp-dev,
libcurl4-openssl-dev,
libgoogle-glog-dev,
libgtest-dev,
libjsoncpp-dev,
libtinfo5,
libprotobuf-c-dev,
libprotobuf-dev,
libssl-dev,
libxml2-dev,
uuid-dev,
libprotobuf-dev,
libprotobuf-c-dev,
protobuf-compiler,
libz3-dev,
pkg-config,
protobuf-compiler,
sed,
git,
bazel [amd64]
uuid-dev
Standards-Version: 4.5.0

Package: cuttlefish-base
Expand Down

0 comments on commit 2f9a158

Please sign in to comment.