Skip to content
Merged
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
76 changes: 76 additions & 0 deletions .github/workflows/cpu_linux_x86_64_linux_aarch64_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,85 @@ jobs:
--platforms=//common:linux_aarch64 \
//cc/tests/cpu:all

- name: "Clang 18, Glibc 2.27, libc++ static linking | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--@rules_ml_toolchain//common:stdlib=libc++ \
--@rules_ml_toolchain//common:static_libcxx=true \
//cc/tests/cpu:all

- name: "Bzlmod. Clang 18, Glibc 2.27 | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--config=bzlmod \
//cc/tests/cpu:all

- name: "Bzlmod. Clang 18, Glibc 2.27, libc++ static linking | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--@rules_ml_toolchain//common:stdlib=libc++ \
--@rules_ml_toolchain//common:static_libcxx=true \
--config=bzlmod \
//cc/tests/cpu:all

- name: "Clang 21, Glibc 2.31 | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--repo_env=LLVM_VERSION=21 \
--repo_env=SYSROOT_DIST=linux_glibc_2_31 \
//cc/tests/cpu:all

- name: "Bzlmod. Clang 21, Glibc 2.31 | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--repo_env=LLVM_VERSION=21 \
--repo_env=SYSROOT_DIST=linux_glibc_2_31 \
--config=bzlmod \
//cc/tests/cpu:all

# TODO: Replace `build` to `test` and run //cc/tests/cpu:all when GitHub runners will be updated to Ubuntu 24
- name: "Bzlmod. Clang 22, Glibc 2.31 | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--repo_env=LLVM_VERSION=22 \
--repo_env=SYSROOT_DIST=linux_glibc_2_31 \
--config=bzlmod \
//cc/tests/cpu:all

- name: "Clang 21, Glibc 2.31, libc++ static linking | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--repo_env=LLVM_VERSION=21 \
--repo_env=SYSROOT_DIST=linux_glibc_2_31 \
--@rules_ml_toolchain//common:stdlib=libc++ \
--@rules_ml_toolchain//common:static_libcxx=true \
//cc/tests/cpu:all

# TODO: Replace `build` to `test` and run //cc/tests/cpu:all when GitHub runners will be updated to Ubuntu 24
- name: "Clang 22, Glibc 2.31, libc++ static linking | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--repo_env=LLVM_VERSION=22 \
--repo_env=SYSROOT_DIST=linux_glibc_2_31 \
--@rules_ml_toolchain//common:stdlib=libc++ \
--@rules_ml_toolchain//common:static_libcxx=true \
//cc/tests/cpu:all

- name: "Bzlmod. Clang 22, Glibc 2.31, libc++ static linking | Testing..."
run: |
bazel build --color=yes \
--platforms=//common:linux_aarch64 \
--repo_env=LLVM_VERSION=22 \
--repo_env=SYSROOT_DIST=linux_glibc_2_31 \
--@rules_ml_toolchain//common:stdlib=libc++ \
--@rules_ml_toolchain//common:static_libcxx=true \
--config=bzlmod \
//cc/tests/cpu:all
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ When the executor and the target are the same, a non-hermetic GPU build can stil

For details, look at the `.bazelrc` file, specifically the `cuda_clang_local` configuration.

<!--
### Cross-platform builds
Project supports cross-platform builds only on Linux x86_64 executor
and allows build for such targets:
* Linux aarch64
* macOS aarch64
<!--* macOS aarch64-->

#### Build for Linux aarch64
`bazel build //cc/tests/cpu/... --platforms=//common:linux_aarch64`

<!--
#### Build for macOS aarch64
[Prepare SDK](cc/sysroots/darwin_aarch64/README.md) before run the following command.

Expand Down
114 changes: 68 additions & 46 deletions cc/impls/linux_x86_64_linux_aarch64/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
# Tools: Linux x86_64, Sysroot: Linux aarch64
# ==============================================================================

