Skip to content

[WIP] bazel: Add LLVM toolchain #29415

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ build:windows --action_env=PATH --host_action_env=PATH
# Requires setting `BAZEL_VOLATILE_DIRTY` in the env.
build --action_env=BAZEL_VOLATILE_DIRTY --host_action_env=BAZEL_VOLATILE_DIRTY

# Prevent stamped caches from busting (eg in PRs)
# Requires setting `BAZEL_FAKE_SCM_REVISION` in the env.
build --action_env=BAZEL_FAKE_SCM_REVISION --host_action_env=BAZEL_FAKE_SCM_REVISION

# build --incompatible_enable_cc_toolchain_resolution

# build --enable_platform_specific_config
build --test_summary=terse

build:docs-ci --action_env=DOCS_RST_CHECK=1 --host_action_env=DOCS_RST_CHECK=1
Expand Down
4 changes: 4 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ envoy_dependency_imports()
load("//bazel:dependency_imports_extra.bzl", "envoy_dependency_imports_extra")

envoy_dependency_imports_extra()

load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")

llvm_register_toolchains()
6 changes: 6 additions & 0 deletions bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
load("@rules_rust//rust:defs.bzl", "rust_common")
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains", "rust_repository_set")
load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")

# go version for rules_go
GO_VERSION = "1.23.1"
Expand Down Expand Up @@ -175,6 +176,11 @@ def envoy_dependency_imports(go_version = GO_VERSION, jq_version = JQ_VERSION, y
protoc_gen_jsonschema_go_dependencies()
rules_proto_grpc_toolchains()

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "14.0.0",
)

def envoy_download_go_sdks(go_version):
go_download_sdk(
name = "go_linux_amd64",
Expand Down
1 change: 1 addition & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def envoy_dependencies(skip_targets = []):
external_http_archive("bazel_toolchains")
external_http_archive("bazel_compdb")
external_http_archive("envoy_examples")
external_http_archive("toolchains_llvm")

_com_github_maxmind_libmaxminddb()

Expand Down
3 changes: 3 additions & 0 deletions bazel/repositories_extra.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_baze
load("@emsdk//:deps.bzl", emsdk_deps = "deps")
load("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:crates.bzl", "crate_repositories")
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")
load("//bazel/external/cargo:crates.bzl", "raze_fetch_remote_crates")

def _python_minor_version(python_version):
Expand Down Expand Up @@ -34,3 +35,5 @@ def envoy_dependencies_extra(

if not native.existing_rule("proto_bazel_features"):
proto_bazel_features(name = "proto_bazel_features")

bazel_toolchain_dependencies()
13 changes: 13 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,19 @@ REPOSITORY_LOCATIONS_SPEC = dict(
license = "Apache-2.0",
license_url = "https://github.com/bazelbuild/rules_license/blob/{version}/LICENSE",
),
toolchains_llvm = dict(
project_name = "toolchains_llvm",
project_desc = "A LLVM toolchain for bazel",
project_url = "https://github.com/bazel-contrib/toolchains_llvm",
strip_prefix = "toolchains_llvm-v{version}",
version = "1.2.0",
sha256 = "e3fb6dc6b77eaf167cb2b0c410df95d09127cbe20547e5a329c771808a816ab4",
urls = ["https://github.com/bazel-contrib/toolchains_llvm/releases/download/v{version}/toolchains_llvm-v{version}.tar.gz"],
use_category = [],
extensions = [],
release_date = "2023-01-06",
cpe = "N/A",
),
utf8_range = dict(
project_name = "utf8_range",
project_desc = "Fast UTF-8 validation with Range algorithm (NEON+SSE4+AVX2)",
Expand Down