CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
481 lines
12 KiB
Python
481 lines
12 KiB
Python
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
|
|
|
package(
|
|
default_visibility = ["//visibility:public"],
|
|
features = ["layering_check"],
|
|
)
|
|
|
|
licenses(["notice"])
|
|
|
|
cc_library(
|
|
name = "config",
|
|
defines = select({
|
|
"@platforms//os:linux": [
|
|
"COMPILER_RT_BUILD_PROFILE_ROCM=1",
|
|
"COMPILER_RT_HAS_ATOMICS=1",
|
|
"COMPILER_RT_HAS_FCNTL_LCK=1",
|
|
"COMPILER_RT_HAS_UNAME=1",
|
|
],
|
|
# Will raise error unless supported platforms.
|
|
}),
|
|
target_compatible_with = select({
|
|
"@platforms//os:linux": [],
|
|
"//conditions:default": ["@platforms//:incompatible"],
|
|
}),
|
|
)
|
|
|
|
WIN32_ONLY_FILES = [
|
|
"lib/profile/WindowsMMap.c",
|
|
]
|
|
|
|
cc_library(
|
|
name = "sanitizer_common_headers",
|
|
hdrs = glob([
|
|
"lib/sanitizer_common/*.h",
|
|
"lib/sanitizer_common/*.inc",
|
|
"lib/sanitizer_common/*.inc.S",
|
|
]),
|
|
includes = ["lib"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "sanitizer_common",
|
|
srcs = glob(
|
|
[
|
|
"lib/sanitizer_common/*.cpp",
|
|
],
|
|
),
|
|
linkstatic = True,
|
|
deps = [
|
|
":interception",
|
|
":sanitizer_common_headers",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "interception",
|
|
srcs = glob(["lib/interception/*.cpp"]),
|
|
hdrs = glob(["lib/interception/*.h"]),
|
|
copts = [
|
|
"-fomit-frame-pointer",
|
|
"-fvisibility=hidden",
|
|
],
|
|
includes = ["lib"],
|
|
linkstatic = True,
|
|
deps = [
|
|
":sanitizer_common_headers",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "profile",
|
|
srcs = glob(
|
|
[
|
|
"lib/profile/*.c",
|
|
"lib/profile/*.cpp",
|
|
"lib/profile/*.h",
|
|
],
|
|
exclude = WIN32_ONLY_FILES,
|
|
) + select({
|
|
"@platforms//os:windows": WIN32_ONLY_FILES,
|
|
"//conditions:default": [],
|
|
}),
|
|
hdrs = glob([
|
|
"include/profile/*.h",
|
|
"include/profile/*.inc",
|
|
]),
|
|
includes = [
|
|
"include",
|
|
],
|
|
linkstatic = True,
|
|
deps = [
|
|
":config",
|
|
":interception",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "orc_rt_common_headers",
|
|
hdrs = [
|
|
"lib/orc/adt.h",
|
|
"lib/orc/bitmask_enum.h",
|
|
"lib/orc/common.h",
|
|
"lib/orc/compiler.h",
|
|
"lib/orc/debug.h",
|
|
"lib/orc/endianness.h",
|
|
"lib/orc/error.h",
|
|
"lib/orc/executor_address.h",
|
|
"lib/orc/executor_symbol_def.h",
|
|
"lib/orc/interval_map.h",
|
|
"lib/orc/interval_set.h",
|
|
"lib/orc/jit_dispatch.h",
|
|
"lib/orc/record_section_tracker.h",
|
|
"lib/orc/rtti.h",
|
|
"lib/orc/simple_packed_serialization.h",
|
|
"lib/orc/stl_extras.h",
|
|
"lib/orc/string_pool.h",
|
|
"lib/orc/unique_function.h",
|
|
"lib/orc/wrapper_function_utils.h",
|
|
],
|
|
strip_include_prefix = "lib/orc",
|
|
)
|
|
|
|
cc_library(
|
|
name = "orc_rt",
|
|
srcs = [
|
|
"lib/orc/debug.cpp",
|
|
"lib/orc/dlfcn_wrapper.cpp",
|
|
"lib/orc/log_error_to_stderr.cpp",
|
|
"lib/orc/rtti.cpp",
|
|
"lib/orc/run_program_wrapper.cpp",
|
|
] + select({
|
|
"@platforms//os:macos": [
|
|
"lib/orc/macho_platform.cpp",
|
|
"lib/orc/macho_platform.h",
|
|
"lib/orc/macho_tlv.arm64.S",
|
|
"lib/orc/macho_tlv.x86-64.S",
|
|
],
|
|
"@platforms//os:linux": [
|
|
"lib/orc/elfnix_platform.cpp",
|
|
"lib/orc/elfnix_platform.h",
|
|
"lib/orc/elfnix_tls.aarch64.S",
|
|
"lib/orc/elfnix_tls.ppc64.S",
|
|
"lib/orc/elfnix_tls.x86-64.S",
|
|
],
|
|
}),
|
|
hdrs = glob(["include/orc_rt/*.h"]),
|
|
includes = ["include"],
|
|
linkstatic = True,
|
|
deps = [
|
|
":orc_rt_common_headers",
|
|
],
|
|
)
|
|
|
|
filegroup(
|
|
name = "fuzzer_installed_hdrs",
|
|
srcs = glob(["include/fuzzer/*.h"]),
|
|
)
|
|
|
|
filegroup(
|
|
name = "profile_installed_hdrs",
|
|
srcs = glob(["include/profile/*.h"]),
|
|
)
|
|
|
|
filegroup(
|
|
name = "sanitizer_installed_hdrs",
|
|
srcs = glob(["include/sanitizer/*.h"]),
|
|
)
|
|
|
|
BUILTINS_CRTBEGIN_SRCS = ["lib/builtins/crtbegin.c"]
|
|
|
|
filegroup(
|
|
name = "builtins_crtbegin_src",
|
|
srcs = BUILTINS_CRTBEGIN_SRCS,
|
|
)
|
|
|
|
BUILTINS_CRTEND_SRCS = ["lib/builtins/crtend.c"]
|
|
|
|
filegroup(
|
|
name = "builtins_crtend_src",
|
|
srcs = BUILTINS_CRTEND_SRCS,
|
|
)
|
|
|
|
BUILTINS_HOSTED_SRCS = [
|
|
"lib/builtins/clear_cache.c",
|
|
"lib/builtins/emutls.c",
|
|
"lib/builtins/enable_execute_stack.c",
|
|
"lib/builtins/eprintf.c",
|
|
]
|
|
|
|
# Source files in the builtins library that build on top of libc and are only
|
|
# appropriate in hosted environments.
|
|
filegroup(
|
|
name = "builtins_hosted_srcs",
|
|
srcs = BUILTINS_HOSTED_SRCS,
|
|
)
|
|
|
|
BUILTINS_BF16_SRCS_PATTERNS = [
|
|
"lib/builtins/*bf*.c",
|
|
]
|
|
|
|
# Source files for the 16-bit Brain floating-point number builtins.
|
|
filegroup(
|
|
name = "builtins_bf16_srcs",
|
|
srcs = glob(BUILTINS_BF16_SRCS_PATTERNS),
|
|
)
|
|
|
|
BUILTINS_X86_FP80_SRCS_PATTERNS = [
|
|
# `xc` marks 80-bit complex number builtins.
|
|
"lib/builtins/*xc*.c",
|
|
|
|
# `xf` marks 80-bit floating-point builtins.
|
|
"lib/builtins/*xf*.c",
|
|
]
|
|
|
|
# Source files for the 80-bit floating-point and complex number builtins.
|
|
filegroup(
|
|
name = "builtins_x86_fp80_srcs",
|
|
srcs = glob(
|
|
BUILTINS_X86_FP80_SRCS_PATTERNS,
|
|
exclude = BUILTINS_BF16_SRCS_PATTERNS,
|
|
),
|
|
)
|
|
|
|
BUILTINS_TF_SRCS_PATTERNS = [
|
|
# `tc` marks 128-bit complex number builtins.
|
|
"lib/builtins/*tc*.c",
|
|
|
|
# `tf` marks 128-bit floating-point builtins.
|
|
"lib/builtins/*tf*.c",
|
|
]
|
|
|
|
BUILTINS_TF_EXCLUDES = (
|
|
BUILTINS_HOSTED_SRCS +
|
|
BUILTINS_BF16_SRCS_PATTERNS +
|
|
BUILTINS_X86_FP80_SRCS_PATTERNS
|
|
)
|
|
|
|
# Source files for the 128-bit floating-point and complex number builtins.
|
|
filegroup(
|
|
name = "builtins_tf_srcs",
|
|
srcs = glob(
|
|
BUILTINS_TF_SRCS_PATTERNS,
|
|
exclude = BUILTINS_TF_EXCLUDES,
|
|
),
|
|
)
|
|
|
|
BUILTNS_ATOMICS_SRCS = ["lib/builtins/atomic.c"]
|
|
|
|
filegroup(
|
|
name = "builtins_atomics_srcs",
|
|
srcs = BUILTNS_ATOMICS_SRCS + ["lib/builtins/assembly.h"],
|
|
)
|
|
|
|
BUILTINS_MACOS_ATOMIC_SRCS_PATTERNS = [
|
|
"lib/builtins/atomic_*.c",
|
|
]
|
|
|
|
# Source files for macOS atomic builtins.
|
|
filegroup(
|
|
name = "builtins_macos_atomic_srcs",
|
|
srcs = glob(BUILTINS_MACOS_ATOMIC_SRCS_PATTERNS),
|
|
)
|
|
|
|
# Apple-platform specific SME source file.
|
|
filegroup(
|
|
name = "builtins_aarch64_apple_sme_srcs",
|
|
srcs = ["lib/builtins/aarch64/arm_apple_sme_abi.s"],
|
|
)
|
|
|
|
# Non-Apple platform SME sources. These sources assume function
|
|
# multi-versioning, `-fno-builtin`, `__ARM_UNALIGNED` feature support, and FP
|
|
# availability. Other configurations will need to add a new filegroup if
|
|
# desired.
|
|
filegroup(
|
|
name = "builtins_aarch64_sme_srcs",
|
|
srcs = [
|
|
"lib/builtins/aarch64/sme-abi.S",
|
|
"lib/builtins/aarch64/sme-abi-assert.c",
|
|
] + glob(["lib/builtins/aarch64/sme-libc-opt-*.S"]),
|
|
)
|
|
|
|
# A list of (pat, size, model) tuples for AArch64's outline atomics.
|
|
AARCH64_OUTLINE_ATOMICS = [
|
|
(pat, size, model)
|
|
for pat in [
|
|
"cas",
|
|
"swp",
|
|
"ldadd",
|
|
"ldclr",
|
|
"ldeor",
|
|
"ldset",
|
|
]
|
|
for size in [
|
|
"1",
|
|
"2",
|
|
"4",
|
|
"8",
|
|
"16",
|
|
]
|
|
for model in [
|
|
"1",
|
|
"2",
|
|
"3",
|
|
"4",
|
|
"5",
|
|
]
|
|
if pat == "cas" or size != "16"
|
|
]
|
|
|
|
AARCH64_OUTLINE_ATOMICS_FMT = "lib/builtins/aarch64/outline_atomic_{0}{1}_{2}.S"
|
|
|
|
# lse.S is compiled multiple times with different macros as the input. Model
|
|
# this as a genrule producing individual files with the macros at the start.
|
|
[[genrule(
|
|
name = "builtins_aarch64_outline_atomic_" + pat + size + "_" + model,
|
|
srcs = ["lib/builtins/aarch64/lse.S"],
|
|
outs = [AARCH64_OUTLINE_ATOMICS_FMT.format(pat, size, model)],
|
|
cmd = (
|
|
"echo '#define L_" + pat + "' >> $(OUTS) && " +
|
|
"echo '#define SIZE " + size + "' >> $(OUTS) && " +
|
|
"echo '#define MODEL " + model + "' >> $(OUTS) && " +
|
|
"cat $(SRCS) >> $(OUTS)"
|
|
),
|
|
)] for (pat, size, model) in AARCH64_OUTLINE_ATOMICS]
|
|
|
|
# Source files for the AArch64 architecture-specific builtins.
|
|
filegroup(
|
|
name = "builtins_aarch64_srcs",
|
|
srcs = [
|
|
"lib/builtins/cpu_model/aarch64.c",
|
|
"lib/builtins/cpu_model/aarch64.h",
|
|
] + [
|
|
AARCH64_OUTLINE_ATOMICS_FMT.format(pat, size, model)
|
|
for (pat, size, model) in AARCH64_OUTLINE_ATOMICS
|
|
] + glob(
|
|
[
|
|
"lib/builtins/cpu_model/AArch64*.inc",
|
|
"lib/builtins/cpu_model/aarch64/**/*.inc",
|
|
"lib/builtins/aarch64/*.S",
|
|
"lib/builtins/aarch64/*.c",
|
|
"lib/builtins/aarch64/*.cpp",
|
|
"lib/builtins/aarch64/*.h",
|
|
],
|
|
allow_empty = True,
|
|
exclude = [
|
|
# This file isn't intended to directly compile, and instead is used
|
|
# above to generate a collection of outline atomic helpers.
|
|
"lib/builtins/aarch64/lse.S",
|
|
# These files are provided by SME-specific file groups above.
|
|
"lib/builtins/aarch64/*sme*",
|
|
],
|
|
),
|
|
)
|
|
|
|
BUILTINS_ARM_VFP_SRCS_PATTERNS = [
|
|
"lib/builtins/arm/*vfp*.S",
|
|
"lib/builtins/arm/*vfp*.c",
|
|
"lib/builtins/arm/*vfp*.cpp",
|
|
"lib/builtins/arm/*vfp*.h",
|
|
]
|
|
|
|
# Source files for the ARM VFP-specific builtins.
|
|
filegroup(
|
|
name = "builtins_arm_vfp_srcs",
|
|
srcs = glob(
|
|
BUILTINS_ARM_VFP_SRCS_PATTERNS,
|
|
allow_empty = True,
|
|
),
|
|
)
|
|
|
|
# Source files for the ARM architecture-specific builtins.
|
|
filegroup(
|
|
name = "builtins_arm_srcs",
|
|
srcs = glob(
|
|
[
|
|
"lib/builtins/arm/*.S",
|
|
"lib/builtins/arm/*.c",
|
|
"lib/builtins/arm/*.cpp",
|
|
"lib/builtins/arm/*.h",
|
|
],
|
|
allow_empty = True,
|
|
exclude = BUILTINS_ARM_VFP_SRCS_PATTERNS,
|
|
),
|
|
)
|
|
|
|
# Source files for the PPC architecture-specific builtins.
|
|
filegroup(
|
|
name = "builtins_ppc_srcs",
|
|
srcs = glob(
|
|
[
|
|
"lib/builtins/ppc/*.S",
|
|
"lib/builtins/ppc/*.c",
|
|
"lib/builtins/ppc/*.cpp",
|
|
"lib/builtins/ppc/*.h",
|
|
],
|
|
allow_empty = True,
|
|
),
|
|
)
|
|
|
|
# Source files for the RISC-V architecture-specific builtins.
|
|
filegroup(
|
|
name = "builtins_riscv_srcs",
|
|
srcs = glob(
|
|
[
|
|
"lib/builtins/riscv/*.S",
|
|
"lib/builtins/riscv/*.c",
|
|
"lib/builtins/riscv/*.cpp",
|
|
],
|
|
allow_empty = True,
|
|
),
|
|
)
|
|
|
|
# Source files for the x86 architecture specific builtins (both 32-bit and
|
|
# 64-bit).
|
|
filegroup(
|
|
name = "builtins_x86_arch_srcs",
|
|
srcs = [
|
|
"lib/builtins/cpu_model/x86.c",
|
|
"lib/builtins/i386/fp_mode.c",
|
|
],
|
|
)
|
|
|
|
# Source files for the x86-64 architecture specific builtins.
|
|
filegroup(
|
|
name = "builtins_x86_64_srcs",
|
|
srcs = glob(
|
|
[
|
|
"lib/builtins/x86_64/*.S",
|
|
"lib/builtins/x86_64/*.c",
|
|
"lib/builtins/x86_64/*.cpp",
|
|
"lib/builtins/x86_64/*.h",
|
|
],
|
|
allow_empty = True,
|
|
),
|
|
)
|
|
|
|
# Source files for the 32-bit-specific x86 architecture specific builtins.
|
|
filegroup(
|
|
name = "builtins_i386_srcs",
|
|
srcs = glob(
|
|
[
|
|
"lib/builtins/i386/*.S",
|
|
"lib/builtins/i386/*.c",
|
|
"lib/builtins/i386/*.cpp",
|
|
"lib/builtins/i386/*.h",
|
|
],
|
|
allow_empty = True,
|
|
exclude = [
|
|
# This file is used for both i386 and x86_64 and so included in the
|
|
# broader x86 sources.
|
|
"lib/builtins/i386/fp_mode.c",
|
|
],
|
|
),
|
|
)
|
|
|
|
# Source files for portable components of the compiler builtins library.
|
|
filegroup(
|
|
name = "builtins_generic_srcs",
|
|
srcs = ["lib/builtins/cpu_model/cpu_model.h"] + glob(
|
|
[
|
|
"lib/builtins/*.c",
|
|
"lib/builtins/*.cpp",
|
|
"lib/builtins/*.h",
|
|
"lib/builtins/*.inc",
|
|
],
|
|
allow_empty = True,
|
|
exclude = (
|
|
BUILTINS_CRTBEGIN_SRCS +
|
|
BUILTINS_CRTEND_SRCS +
|
|
BUILTINS_TF_EXCLUDES +
|
|
BUILTINS_TF_SRCS_PATTERNS +
|
|
BUILTNS_ATOMICS_SRCS +
|
|
BUILTINS_MACOS_ATOMIC_SRCS_PATTERNS
|
|
),
|
|
),
|
|
)
|