load("@rules_cc//cc:defs.bzl", "cc_toolchain")

load("//cc/config:constants.bzl", "LIBCXX_FLAGS")
load("//third_party/rules_cc_toolchain:toolchain_config.bzl", "cc_toolchain_config")
load("//third_party/rules_cc_toolchain/features:cc_toolchain_import.bzl", "cc_toolchain_import")
load("//third_party/rules_cc_toolchain/features:features.bzl", "cc_toolchain_import_feature")
Expand Down Expand Up @@ -49,15 +48,33 @@ cc_toolchain_import_feature(
toolchain_import = ":startup_libs",
)

alias(
name = "std_incs",
actual = select({
"//common:is_stdlib_libcxx": "@llvm_linux_aarch64//:std_incs" ,
"//conditions:default": "@sysroot_linux_aarch64//:std_incs",
})
)

alias(
name = "std_libs",
actual = select({
"//common:is_stdlib_libcxx": "@llvm_linux_aarch64//:std_libs" ,
"//conditions:default": "@sysroot_linux_aarch64//:std_libs",
})
)

# buildifier: leave-alone
cc_toolchain_import(
name = "imports",
deps = [
"@sysroot_linux_aarch64//:std_incs",
":std_incs",
"@llvm_linux_x86_64//:compiler_incs",
"@sysroot_linux_aarch64//:sys_incs",
"@sysroot_linux_aarch64//:sys_libs",
"@sysroot_linux_aarch64//:std_libs",
":std_libs",
"@sysroot_linux_aarch64//:openmp",
"@llvm_linux_aarch64//:libclang_rt",
],
visibility = ["//visibility:public"],
)
Expand All @@ -66,6 +83,10 @@ cc_toolchain_import_feature(
name = "imports_feature",
enabled = True,
toolchain_import = ":imports",
static_link_flags = select({
"//common:is_static_libcxx": LIBCXX_FLAGS,
"//conditions:default": [],
}),
)

# buildifier: leave-alone
Expand All @@ -83,7 +104,7 @@ filegroup(
filegroup(
name = "compiler",
srcs = [
":all",
":imports",
":wrappers",
"@llvm_linux_x86_64//:clang",
"@llvm_linux_x86_64//:clang++",
Expand Down Expand Up @@ -134,51 +155,52 @@ filegroup(
],
)

FEATURES_ESSENTIAL = [
"//third_party/rules_cc_toolchain/features:hermetic_libraries", # Hermetic libraries feature required before import
":imports_feature",

# Toolchain configuration
"//third_party/rules_cc_toolchain/features:warnings",
"//third_party/rules_cc_toolchain/features:errors",
"//third_party/rules_cc_toolchain/features:reproducible",
"//third_party/rules_cc_toolchain/features:language",
"//third_party/rules_cc_toolchain/features:use_lld",
"//cc/features:sysroot_linux_aarch64",
":startup_libs_feature",
"//third_party/rules_cc_toolchain/features:coverage",
#"//cc/features:clang19", # TODO: Add a selection mechanism based on the Clang version

# PIC / PIE flags
"//third_party/rules_cc_toolchain/features:supports_pic",
"//third_party/rules_cc_toolchain/features:position_independent_code",
"//third_party/rules_cc_toolchain/features:position_independent_executable",

# Optimization flags
"//third_party/rules_cc_toolchain/features:garbage_collect_symbols",
"//cc/features:constants_merge",
"//cc/features:dbg",
"//cc/features:fastbuild",
"//cc/features:opt",
"//cc/features:detect_issues",
"//cc/features:detect_issues_ext",

# C++ standard flags
"//third_party/rules_cc_toolchain/features:c++11",
"//third_party/rules_cc_toolchain/features:c++14",
"//third_party/rules_cc_toolchain/features:c++17",

# Other flags
"//cc/features:allow_shlib_undefined",
"//cc/features:supports_dynamic_linker",
"//cc/features:supports_start_end_lib_feature",
]

cc_toolchain_config(
name = "config",
archiver = "@llvm_linux_x86_64//:ar",
c_compiler = "@llvm_linux_x86_64//:clang",
cc_compiler = "@llvm_linux_x86_64//:clang++",
compiler_features = [
# Hermetic libraries feature required before import.
"//third_party/rules_cc_toolchain/features:hermetic_libraries",
":imports_feature",

# Toolchain configuration
"//third_party/rules_cc_toolchain/features:warnings",
"//third_party/rules_cc_toolchain/features:errors",
"//third_party/rules_cc_toolchain/features:reproducible",
"//third_party/rules_cc_toolchain/features:language",
"//third_party/rules_cc_toolchain/features:use_lld",
"//cc/features:sysroot_linux_aarch64",
":startup_libs_feature",
"//third_party/rules_cc_toolchain/features:coverage",
#"//cc/features:clang19", # TODO: Add a selection mechanism based on the Clang version

# PIC / PIE flags
"//third_party/rules_cc_toolchain/features:supports_pic",
"//third_party/rules_cc_toolchain/features:position_independent_code",
"//third_party/rules_cc_toolchain/features:position_independent_executable",

# Optimization flags
"//third_party/rules_cc_toolchain/features:garbage_collect_symbols",
"//cc/features:constants_merge",
"//cc/features:dbg",
"//cc/features:fastbuild",
"//cc/features:opt",
"//cc/features:detect_issues",
"//cc/features:detect_issues_ext",

# C++ standard configuration
"//third_party/rules_cc_toolchain/features:c++11",
"//third_party/rules_cc_toolchain/features:c++14",
"//third_party/rules_cc_toolchain/features:c++17",

#
"//cc/features:allow_shlib_undefined",
"//cc/features:supports_dynamic_linker",
"//cc/features:supports_start_end_lib_feature",
],
compiler_features = FEATURES_ESSENTIAL,
linker = "@llvm_linux_x86_64//:ld",
strip_tool = "@llvm_linux_x86_64//:strip",
target_cpu = "aarch64",
Expand All @@ -196,5 +218,5 @@ cc_toolchain(
strip_files = ":strip",
supports_param_files = 1,
toolchain_config = ":config",
toolchain_identifier = "toolchain_id_linux_x86_64_linux_aarch64",
toolchain_identifier = "toolchain_id_linux_x86_64_linux_aarch64_id",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to double check that if the ID here is correct or not? Asking since I thought we'd remove x86_64 in the naming, but totally fine if that's intentional.

Copy link
Copy Markdown
Collaborator Author

@yuriivcs yuriivcs May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It's correct. I've changed the ID because we use the same convention for other toolchains' identifier. For example:
toolchain_linux_aarch64_linux_aarch64_id
toolchain_linux_x86_64_linux_x86_64_id

)
16 changes: 0 additions & 16 deletions cc/llvms/llvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ load(
_LLVM_VERSION = "LLVM_VERSION"
_STATIC_LIBCXX = "STATIC_LIBCXX"

def _get_platform_arch(ctx):
"""Gets current platform architecture"""
if ctx.os.arch == "amd64":
return "x86_64"
else:
return ctx.os.arch

def _is_compatible_arch(ctx):
"""Checks if LLVM compatible with current platform"""
return ctx.attr.name.endswith(_get_platform_arch(ctx))

def _get_llvm_version_flag(ctx):
"""Returns LLVM version put as environment variable"""
return get_host_environ(ctx, _LLVM_VERSION)
Expand Down Expand Up @@ -62,11 +51,6 @@ def _create_version_file(ctx, major_version):
)

def _llvm_impl(ctx):
if not _is_compatible_arch(ctx):
_create_version_file(ctx, "")
ctx.file("BUILD", "")
return

ver = _get_llvm_version(ctx)
llvm_label = _get_llvm_label(ctx, ver)
if not llvm_label:
Expand Down
Loading