├── kernel ├── BUILD.bazel └── extension │ ├── BUILD.bazel │ ├── kernel_helpers.bzl │ ├── BUILD.trampoline.tpl │ ├── BUILD.kernel-headers.tpl │ ├── make_select_kernel_headers_repository_target.bzl │ └── libc_kernel_versions.bzl ├── runtimes ├── empty.c ├── glibc │ ├── extension │ │ ├── BUILD.bazel │ │ ├── make_select_glibc_repository_target.bzl │ │ ├── BUILD.trampoline.tpl │ │ └── BUILD.glibc-headers.tpl │ ├── abilists │ ├── glibc_linker_script.bzl │ ├── libc_aware_target_triple.bzl │ ├── README.md │ ├── glibc_shared_library.bzl │ └── glibc_stubs_assembly_files.bzl ├── mingw │ ├── extension │ │ ├── BUILD.bazel │ │ └── mingw.bzl │ └── crt_object.bzl ├── musl │ └── extension │ │ ├── BUILD.bazel │ │ └── musl.bzl ├── defs.bzl ├── compiler-rt │ └── BUILD.bazel ├── libunwind │ └── BUILD.bazel ├── libcxx │ └── BUILD.bazel └── README.md ├── third_party ├── BUILD ├── libc │ ├── BUILD.bazel │ ├── musl │ │ ├── BUILD.bazel │ │ ├── 1.2.5-CVE-2025-26519-2.patch │ │ └── 1.2.5-CVE-2025-26519-1.patch │ └── glibc │ │ ├── BUILD.bazel │ │ ├── nptl │ │ └── BUILD.bazel │ │ ├── stdlib │ │ ├── BUILD.bazel │ │ ├── at_quick_exit.c │ │ └── atexit.c │ │ ├── csu │ │ └── BUILD.bazel │ │ ├── NOTICE │ │ ├── 0001-Add-empty-config.h.patch │ │ ├── 0002-Add-abi-tag.h.patch │ │ ├── LICENSE │ │ ├── README.md │ │ └── helpers.bzl ├── macosx.sdk │ └── BUILD.bazel └── llvm-project │ ├── 20.x │ ├── BUILD.bazel │ ├── libcxx │ │ ├── BUILD.bazel │ │ └── lgamma_r.patch │ ├── compiler-rt │ │ ├── BUILD.bazel │ │ ├── targets.bzl │ │ ├── README.md │ │ └── filter_builtin_sources.bzl │ ├── libcxxabi │ │ └── BUILD.bazel │ ├── libunwind │ │ └── BUILD.bazel │ └── libc │ │ ├── BUILD.bazel │ │ ├── README.md │ │ ├── hdr │ │ ├── float_macros.h │ │ ├── limits_macros.h │ │ ├── errno_macros.h │ │ └── fenv_macros.h │ │ ├── shared │ │ ├── fp_bits.h │ │ ├── str_to_integer.h │ │ ├── str_to_float.h │ │ └── libc_common.h │ │ ├── src │ │ └── __support │ │ │ ├── CPP │ │ │ ├── utility.h │ │ │ ├── type_traits │ │ │ │ ├── type_identity.h │ │ │ │ ├── true_type.h │ │ │ │ ├── false_type.h │ │ │ │ ├── bool_constant.h │ │ │ │ ├── is_constant_evaluated.h │ │ │ │ ├── integral_constant.h │ │ │ │ ├── is_enum.h │ │ │ │ ├── is_union.h │ │ │ │ ├── void_t.h │ │ │ │ ├── enable_if.h │ │ │ │ ├── is_trivially_constructible.h │ │ │ │ ├── aligned_storage.h │ │ │ │ ├── is_void.h │ │ │ │ ├── remove_cvref.h │ │ │ │ ├── conditional.h │ │ │ │ ├── is_const.h │ │ │ │ ├── is_trivially_copyable.h │ │ │ │ ├── is_same.h │ │ │ │ ├── remove_reference.h │ │ │ │ ├── remove_extent.h │ │ │ │ ├── is_null_pointer.h │ │ │ │ ├── remove_cv.h │ │ │ │ ├── invoke_result.h │ │ │ │ ├── is_array.h │ │ │ │ ├── is_copy_constructible.h │ │ │ │ ├── add_pointer.h │ │ │ │ ├── is_move_constructible.h │ │ │ │ ├── is_arithmetic.h │ │ │ │ ├── is_copy_assignable.h │ │ │ │ ├── add_rvalue_reference.h │ │ │ │ ├── always_false.h │ │ │ │ ├── is_class.h │ │ │ │ ├── has_unique_object_representations.h │ │ │ │ ├── is_function.h │ │ │ │ ├── is_object.h │ │ │ │ ├── add_lvalue_reference.h │ │ │ │ ├── is_move_assignable.h │ │ │ │ ├── is_pointer.h │ │ │ │ ├── is_member_pointer.h │ │ │ │ ├── is_reference.h │ │ │ │ ├── is_lvalue_reference.h │ │ │ │ ├── is_rvalue_reference.h │ │ │ │ ├── is_scalar.h │ │ │ │ ├── is_trivially_destructible.h │ │ │ │ ├── remove_all_extents.h │ │ │ │ ├── decay.h │ │ │ │ ├── is_integral.h │ │ │ │ ├── is_floating_point.h │ │ │ │ ├── is_convertible.h │ │ │ │ ├── is_base_of.h │ │ │ │ ├── is_complex.h │ │ │ │ ├── make_signed.h │ │ │ │ └── is_fixed_point.h │ │ │ └── utility │ │ │ │ ├── move.h │ │ │ │ ├── declval.h │ │ │ │ ├── forward.h │ │ │ │ ├── in_place.h │ │ │ │ └── integer_sequence.h │ │ │ ├── number_pair.h │ │ │ ├── uint128.h │ │ │ ├── macros │ │ │ ├── properties │ │ │ │ ├── os.h │ │ │ │ ├── complex_types.h │ │ │ │ └── compiler.h │ │ │ ├── attributes.h │ │ │ ├── null_check.h │ │ │ └── config.h │ │ │ ├── sign.h │ │ │ └── str_to_num_result.h │ │ └── include │ │ ├── llvm-libc-types │ │ ├── cfloat16.h │ │ ├── float128.h │ │ └── cfloat128.h │ │ └── llvm-libc-macros │ │ └── float16-macros.h │ ├── BUILD.bazel │ ├── llvm-sanitizers-ignorelists.patch │ ├── no_frontend_builtin_headers.patch │ ├── no_zlib_genrule.patch │ └── llvm-extra.patch ├── .bazelignore ├── constraints ├── BUILD.bazel └── libc │ ├── declare_libcs_constraints.bzl │ ├── libc_versions.bzl │ └── BUILD.bazel ├── prebuilt ├── BUILD.bazel ├── extras │ ├── BUILD.extras.tpl │ ├── extra_bins_release.bzl │ └── BUILD.bazel ├── platforms.bzl ├── llvm │ └── BUILD.bazel └── mtree.bzl ├── .bazelversion ├── toolchain ├── llvm │ ├── BUILD.bazel │ ├── BUILD.llvm_release.tpl │ └── BUILD.llvm_release_windows.tpl ├── stage1 │ ├── BUILD.bazel │ └── README.md ├── stage2 │ ├── README.md │ ├── cc_stage2_library.bzl │ ├── cc_stage2_static_library.bzl │ ├── cc_stage2_shared_library.bzl │ ├── cc_stage2_common.bzl │ ├── BUILD.bazel │ ├── args │ │ ├── linux │ │ │ └── BUILD.bazel │ │ └── BUILD.bazel │ └── cc_unsanitized_library.bzl ├── args │ ├── llvm_target_triple.bzl │ ├── macos │ │ └── BUILD.bazel │ └── windows │ │ └── BUILD.bazel ├── README ├── declare_toolchains.bzl ├── cc_toolchain.bzl └── features │ └── legacy │ └── BUILD.bazel ├── config ├── BUILD.bazel └── stage1 │ └── BUILD.bazel ├── .gitignore ├── platforms ├── BUILD.bazel ├── config │ └── BUILD.bazel └── common.bzl ├── .vscode └── settings.json ├── .gitattributes ├── .bcr ├── source.template.json ├── presubmit.yml └── metadata.template.json ├── sanitizers ├── BUILD.bazel └── ubsan_ignore.txt ├── tools ├── BUILD.bazel └── defs.bzl ├── BUILD.bazel ├── sh_script.bzl ├── llvm.bzl ├── .github └── workflows │ ├── ci.bazelrc │ ├── publish.yml │ ├── release.yml │ └── release_prep.sh ├── LICENSE ├── http_pkg_archive.bzl └── defs.bzl /kernel/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /runtimes/empty.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.bazelignore: -------------------------------------------------------------------------------- 1 | e2e 2 | -------------------------------------------------------------------------------- /constraints/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /prebuilt/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 9.0.0rc2 2 | -------------------------------------------------------------------------------- /kernel/extension/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/libc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /toolchain/llvm/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/libc/musl/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /runtimes/glibc/extension/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /runtimes/mingw/extension/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /runtimes/musl/extension/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/libc/glibc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/macosx.sdk/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libcxx/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/compiler-rt/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libcxxabi/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libunwind/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load(":defs.bzl", "config_settings") 2 | 3 | config_settings() 4 | -------------------------------------------------------------------------------- /prebuilt/extras/BUILD.extras.tpl: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "bin/glibc-stubs-generator", 3 | ]) 4 | -------------------------------------------------------------------------------- /third_party/libc/glibc/nptl/BUILD.bazel: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "pthread_atfork.c", 3 | ]) 4 | -------------------------------------------------------------------------------- /config/stage1/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//config:defs.bzl", "config_settings") 2 | 3 | config_settings() 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | .bazelrc.user 3 | .idea/ 4 | .ijwb/ 5 | examples/*/MODULE.bazel.lock 6 | *.swp 7 | -------------------------------------------------------------------------------- /platforms/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load(":declare_platforms.bzl", "declare_platforms") 2 | 3 | declare_platforms() 4 | -------------------------------------------------------------------------------- /third_party/libc/glibc/stdlib/BUILD.bazel: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "atexit.c", 3 | "at_quick_exit.c", 4 | ]) 5 | -------------------------------------------------------------------------------- /runtimes/glibc/abilists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cerisier/toolchains_llvm_bootstrapped/HEAD/runtimes/glibc/abilists -------------------------------------------------------------------------------- /third_party/libc/glibc/csu/BUILD.bazel: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "abi-note-2.31.S", 3 | "elf-init-2.31.c", 4 | ]) 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.tpl": "starlark", 4 | "stdexcept": "cpp" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /platforms/config/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load(":declare_config_settings.bzl", "declare_config_settings") 2 | 3 | declare_config_settings() 4 | -------------------------------------------------------------------------------- /toolchain/stage1/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//toolchain/stage1:declare_toolchains.bzl", "declare_toolchains") 2 | 3 | declare_toolchains() 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # In code review, collapse generated files 2 | docs/*.md linguist-generated=true 3 | 4 | internal_tools export-ignore 5 | e2e export-ignore 6 | 7 | -------------------------------------------------------------------------------- /toolchain/stage1/README.md: -------------------------------------------------------------------------------- 1 | # Stage 1 Toolchain 2 | 3 | Stage 1 = The toolchain to compile the compiler 4 | Stage 2 [THIS ONE] = The toolchain to compile the dependencies to the final toolchain 5 | -------------------------------------------------------------------------------- /toolchain/stage2/README.md: -------------------------------------------------------------------------------- 1 | # Stage 2 Toolchain 2 | 3 | Stage 1 = The toolchain to compile the compiler 4 | Stage 2 [THIS ONE] = The toolchain to compile the dependencies to the final toolchain 5 | -------------------------------------------------------------------------------- /third_party/llvm-project/BUILD.bazel: -------------------------------------------------------------------------------- 1 | alias( 2 | name = "libc_headers", 3 | actual = "//third_party/llvm-project/20.x/libc:libc_headers", 4 | visibility = ["//visibility:public"], 5 | ) 6 | -------------------------------------------------------------------------------- /.bcr/source.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "**leave this alone**", 3 | "strip_prefix": "{REPO}-{VERSION}", 4 | "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/toolchains_llvm_bootstrapped-{TAG}.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /sanitizers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # TODO(zbarsky): This can't be a `exports_files` because rules_cc only accepts labels 2 | filegroup( 3 | name = "ubsan_ignore", 4 | srcs = ["ubsan_ignore.txt"], 5 | visibility = ["//visibility:public"], 6 | ) 7 | -------------------------------------------------------------------------------- /sanitizers/ubsan_ignore.txt: -------------------------------------------------------------------------------- 1 | # Ignore all sanitizer instrumentation for libc startup files. 2 | src:external/toolchains_llvm_bootstrapped+/third_party/libc/glibc/csu/elf-init-2.31.c 3 | src:external/toolchains_llvm_bootstrapped++musl+musl_libc/src/env/__libc_start_main.c -------------------------------------------------------------------------------- /constraints/libc/declare_libcs_constraints.bzl: -------------------------------------------------------------------------------- 1 | load(":libc_versions.bzl", "LIBCS") 2 | 3 | def declare_libcs_constraints(): 4 | for libc in LIBCS: 5 | native.constraint_value( 6 | name = libc, 7 | constraint_setting = "variant", 8 | ) 9 | -------------------------------------------------------------------------------- /toolchain/llvm/BUILD.llvm_release.tpl: -------------------------------------------------------------------------------- 1 | load("@toolchains_llvm_bootstrapped//toolchain/llvm:llvm.bzl", "declare_llvm_targets") 2 | 3 | # selects won't work here to choose between .exe and no suffix, so we have a separate BUILD file for Windows and non-Windows 4 | declare_llvm_targets() 5 | -------------------------------------------------------------------------------- /toolchain/llvm/BUILD.llvm_release_windows.tpl: -------------------------------------------------------------------------------- 1 | 2 | load("@toolchains_llvm_bootstrapped//toolchain/llvm:llvm.bzl", "declare_llvm_targets") 3 | 4 | # selects won't work here to choose between .exe and no suffix, so we have a separate BUILD file for Windows and non-Windows 5 | declare_llvm_targets(suffix = ".exe") 6 | 7 | -------------------------------------------------------------------------------- /prebuilt/platforms.bzl: -------------------------------------------------------------------------------- 1 | PLATFORMS = [ 2 | # "//platforms:linux_amd64_gnu.2.28", 3 | "//platforms:linux_amd64_musl", 4 | # "//platforms:linux_arm64_gnu.2.28", 5 | "//platforms:linux_arm64_musl", 6 | "//platforms:macos_arm64", 7 | "//platforms:windows_amd64", 8 | "//platforms:windows_arm64", 9 | ] 10 | -------------------------------------------------------------------------------- /third_party/libc/glibc/NOTICE: -------------------------------------------------------------------------------- 1 | Files under `nptl` and `stlibd` packages were copied from the `ziglang/zig` 2 | project which is under the MIT License, which themselves were edited from the 3 | `glibc` project were they fall under the `LGPL` License. 4 | 5 | Files under `csu` are copied from the `glibc` project were they fall under the 6 | the `LGPL` License. 7 | -------------------------------------------------------------------------------- /runtimes/defs.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_lib//lib:run_binary.bzl", "run_binary") 2 | 3 | def stub_library(name, out = None, visibility = None): 4 | out = out or "lib%s.a" % name 5 | run_binary( 6 | name = name, 7 | outs = [out], 8 | tool = "//tools:llvm-ar", 9 | args = ["rc", "$@"], 10 | visibility = visibility, 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /kernel/extension/kernel_helpers.bzl: -------------------------------------------------------------------------------- 1 | 2 | def arch_to_kernel_arch(arch): 3 | """Convert the architecture name used in the glibc to the one used in the kernel.""" 4 | if arch == "x86_64": 5 | return "x86" 6 | elif arch == "aarch64": 7 | return "arm64" 8 | elif arch == "armv7": 9 | return "arm" 10 | else: 11 | return arch 12 | -------------------------------------------------------------------------------- /.bcr/presubmit.yml: -------------------------------------------------------------------------------- 1 | bcr_test_module: 2 | module_path: . 3 | matrix: 4 | bazel: [7.x, 8.x] 5 | # Add macos_arm64 back when we support sdk discovery 6 | platform: [debian11, ubuntu2004] 7 | tasks: 8 | run_test_module: 9 | name: Run test module 10 | bazel: ${{ bazel }} 11 | platform: ${{ platform }} 12 | build_targets: 13 | - //:all 14 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:cc_library.bzl", "cc_library") 2 | 3 | cc_library( 4 | name = "libc_headers", 5 | includes = [ 6 | ".", 7 | ], 8 | hdrs = glob([ 9 | "hdr/*.h", 10 | "include/**/*.h", 11 | "shared/*.h", 12 | "src/**/*.h", 13 | ]), 14 | visibility = ["//visibility:public"], 15 | ) 16 | -------------------------------------------------------------------------------- /tools/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@toolchains_llvm_bootstrapped//toolchain:selects.bzl", "platform_llvm_binary") 2 | load("@toolchains_llvm_bootstrapped//tools:defs.bzl", "TOOLCHAIN_BINARIES") 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | [ 7 | alias( 8 | name = tool, 9 | actual = platform_llvm_binary("bin/" + tool), 10 | ) 11 | for tool in TOOLCHAIN_BINARIES 12 | ] 13 | -------------------------------------------------------------------------------- /toolchain/stage2/cc_stage2_library.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:cc_library.bzl", "cc_library") 2 | load("@toolchains_llvm_bootstrapped//toolchain/stage2:cc_stage2_common.bzl", "configure_builder_for_stage2") 3 | load("@with_cfg.bzl", "with_cfg") 4 | 5 | _builder = with_cfg( 6 | cc_library, 7 | ) 8 | 9 | configure_builder_for_stage2(_builder) 10 | 11 | cc_stage2_library, _cc_stage2_library_internal = _builder.build() 12 | -------------------------------------------------------------------------------- /.bcr/metadata.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "https://github.com/cerisier/toolchains_llvm_bootstrapped", 3 | "maintainers": [ 4 | { 5 | "name": "Corentin Kerisit", 6 | "email": "corentin.kerisit@gmail.com", 7 | "github": "cerisier" 8 | } 9 | ], 10 | "repository": [ 11 | "github:cerisier/toolchains_llvm_bootstrapped" 12 | ], 13 | "versions": [], 14 | "yanked_versions": {} 15 | } 16 | -------------------------------------------------------------------------------- /constraints/libc/libc_versions.bzl: -------------------------------------------------------------------------------- 1 | GLIBC_VERSIONS = [ 2 | "2.28", 3 | "2.29", 4 | "2.30", 5 | "2.31", 6 | "2.32", 7 | "2.33", 8 | "2.34", 9 | "2.35", 10 | "2.36", 11 | "2.37", 12 | "2.38", 13 | "2.39", 14 | "2.40", 15 | "2.41", 16 | "2.42", 17 | ] 18 | 19 | GLIBCS = ["gnu.{}".format(glibc) for glibc in GLIBC_VERSIONS] 20 | 21 | LIBCS = ["musl"] + GLIBCS 22 | 23 | DEFAULT_LIBC = "gnu.2.28" 24 | -------------------------------------------------------------------------------- /toolchain/stage2/cc_stage2_static_library.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:cc_static_library.bzl", "cc_static_library") 2 | load("@toolchains_llvm_bootstrapped//toolchain/stage2:cc_stage2_common.bzl", "configure_builder_for_stage2") 3 | load("@with_cfg.bzl", "with_cfg") 4 | 5 | _builder = with_cfg( 6 | cc_static_library, 7 | ) 8 | 9 | configure_builder_for_stage2(_builder) 10 | 11 | cc_stage2_static_library, _cc_stage2_static_library_internal = _builder.build() 12 | -------------------------------------------------------------------------------- /constraints/libc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load(":declare_libcs_constraints.bzl", "declare_libcs_constraints") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | constraint_setting( 6 | name = "variant", 7 | # For linux, this maps to a default gnu.2.28 8 | default_constraint_value = "unconstrained", 9 | ) 10 | 11 | constraint_value( 12 | name = "unconstrained", 13 | constraint_setting = "variant", 14 | ) 15 | 16 | declare_libcs_constraints() 17 | -------------------------------------------------------------------------------- /tools/defs.bzl: -------------------------------------------------------------------------------- 1 | TOOLCHAIN_BINARIES = [ 2 | "clang", 3 | "clang++", 4 | "clang-cpp", 5 | "lld", 6 | "ld.lld", 7 | "ld64.lld", 8 | "wasm-ld", 9 | "llvm-ar", 10 | "llvm-as", 11 | "llvm-dlltool", 12 | "llvm-libtool-darwin", 13 | "llvm-nm", 14 | "llvm-objcopy", 15 | "llvm-strip", 16 | # "clang-tidy", 17 | # "clang-format", 18 | "clangd", 19 | # "llvm-symbolizer", 20 | # "llvm-profdata", 21 | # "llvm-cov", 22 | # "llvm-dwp", 23 | # "llvm-objdump", 24 | ] 25 | -------------------------------------------------------------------------------- /kernel/extension/BUILD.trampoline.tpl: -------------------------------------------------------------------------------- 1 | load("@toolchains_llvm_bootstrapped//kernel/extension:make_select_kernel_headers_repository_target.bzl", "make_select_kernel_headers_repository_target") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | alias( 6 | name = "kernel_headers", 7 | actual = make_select_kernel_headers_repository_target("kernel_headers"), 8 | ) 9 | 10 | alias( 11 | name = "kernel_headers_directory", 12 | actual = make_select_kernel_headers_repository_target("kernel_headers_directory"), 13 | ) 14 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- 1 | platform( 2 | name = "rbe_platform", 3 | constraint_values = [ 4 | "@platforms//cpu:x86_64", 5 | "@platforms//os:linux", 6 | # ubuntu:22.04 has GNU C Library (Ubuntu GLIBC 2.35-0ubuntu3.10) 7 | # But apparently not in this docker://ubuntu:22.04 image? 8 | "@toolchains_llvm_bootstrapped//constraints/libc:gnu.2.28", 9 | "@bazel_tools//tools/cpp:clang", 10 | ], 11 | exec_properties = { 12 | "container-image": "docker://ubuntu:22.04", 13 | "OSFamily": "Linux", 14 | }, 15 | ) 16 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/README.md: -------------------------------------------------------------------------------- 1 | # LLVM libc 2 | 3 | This contains a subset of internal headers from the LLVM libc which fall under 4 | the Apache License 2.0 with LLVM Exceptions. 5 | 6 | Sadly, starting LLVM 20.1.0, libcxx started depending on internal headers of the 7 | LLVM libc implementation. 8 | 9 | For now, I've resorted to not depend on llvm-project source tarball because it is 10 | 140MB and decided to go the same way ziglang does: include the subset of headers 11 | required by libcxx. 12 | 13 | These will have to be monitored when updating LLVM. 14 | -------------------------------------------------------------------------------- /toolchain/stage2/cc_stage2_shared_library.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:cc_shared_library.bzl", "cc_shared_library") 2 | load("@rules_cc//cc/common:cc_shared_library_info.bzl", "CcSharedLibraryInfo") 3 | load("@toolchains_llvm_bootstrapped//toolchain/stage2:cc_stage2_common.bzl", "configure_builder_for_stage2") 4 | load("@with_cfg.bzl", "with_cfg") 5 | 6 | _builder = with_cfg( 7 | cc_shared_library, 8 | extra_providers = [CcSharedLibraryInfo], 9 | ) 10 | 11 | configure_builder_for_stage2(_builder) 12 | 13 | cc_stage2_shared_library, _cc_stage2_shared_library_internal = _builder.build() 14 | -------------------------------------------------------------------------------- /prebuilt/llvm/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") 2 | load("//prebuilt:platforms.bzl", "PLATFORMS") 3 | load("//prebuilt/llvm:llvm_release.bzl", "llvm_release") 4 | 5 | llvm_release(name = "llvm_release") 6 | 7 | llvm_release(name = "windows_llvm_release", bin_suffix = ".exe") 8 | 9 | [ 10 | platform_transition_filegroup( 11 | name = "for_" + platform.split(":")[1], 12 | srcs = [ 13 | ":windows_llvm_release" if "windows" in platform else ":llvm_release", 14 | ], 15 | target_platform = platform, 16 | ) 17 | for platform in PLATFORMS 18 | ] 19 | -------------------------------------------------------------------------------- /runtimes/mingw/crt_object.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_lib//lib:copy_file.bzl", "copy_file") 2 | load("@toolchains_llvm_bootstrapped//toolchain/stage2:cc_stage2_library.bzl", "cc_stage2_library") 3 | 4 | def crt_object(name, out, visibility, **kwargs): 5 | cc_stage2_library( 6 | name = name + "_lib", 7 | **kwargs 8 | ) 9 | 10 | native.filegroup( 11 | name = name + "_file", 12 | srcs = [name + "_lib"], 13 | output_group = "compilation_outputs", 14 | ) 15 | 16 | copy_file( 17 | name = name, 18 | src = name + "_file", 19 | out = out, 20 | visibility = visibility, 21 | ) 22 | 23 | -------------------------------------------------------------------------------- /third_party/libc/glibc/0001-Add-empty-config.h.patch: -------------------------------------------------------------------------------- 1 | From 0ab79f2150500b31d847f3a047d2b945a0302265 Mon Sep 17 00:00:00 2001 2 | From: Corentin Kerisit 3 | Date: Tue, 13 May 2025 17:00:48 +0200 4 | Subject: [PATCH 1/3] Add empty config.h 5 | 6 | All values are passed using defines. 7 | --- 8 | include/config.h | 1 + 9 | 1 file changed, 1 insertion(+) 10 | create mode 100644 include/config.h 11 | 12 | diff --git a/include/config.h b/include/config.h 13 | new file mode 100644 14 | index 0000000000..b7db25411d 15 | --- /dev/null 16 | +++ b/include/config.h 17 | @@ -0,0 +1 @@ 18 | +// Empty 19 | -- 20 | 2.39.3 (Apple Git-146) 21 | 22 | -------------------------------------------------------------------------------- /platforms/common.bzl: -------------------------------------------------------------------------------- 1 | ARCH_ALIASES = { 2 | "x86_64": ["amd64"], 3 | "aarch64": ["arm64"], 4 | } 5 | 6 | SUPPORTED_TARGETS = [ 7 | ("macos", "x86_64"), 8 | ("macos", "aarch64"), 9 | ("linux", "x86_64"), 10 | ("linux", "aarch64"), 11 | ("windows", "x86_64"), 12 | ("windows", "aarch64"), 13 | ("none", "wasm32"), 14 | ("none", "wasm64"), 15 | ] 16 | 17 | SUPPORTED_EXECS = [ 18 | ("macos", "aarch64"), 19 | ("linux", "x86_64"), 20 | ("linux", "aarch64"), 21 | ("windows", "x86_64"), 22 | ("windows", "aarch64"), 23 | ] 24 | 25 | LIBC_SUPPORTED_TARGETS = [ 26 | ("linux", "x86_64"), 27 | ("linux", "aarch64"), 28 | ] 29 | -------------------------------------------------------------------------------- /runtimes/compiler-rt/BUILD.bazel: -------------------------------------------------------------------------------- 1 | alias( 2 | name = "clang_rt.builtins.static", 3 | actual = "@compiler-rt//:clang_rt.builtins.static", 4 | visibility = ["//visibility:public"], 5 | ) 6 | 7 | alias( 8 | name = "clang_rt.ubsan.static", 9 | actual = "@compiler-rt//:ubsan.static", 10 | visibility = ["//visibility:public"], 11 | ) 12 | 13 | alias( 14 | name = "clang_rt.crtbegin", 15 | actual = "@compiler-rt//:clang_rt.crtbegin.static", 16 | visibility = ["//visibility:public"], 17 | ) 18 | 19 | alias( 20 | name = "clang_rt.crtend", 21 | actual = "@compiler-rt//:clang_rt.crtend.static", 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /runtimes/glibc/glibc_linker_script.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_skylib//rules:write_file.bzl", "write_file") 2 | 3 | def make_glibc_linker_script(name, lib_name, lib_version, additional_linker_inputs = []): 4 | write_file( 5 | name = name, 6 | out = "lib{lib}.so".format(lib = lib_name), 7 | content = [ 8 | # GROUP(file) is the same as INPUT(file) when there is just one file 9 | "GROUP(lib{lib}.so.{version} {extra_inputs})".format( 10 | lib = lib_name, 11 | version = lib_version, 12 | extra_inputs = " ".join(additional_linker_inputs), 13 | ), 14 | ], 15 | ) 16 | return name 17 | -------------------------------------------------------------------------------- /sh_script.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_lib//lib:run_binary.bzl", "run_binary") 2 | load("@bazel_skylib//rules:write_file.bzl", "write_file") 3 | load("@rules_shell//shell:sh_binary.bzl", "sh_binary") 4 | 5 | def sh_script(name, cmd, **kwargs): 6 | write_file( 7 | name = name + "_sh", 8 | out = name + ".sh", 9 | content = [ 10 | "#!/usr/bin/env bash", 11 | "set -euo pipefail", 12 | cmd, 13 | ], 14 | ) 15 | 16 | sh_binary( 17 | name = name + "_bin", 18 | srcs = [name + ".sh"], 19 | ) 20 | 21 | run_binary( 22 | name = name, 23 | tool = name + "_bin", 24 | **kwargs 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /prebuilt/extras/extra_bins_release.bzl: -------------------------------------------------------------------------------- 1 | load("@tar.bzl", "tar") 2 | load("//prebuilt:mtree.bzl", "mtree") 3 | 4 | def extra_bins_release(name): 5 | files = { 6 | "@glibc-stubs-generator//:glibc-stubs-generator": "bin/glibc-stubs-generator", 7 | "@libstdcxx-stubs-generator//:libstdc++-stubs-generator": "bin/libstdcxx-stubs-generator", 8 | } 9 | 10 | mtree( 11 | name = name + "_mtree", 12 | files = files, 13 | ) 14 | 15 | tar( 16 | name = name, 17 | srcs = files.keys(), 18 | args = [ 19 | "--options", 20 | "zstd:compression-level=22", 21 | ], 22 | compress = "zstd", 23 | mtree = name + "_mtree", 24 | ) 25 | -------------------------------------------------------------------------------- /prebuilt/extras/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") 2 | load("//prebuilt:platforms.bzl", "PLATFORMS") 3 | load("//prebuilt/extras:extra_bins_release.bzl", "extra_bins_release") 4 | 5 | [ 6 | extra_bins_release(name = platform.split(":")[1]) 7 | for platform in PLATFORMS 8 | ] 9 | 10 | [ 11 | platform_transition_filegroup( 12 | name = "for_" + platform.split(":")[1], 13 | srcs = [ 14 | ":{}".format(platform.split(":")[1]), 15 | ], 16 | target_platform = platform, 17 | ) 18 | for platform in PLATFORMS 19 | ] 20 | 21 | filegroup( 22 | name = "for_all_platforms", 23 | srcs = ["for_" + platform.split(":")[1] for platform in PLATFORMS], 24 | ) 25 | -------------------------------------------------------------------------------- /runtimes/glibc/libc_aware_target_triple.bzl: -------------------------------------------------------------------------------- 1 | load("//constraints/libc:libc_versions.bzl", "LIBCS", "DEFAULT_LIBC") 2 | load("//platforms:common.bzl", "LIBC_SUPPORTED_TARGETS") 3 | 4 | # For use with zig tools that consume parse zig targets triples 5 | # Zig target triples only, not LLVM 6 | def libc_aware_target_triple(): 7 | target = {} 8 | for (target_os, target_cpu) in LIBC_SUPPORTED_TARGETS: 9 | for libc_version in LIBCS + ["unconstrained"]: 10 | target_libc_suffix = libc_version if libc_version != "unconstrained" else DEFAULT_LIBC 11 | target["//platforms/config:{}_{}_{}".format(target_os, target_cpu, libc_version)] = "{}-{}-{}".format(target_cpu, target_os, target_libc_suffix) 12 | 13 | return select(target) 14 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/hdr/float_macros.h: -------------------------------------------------------------------------------- 1 | //===-- Definition of macros from math.h ----------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_HDR_FLOAT_MACROS_H 10 | #define LLVM_LIBC_HDR_FLOAT_MACROS_H 11 | 12 | #ifdef LIBC_FULL_BUILD 13 | 14 | #include "include/llvm-libc-macros/float-macros.h" 15 | 16 | #else // Overlay mode 17 | 18 | #include 19 | 20 | #endif // LLVM_LIBC_FULL_BUILD 21 | 22 | #endif // LLVM_LIBC_HDR_FLOAT_MACROS_H 23 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/hdr/limits_macros.h: -------------------------------------------------------------------------------- 1 | //===-- Definition of macros from limits.h --------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_HDR_LIMITS_MACROS_H 10 | #define LLVM_LIBC_HDR_LIMITS_MACROS_H 11 | 12 | #ifdef LIBC_FULL_BUILD 13 | 14 | #include "include/llvm-libc-macros/limits-macros.h" 15 | 16 | #else // Overlay mode 17 | 18 | #include 19 | 20 | #endif // LLVM_LIBC_FULL_BUILD 21 | 22 | #endif // LLVM_LIBC_HDR_LIMITS_MACROS_H 23 | -------------------------------------------------------------------------------- /third_party/llvm-project/llvm-sanitizers-ignorelists.patch: -------------------------------------------------------------------------------- 1 | diff --git a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel b/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel 2 | index bcf947a23014..7e9bfb8a19ca 100644 3 | --- a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel 4 | +++ b/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel 5 | @@ -111,3 +111,15 @@ cc_library( 6 | ":orc_rt_common_headers", 7 | ], 8 | ) 9 | + 10 | +filegroup( 11 | + name = "msan_ignorelist", 12 | + srcs = ["lib/msan/msan_ignorelist.txt"], 13 | + visibility = ["//visibility:public"], 14 | +) 15 | + 16 | +filegroup( 17 | + name = "asan_ignorelist", 18 | + srcs = ["lib/asan/asan_ignorelist.txt"], 19 | + visibility = ["//visibility:public"], 20 | +) 21 | -------------------------------------------------------------------------------- /third_party/libc/glibc/0002-Add-abi-tag.h.patch: -------------------------------------------------------------------------------- 1 | From b88b5deeb665d8371fd023cc8636ba540f15f780 Mon Sep 17 00:00:00 2001 2 | From: Corentin Kerisit 3 | Date: Tue, 13 May 2025 17:08:16 +0200 4 | Subject: [PATCH 2/3] Add abi-tag.h 5 | 6 | This is generated normally as part of the glibc build but is 7 | stable for all libc 2.x 8 | --- 9 | csu/abi-tag.h | 5 +++++ 10 | 1 file changed, 5 insertions(+) 11 | create mode 100644 csu/abi-tag.h 12 | 13 | diff --git a/csu/abi-tag.h b/csu/abi-tag.h 14 | new file mode 100644 15 | index 0000000000..2ee19e3f75 16 | --- /dev/null 17 | +++ b/csu/abi-tag.h 18 | @@ -0,0 +1,5 @@ 19 | +#define __ABI_TAG_OS 0 20 | +#ifndef __ABI_TAG_VERSION 21 | +# define __ABI_TAG_VERSION 2,0,0 22 | +#endif 23 | + 24 | -- 25 | 2.39.3 (Apple Git-146) 26 | 27 | -------------------------------------------------------------------------------- /runtimes/libunwind/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") 2 | load("//runtimes:defs.bzl", "stub_library") 3 | 4 | stub_library( 5 | name = "unwind", 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | stub_library( 10 | name = "gcc_s", 11 | visibility = ["//visibility:public"], 12 | ) 13 | 14 | config_setting( 15 | name = "stub_libgcc_s", 16 | flag_values = { 17 | "//config:experimental_stub_libgcc_s": "True", 18 | }, 19 | ) 20 | 21 | copy_to_directory( 22 | name = "libunwind_library_search_directory", 23 | srcs = [ 24 | ":unwind", 25 | ] + select({ 26 | ":stub_libgcc_s": [":gcc_s"], 27 | "//conditions:default": [], 28 | }), 29 | visibility = ["//visibility:public"], 30 | ) 31 | -------------------------------------------------------------------------------- /toolchain/stage2/cc_stage2_common.bzl: -------------------------------------------------------------------------------- 1 | def configure_builder_for_stage2(builder): 2 | # The problem is that compiler-rt and start libs can only be compiled with 3 | # a specific set of flags and compilation mode. It is not safe to let the user 4 | # interfere with them using default command line flags. 5 | # TODO: Expose a build setting to extend stage1 flags. 6 | builder.set("copt", []) 7 | builder.set("cxxopt", []) 8 | builder.set("linkopt", []) 9 | builder.set("host_copt", []) 10 | builder.set("host_cxxopt", []) 11 | builder.set("host_linkopt", []) 12 | 13 | builder.set( 14 | Label("//toolchain:bootstrap_setting"), 15 | True, 16 | ) 17 | 18 | builder.set( 19 | Label("//toolchain:stage1_bootstrap_setting"), 20 | True, 21 | ) 22 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/shared/fp_bits.h: -------------------------------------------------------------------------------- 1 | //===-- Floating point number utils -----------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SHARED_FP_BITS_H 10 | #define LLVM_LIBC_SHARED_FP_BITS_H 11 | 12 | #include "libc_common.h" 13 | #include "src/__support/FPUtil/FPBits.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace shared { 17 | 18 | using fputil::FPBits; 19 | 20 | } // namespace shared 21 | } // namespace LIBC_NAMESPACE_DECL 22 | 23 | #endif // LLVM_LIBC_SHARED_FP_BITS_H 24 | -------------------------------------------------------------------------------- /third_party/llvm-project/no_frontend_builtin_headers.patch: -------------------------------------------------------------------------------- 1 | commit e63c26093fddb963a94b6207beaaf576c2c54115 2 | Author: David Zbarsky 3 | Date: Sat Dec 13 17:05:57 2025 -0500 4 | 5 | Remove builtin headers from frontend target 6 | 7 | diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 8 | index 5ceb2e42c23d..c7ba4fed1760 100644 9 | --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 10 | +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 11 | @@ -1744,7 +1744,7 @@ cc_library( 12 | "include/clang/Frontend/*.h", 13 | ]), 14 | copts = ["$(STACK_FRAME_UNLIMITED)"], 15 | - data = [":builtin_headers_gen"], 16 | + #data = [":builtin_headers_gen"], 17 | includes = ["include"], 18 | deps = [ 19 | ":apinotes", 20 | -------------------------------------------------------------------------------- /runtimes/glibc/extension/make_select_glibc_repository_target.bzl: -------------------------------------------------------------------------------- 1 | load("//constraints/libc:libc_versions.bzl", "GLIBCS", "DEFAULT_LIBC") 2 | load("//platforms:common.bzl", "LIBC_SUPPORTED_TARGETS") 3 | 4 | def make_select_glibc_repository_target(bazel_repository, bazel_target): 5 | selection = {} 6 | for (target_os, target_arch) in LIBC_SUPPORTED_TARGETS: 7 | for libc_version in GLIBCS + ["unconstrained"]: 8 | apparent_libc_version_suffix = libc_version if libc_version != "unconstrained" else DEFAULT_LIBC 9 | apparent_target = "{}_{}-{}-{}//:{}".format(bazel_repository, target_arch, target_os, apparent_libc_version_suffix, bazel_target) 10 | selection["@toolchains_llvm_bootstrapped//platforms/config:{}_{}_{}".format(target_os, target_arch, libc_version)] = apparent_target 11 | 12 | return select(selection) 13 | -------------------------------------------------------------------------------- /llvm.bzl: -------------------------------------------------------------------------------- 1 | load("@llvm-raw//utils/bazel:configure.bzl", _llvm_configure = "llvm_configure") 2 | 3 | def _llvm_impl(mctx): 4 | _targets = {} 5 | for mod in mctx.modules: 6 | for conf in mod.tags.configure: 7 | for target in conf.targets: 8 | _targets[target] = True 9 | _llvm_configure( 10 | name = "llvm-project", 11 | targets = _targets.keys(), 12 | ) 13 | return mctx.extension_metadata( 14 | reproducible = True, 15 | root_module_direct_deps = "all", 16 | root_module_direct_dev_deps = [], 17 | ) 18 | 19 | llvm = module_extension( 20 | implementation = _llvm_impl, 21 | tag_classes = { 22 | "configure": tag_class( 23 | attrs = { 24 | "targets": attr.string_list(mandatory = True), 25 | }, 26 | ), 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/utility.h: -------------------------------------------------------------------------------- 1 | //===-- Analogous to ----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H 11 | 12 | #include "src/__support/CPP/utility/declval.h" 13 | #include "src/__support/CPP/utility/forward.h" 14 | #include "src/__support/CPP/utility/in_place.h" 15 | #include "src/__support/CPP/utility/integer_sequence.h" 16 | #include "src/__support/CPP/utility/move.h" 17 | 18 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H 19 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/shared/str_to_integer.h: -------------------------------------------------------------------------------- 1 | //===-- String to int conversion utils --------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SHARED_STR_TO_INTEGER_H 10 | #define LLVM_LIBC_SHARED_STR_TO_INTEGER_H 11 | 12 | #include "libc_common.h" 13 | #include "src/__support/str_to_integer.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace shared { 17 | 18 | using LIBC_NAMESPACE::StrToNumResult; 19 | 20 | using internal::strtointeger; 21 | 22 | } // namespace shared 23 | } // namespace LIBC_NAMESPACE_DECL 24 | 25 | #endif // LLVM_LIBC_SHARED_STR_TO_INTEGER_H 26 | -------------------------------------------------------------------------------- /runtimes/libcxx/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@bazel_lib//lib:copy_file.bzl", "copy_file") 2 | load("@bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") 3 | load("//runtimes:defs.bzl", "stub_library") 4 | 5 | stub_library( 6 | name = "c++", 7 | ) 8 | 9 | stub_library( 10 | name = "c++abi", 11 | ) 12 | 13 | copy_to_directory( 14 | name = "libcxx_library_search_directory", 15 | srcs = [ 16 | ":c++", 17 | ":c++abi", 18 | ], 19 | visibility = ["//visibility:public"], 20 | ) 21 | 22 | alias( 23 | name = "libcxx_headers_include_search_directory", 24 | actual = "@libcxx//:libcxx_headers_include_search_directory", 25 | visibility = ["//visibility:public"], 26 | ) 27 | 28 | alias( 29 | name = "libcxxabi_headers_include_search_directory", 30 | actual = "@libcxxabi//:libcxxabi_headers_include_search_directory", 31 | visibility = ["//visibility:public"], 32 | ) 33 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/number_pair.h: -------------------------------------------------------------------------------- 1 | //===-- Utilities for pairs of numbers. -------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H 10 | #define LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H 11 | 12 | #include "CPP/type_traits.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | #include 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | 19 | template struct NumberPair { 20 | T lo = T(0); 21 | T hi = T(0); 22 | }; 23 | 24 | } // namespace LIBC_NAMESPACE_DECL 25 | 26 | #endif // LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H 27 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/hdr/errno_macros.h: -------------------------------------------------------------------------------- 1 | //===-- Definition of macros from errno.h ---------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_HDR_ERRNO_MACROS_H 10 | #define LLVM_LIBC_HDR_ERRNO_MACROS_H 11 | 12 | #ifdef LIBC_FULL_BUILD 13 | 14 | #ifdef __linux__ 15 | #include 16 | 17 | #include "include/llvm-libc-macros/error-number-macros.h" 18 | #else // __linux__ 19 | #include "include/llvm-libc-macros/generic-error-number-macros.h" 20 | #endif 21 | 22 | #else // Overlay mode 23 | 24 | #include 25 | 26 | #endif // LLVM_LIBC_FULL_BUILD 27 | 28 | #endif // LLVM_LIBC_HDR_ERRNO_MACROS_H 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/uint128.h: -------------------------------------------------------------------------------- 1 | //===-- 128-bit signed and unsigned int types -------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_UINT128_H 10 | #define LLVM_LIBC_SRC___SUPPORT_UINT128_H 11 | 12 | #include "big_int.h" 13 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 14 | 15 | #ifdef LIBC_TYPES_HAS_INT128 16 | using UInt128 = __uint128_t; 17 | using Int128 = __int128_t; 18 | #else 19 | using UInt128 = LIBC_NAMESPACE::UInt<128>; 20 | using Int128 = LIBC_NAMESPACE::Int<128>; 21 | #endif // LIBC_TYPES_HAS_INT128 22 | 23 | #endif // LLVM_LIBC_SRC___SUPPORT_UINT128_H 24 | -------------------------------------------------------------------------------- /kernel/extension/BUILD.kernel-headers.tpl: -------------------------------------------------------------------------------- 1 | load("@bazel_skylib//rules/directory:directory.bzl", "directory") 2 | load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory") 3 | load("@rules_cc//cc:cc_library.bzl", "cc_library") 4 | 5 | cc_library( 6 | name = "kernel_headers", 7 | hdrs = glob([ 8 | "include/**", 9 | ]), 10 | includes = [ 11 | "include", 12 | ], 13 | # Any code should always get passed linux UAPI headers as -isystem 14 | features = ["system_include_paths"], 15 | visibility = ["//visibility:public"], 16 | ) 17 | 18 | directory( 19 | name = "kernel_headers_top_directory", 20 | srcs = glob([ 21 | "include/**", 22 | ]), 23 | visibility = ["//visibility:public"], 24 | ) 25 | 26 | subdirectory( 27 | name = "kernel_headers_directory", 28 | path = "include", 29 | parent = ":kernel_headers_top_directory", 30 | visibility = ["//visibility:public"], 31 | ) 32 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/type_identity.h: -------------------------------------------------------------------------------- 1 | //===-- type_identity type_traits -------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H 10 | 11 | #include "src/__support/macros/config.h" 12 | 13 | namespace LIBC_NAMESPACE_DECL { 14 | namespace cpp { 15 | 16 | // type_identity 17 | template struct type_identity { 18 | using type = T; 19 | }; 20 | 21 | } // namespace cpp 22 | } // namespace LIBC_NAMESPACE_DECL 23 | 24 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H 25 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/true_type.h: -------------------------------------------------------------------------------- 1 | //===-- true_type type_traits -----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // true_type 18 | using true_type = cpp::bool_constant; 19 | 20 | } // namespace cpp 21 | } // namespace LIBC_NAMESPACE_DECL 22 | 23 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H 24 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/false_type.h: -------------------------------------------------------------------------------- 1 | //===-- false_type type_traits ----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // false_type 18 | using false_type = cpp::bool_constant; 19 | 20 | } // namespace cpp 21 | } // namespace LIBC_NAMESPACE_DECL 22 | 23 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H 24 | -------------------------------------------------------------------------------- /runtimes/glibc/extension/BUILD.trampoline.tpl: -------------------------------------------------------------------------------- 1 | load("@toolchains_llvm_bootstrapped//runtimes/glibc/extension:make_select_glibc_repository_target.bzl", "make_select_glibc_repository_target") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | alias( 6 | name = "gnu_libc_headers", 7 | actual = make_select_glibc_repository_target("@glibc_headers", "gnu_libc_headers"), 8 | ) 9 | 10 | alias( 11 | name = "glibc_headers_directory", 12 | actual = make_select_glibc_repository_target("@glibc_headers", "glibc_headers_directory"), 13 | ) 14 | 15 | alias( 16 | name = "glibc_c_nonshared.static", 17 | actual = make_select_glibc_repository_target("@glibc", "c_nonshared"), 18 | ) 19 | 20 | alias( 21 | name = "glibc_Scrt1.object", 22 | actual = make_select_glibc_repository_target("@glibc", "glibc_Scrt1.object"), 23 | ) 24 | 25 | alias( 26 | name = "glibc_crt1.object", 27 | actual = make_select_glibc_repository_target("@glibc", "glibc_crt1.object"), 28 | ) 29 | -------------------------------------------------------------------------------- /runtimes/glibc/extension/BUILD.glibc-headers.tpl: -------------------------------------------------------------------------------- 1 | load("@bazel_skylib//rules/directory:directory.bzl", "directory") 2 | load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory") 3 | load("@rules_cc//cc:cc_library.bzl", "cc_library") 4 | 5 | cc_library( 6 | name = "gnu_libc_headers", 7 | hdrs = glob([ 8 | "include/**", 9 | ]), 10 | includes = [ 11 | "include", 12 | ], 13 | # user code should always get glibc headers as -isystem 14 | # but it seems glibc itself includes as <...> 15 | features = ["system_include_paths"], 16 | visibility = ["//visibility:public"], 17 | ) 18 | 19 | directory( 20 | name = "glibc_headers_top_directory", 21 | srcs = glob([ 22 | "include/**", 23 | ]), 24 | visibility = ["//visibility:public"], 25 | ) 26 | 27 | subdirectory( 28 | name = "glibc_headers_directory", 29 | path = "include", 30 | parent = ":glibc_headers_top_directory", 31 | visibility = ["//visibility:public"], 32 | ) 33 | -------------------------------------------------------------------------------- /kernel/extension/make_select_kernel_headers_repository_target.bzl: -------------------------------------------------------------------------------- 1 | load("//constraints/libc:libc_versions.bzl", "LIBCS") 2 | load("//platforms:common.bzl", "LIBC_SUPPORTED_TARGETS") 3 | load(":libc_kernel_versions.bzl", "LIBC_KERNEL_VERSIONS") 4 | load(":kernel_helpers.bzl", "arch_to_kernel_arch") 5 | 6 | def make_select_kernel_headers_repository_target(bazel_target): 7 | """Select the right kernel headers repository based on the target architecture and the libc version.""" 8 | selection = {} 9 | for (target_os, target_arch) in LIBC_SUPPORTED_TARGETS: 10 | for libc_version in LIBCS + ["unconstrained"]: 11 | kernel_version = LIBC_KERNEL_VERSIONS[libc_version] 12 | apparent_target = "@linux_kernel_headers_{}.{}//:{}".format(arch_to_kernel_arch(target_arch), kernel_version, bazel_target) 13 | selection["@toolchains_llvm_bootstrapped//platforms/config:{}_{}_{}".format(target_os, target_arch, libc_version)] = apparent_target 14 | 15 | return select(selection) 16 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/shared/str_to_float.h: -------------------------------------------------------------------------------- 1 | //===-- String to float conversion utils ------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SHARED_STR_TO_FLOAT_H 10 | #define LLVM_LIBC_SHARED_STR_TO_FLOAT_H 11 | 12 | #include "libc_common.h" 13 | #include "src/__support/str_to_float.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace shared { 17 | 18 | using internal::ExpandedFloat; 19 | using internal::FloatConvertReturn; 20 | using internal::RoundDirection; 21 | 22 | using internal::binary_exp_to_float; 23 | using internal::decimal_exp_to_float; 24 | 25 | } // namespace shared 26 | } // namespace LIBC_NAMESPACE_DECL 27 | 28 | #endif // LLVM_LIBC_SHARED_STR_TO_FLOAT_H 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/bool_constant.h: -------------------------------------------------------------------------------- 1 | //===-- bool_constant type_traits -------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H 10 | 11 | #include "src/__support/CPP/type_traits/integral_constant.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // bool_constant 18 | template using bool_constant = cpp::integral_constant; 19 | 20 | } // namespace cpp 21 | } // namespace LIBC_NAMESPACE_DECL 22 | 23 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H 24 | -------------------------------------------------------------------------------- /.github/workflows/ci.bazelrc: -------------------------------------------------------------------------------- 1 | # This file contains Bazel settings to apply on CI only. 2 | # It is referenced with a --bazelrc option in the call to bazel in ci.yaml 3 | common --config=ci 4 | 5 | # Enable remote caching and execution on CI by default. 6 | common --config remote 7 | 8 | # This directory is configured in GitHub actions to be persisted between runs. 9 | # docs: https://bazel.build/reference/command-line-reference#flag--disk_cache 10 | # build --disk_cache=~/.cache/bazel 11 | # docs: https://bazel.build/reference/command-line-reference#flag--repository_cache 12 | common --repository_cache=~/.cache/bazel-repo 13 | common --repo_contents_cache=~/.cache/bazel-repo/contents 14 | 15 | # docs: https://bazel.build/reference/command-line-reference#flag--remote_download_outputs 16 | common --remote_download_outputs=minimal 17 | 18 | # Allows tests to run bazelisk-in-bazel, since this is the cache folder used 19 | # docs: https://bazel.build/reference/command-line-reference#flag--test_env 20 | test --test_env=XDG_CACHE_HOME 21 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/include/llvm-libc-types/cfloat16.h: -------------------------------------------------------------------------------- 1 | //===-- Definition of cfloat16 type ---------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_TYPES_CFLOAT16_H 10 | #define LLVM_LIBC_TYPES_CFLOAT16_H 11 | 12 | #if defined(__FLT16_MANT_DIG__) && \ 13 | (!defined(__GNUC__) || __GNUC__ >= 13 || \ 14 | (defined(__clang__) && __clang_major__ >= 14)) && \ 15 | !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \ 16 | !defined(_WIN32) 17 | #define LIBC_TYPES_HAS_CFLOAT16 18 | typedef _Complex _Float16 cfloat16; 19 | #endif 20 | 21 | #endif // LLVM_LIBC_TYPES_CFLOAT16_H 22 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_constant_evaluated.h: -------------------------------------------------------------------------------- 1 | //===-- is_constant_evaluated type_traits -----------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H 10 | 11 | #include "src/__support/macros/attributes.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | LIBC_INLINE constexpr bool is_constant_evaluated() { 18 | return __builtin_is_constant_evaluated(); 19 | } 20 | 21 | } // namespace cpp 22 | } // namespace LIBC_NAMESPACE_DECL 23 | 24 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H 25 | -------------------------------------------------------------------------------- /kernel/extension/libc_kernel_versions.bzl: -------------------------------------------------------------------------------- 1 | # Partly from https://github.com/cerisier/glibc-headers/blob/main/glibc_kernel_versions.txt 2 | 3 | LIBC_KERNEL_VERSIONS = { 4 | "gnu.2.17": "3.9.11", 5 | "gnu.2.18": "3.12.74", 6 | "gnu.2.19": "3.15.10", 7 | "gnu.2.20": "3.17.8", 8 | "gnu.2.21": "4.0.9", 9 | "gnu.2.22": "4.3.6", 10 | "gnu.2.23": "4.6.7", 11 | "gnu.2.24": "4.8.17", 12 | "gnu.2.25": "4.11.12", 13 | "gnu.2.26": "4.14.336", 14 | "gnu.2.27": "4.16.18", 15 | "gnu.2.28": "4.19.325", 16 | "gnu.2.29": "5.1.21", 17 | "gnu.2.30": "5.4.293", 18 | "gnu.2.31": "5.7.19", 19 | "gnu.2.32": "5.9.16", 20 | "gnu.2.33": "5.12.19", 21 | "gnu.2.34": "5.15.182", 22 | "gnu.2.35": "5.17.15", 23 | "gnu.2.36": "6.0.19", 24 | "gnu.2.37": "6.3.13", 25 | "gnu.2.38": "6.6.90", 26 | "gnu.2.39": "6.9.12", 27 | "gnu.2.40": "6.12.28", 28 | "gnu.2.41": "6.14.6", 29 | "gnu.2.42": "6.16.12", 30 | "musl" : "6.16.12", # Latest for musl always 31 | } 32 | 33 | LIBC_KERNEL_VERSIONS["unconstrained"] = LIBC_KERNEL_VERSIONS["gnu.2.28"] 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/integral_constant.h: -------------------------------------------------------------------------------- 1 | //===-- integral_constant type_traits ---------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H 10 | 11 | #include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // integral_constant 18 | template struct integral_constant { 19 | using value_type = T; 20 | LIBC_INLINE_VAR static constexpr T value = v; 21 | }; 22 | 23 | } // namespace cpp 24 | } // namespace LIBC_NAMESPACE_DECL 25 | 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H 27 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/utility/move.h: -------------------------------------------------------------------------------- 1 | //===-- move utility --------------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H 10 | 11 | #include "src/__support/CPP/type_traits/remove_reference.h" 12 | #include "src/__support/macros/attributes.h" // LIBC_INLINE 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // move 19 | template 20 | LIBC_INLINE constexpr cpp::remove_reference_t &&move(T &&t) { 21 | return static_cast &&>(t); 22 | } 23 | 24 | } // namespace cpp 25 | } // namespace LIBC_NAMESPACE_DECL 26 | 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H 28 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_enum.h: -------------------------------------------------------------------------------- 1 | //===-- is_enum type_traits -------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/macros/attributes.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // is_enum 19 | template struct is_enum : bool_constant<__is_enum(T)> {}; 20 | template 21 | LIBC_INLINE_VAR constexpr bool is_enum_v = is_enum::value; 22 | 23 | } // namespace cpp 24 | } // namespace LIBC_NAMESPACE_DECL 25 | 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H 27 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/shared/libc_common.h: -------------------------------------------------------------------------------- 1 | //===-- Common defines for sharing LLVM libc with LLVM projects -*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SHARED_LIBC_COMMON_H 10 | #define LLVM_LIBC_SHARED_LIBC_COMMON_H 11 | 12 | // Use system errno. 13 | #ifdef LIBC_ERRNO_MODE 14 | #if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM_INLINE 15 | #error \ 16 | "LIBC_ERRNO_MODE was set to something different from LIBC_ERRNO_MODE_SYSTEM_INLINE." 17 | #endif // LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM_INLINE 18 | #else 19 | #define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM_INLINE 20 | #endif // LIBC_ERRNO_MODE 21 | 22 | #ifndef LIBC_NAMESPACE 23 | #define LIBC_NAMESPACE __llvm_libc 24 | #endif // LIBC_NAMESPACE 25 | 26 | #endif // LLVM_LIBC_SHARED_LIBC_COMMON_H 27 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_union.h: -------------------------------------------------------------------------------- 1 | //===-- is_union type_traits ------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/macros/attributes.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // is_union 19 | template struct is_union : bool_constant<__is_union(T)> {}; 20 | template 21 | LIBC_INLINE_VAR constexpr bool is_union_v = is_union::value; 22 | 23 | } // namespace cpp 24 | } // namespace LIBC_NAMESPACE_DECL 25 | 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H 27 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/void_t.h: -------------------------------------------------------------------------------- 1 | //===-- void_t type_traits --------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // void_t 18 | 19 | namespace detail { 20 | template struct make_void : cpp::type_identity {}; 21 | } // namespace detail 22 | 23 | template 24 | using void_t = typename detail::make_void::type; 25 | 26 | } // namespace cpp 27 | } // namespace LIBC_NAMESPACE_DECL 28 | 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H 30 | -------------------------------------------------------------------------------- /toolchain/args/llvm_target_triple.bzl: -------------------------------------------------------------------------------- 1 | LLVM_TARGET_TRIPLE = select({ 2 | #TODO: Generate this automatically 3 | "@toolchains_llvm_bootstrapped//platforms/config:linux_x86_64_gnu": ["x86_64-linux-gnu"], 4 | "@toolchains_llvm_bootstrapped//platforms/config:linux_aarch64_gnu": ["aarch64-linux-gnu"], 5 | "@toolchains_llvm_bootstrapped//platforms/config:linux_x86_64_musl": ["x86_64-linux-musl"], 6 | "@toolchains_llvm_bootstrapped//platforms/config:linux_aarch64_musl": ["aarch64-linux-musl"], 7 | "@toolchains_llvm_bootstrapped//platforms/config:macos_x86_64": ["x86_64-apple-darwin"], 8 | "@toolchains_llvm_bootstrapped//platforms/config:macos_aarch64": ["aarch64-apple-darwin"], 9 | "@toolchains_llvm_bootstrapped//platforms/config:windows_x86_64": ["x86_64-w64-windows-gnu"], 10 | "@toolchains_llvm_bootstrapped//platforms/config:windows_aarch64": ["aarch64-w64-windows-gnu"], 11 | "@toolchains_llvm_bootstrapped//platforms/config:none_wasm32": ["wasm32-unknown-unknown"], 12 | "@toolchains_llvm_bootstrapped//platforms/config:none_wasm64": ["wasm64-unknown-unknown"], 13 | }, no_match_error = "Unsupported platform") 14 | -------------------------------------------------------------------------------- /runtimes/mingw/extension/mingw.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | load("@bazel_features//:features.bzl", "bazel_features") 3 | 4 | def _mingw_extension_impl(module_ctx): 5 | """Implementation of the mingw module extension.""" 6 | 7 | http_archive( 8 | name = "mingw", 9 | urls = ["https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v13.0.0.tar.bz2"], 10 | integrity = "sha256-Wv6CKvXE7b9n2q9F7sYdU49J7vaxlSTeZIl8a5WCjK8=", 11 | strip_prefix = "mingw-w64-v13.0.0", 12 | build_file = "//runtimes/mingw:BUILD.tpl", 13 | ) 14 | 15 | metadata_kwargs = {} 16 | if bazel_features.external_deps.extension_metadata_has_reproducible: 17 | metadata_kwargs["reproducible"] = True 18 | 19 | return module_ctx.extension_metadata( 20 | root_module_direct_deps = ["mingw"], 21 | root_module_direct_dev_deps = [], 22 | **metadata_kwargs 23 | ) 24 | 25 | mingw = module_extension( 26 | implementation = _mingw_extension_impl, 27 | doc = "Extension for downloading and configuring mingw", 28 | ) 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/utility/declval.h: -------------------------------------------------------------------------------- 1 | //===-- declval utility -----------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H 10 | 11 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" 12 | #include "src/__support/CPP/type_traits/always_false.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // declval 19 | template cpp::add_rvalue_reference_t declval() { 20 | static_assert(cpp::always_false, 21 | "declval not allowed in an evaluated context"); 22 | } 23 | 24 | } // namespace cpp 25 | } // namespace LIBC_NAMESPACE_DECL 26 | 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H 28 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/enable_if.h: -------------------------------------------------------------------------------- 1 | //===-- enable_if type_traits -----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // enable_if 18 | template struct enable_if; 19 | template struct enable_if : type_identity {}; 20 | template 21 | using enable_if_t = typename enable_if::type; 22 | 23 | } // namespace cpp 24 | } // namespace LIBC_NAMESPACE_DECL 25 | 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H 27 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_trivially_constructible.h: -------------------------------------------------------------------------------- 1 | //===-- is_trivially_constructible type_traits ------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H 10 | 11 | #include "src/__support/CPP/type_traits/integral_constant.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // is_trivially_constructible 18 | template 19 | struct is_trivially_constructible 20 | : integral_constant {}; 21 | 22 | } // namespace cpp 23 | } // namespace LIBC_NAMESPACE_DECL 24 | 25 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H 26 | -------------------------------------------------------------------------------- /third_party/libc/glibc/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (Expat) 2 | 3 | Copyright (c) Zig contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/aligned_storage.h: -------------------------------------------------------------------------------- 1 | //===-- aligned_storage type_traits --------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H 11 | 12 | #include "src/__support/macros/config.h" 13 | #include // size_t 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | template struct aligned_storage { 19 | struct type { 20 | alignas(Align) unsigned char data[Len]; 21 | }; 22 | }; 23 | 24 | template 25 | using aligned_storage_t = typename aligned_storage::type; 26 | 27 | } // namespace cpp 28 | } // namespace LIBC_NAMESPACE_DECL 29 | 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H 31 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_void.h: -------------------------------------------------------------------------------- 1 | //===-- is_void type_traits -------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H 10 | 11 | #include "src/__support/CPP/type_traits/is_same.h" 12 | #include "src/__support/CPP/type_traits/remove_cv.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is_void 20 | template struct is_void : is_same> {}; 21 | template 22 | LIBC_INLINE_VAR constexpr bool is_void_v = is_void::value; 23 | 24 | } // namespace cpp 25 | } // namespace LIBC_NAMESPACE_DECL 26 | 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H 28 | -------------------------------------------------------------------------------- /toolchain/stage2/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc/toolchains/impl:documented_api.bzl", "cc_args_list") 2 | load("//toolchain/stage2:declare_toolchains.bzl", "declare_toolchains") 3 | 4 | cc_args_list( 5 | name = "platform_specific_args", 6 | args = select({ 7 | "@platforms//os:macos": [ 8 | "//toolchain/args/macos:macos_minimum_os_flags", 9 | "//toolchain/args/macos:macos_default_link_flags", 10 | "//toolchain/args/macos:macos_sdk_sysroot", 11 | ], 12 | "@platforms//os:linux": [ 13 | "//toolchain/stage2/args/linux:hermetic_linux_args", 14 | ], 15 | "@platforms//os:windows": [ 16 | "//toolchain/args:hermetic_compile_flags", 17 | ], 18 | "//conditions:default": [], 19 | }), 20 | ) 21 | 22 | cc_args_list( 23 | name = "optimization_flags", 24 | args = select({ 25 | "//config:stage2_optimization_mode_debug": [ 26 | "//toolchain/stage2/args:dbg_compile_flags", 27 | ], 28 | "//conditions:default": [ 29 | "//toolchain/stage2/args:opt_compile_flags", 30 | ], 31 | }), 32 | ) 33 | 34 | declare_toolchains() 35 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/remove_cvref.h: -------------------------------------------------------------------------------- 1 | //===-- remove_cvref type_traits --------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H 10 | 11 | #include "src/__support/CPP/type_traits/remove_cv.h" 12 | #include "src/__support/CPP/type_traits/remove_reference.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // remove_cvref 19 | template struct remove_cvref { 20 | using type = remove_cv_t>; 21 | }; 22 | template using remove_cvref_t = typename remove_cvref::type; 23 | 24 | } // namespace cpp 25 | } // namespace LIBC_NAMESPACE_DECL 26 | 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H 28 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/bazel-contrib/publish-to-bcr 2 | name: Publish to BCR 3 | 4 | on: 5 | # Run the publish workflow after a successful release 6 | # Can be triggered from the release.yaml workflow 7 | workflow_call: 8 | inputs: 9 | tag_name: 10 | required: true 11 | type: string 12 | secrets: 13 | publish_token: 14 | required: true 15 | # In case of problems, let release engineers retry by manually dispatching 16 | # the workflow from the GitHub UI 17 | workflow_dispatch: 18 | inputs: 19 | tag_name: 20 | required: true 21 | type: string 22 | 23 | jobs: 24 | publish: 25 | uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.1.0 26 | with: 27 | draft: false 28 | tag_name: ${{ inputs.tag_name }} 29 | # GitHub repository which is a fork of the upstream where the Pull Request will be opened. 30 | registry_fork: cerisier/bazel-central-registry 31 | permissions: 32 | attestations: write 33 | contents: write 34 | id-token: write 35 | secrets: 36 | publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }} 37 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/macros/properties/os.h: -------------------------------------------------------------------------------- 1 | //===-- Target OS detection -------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H 9 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H 10 | 11 | #if (defined(__freebsd__) || defined(__FreeBSD__)) 12 | #define LIBC_TARGET_OS_IS_FREEBSD 13 | #endif 14 | 15 | #if defined(__ANDROID__) 16 | #define LIBC_TARGET_OS_IS_ANDROID 17 | #endif 18 | 19 | #if defined(__linux__) && !defined(LIBC_TARGET_OS_IS_FREEBSD) && \ 20 | !defined(LIBC_TARGET_OS_IS_ANDROID) 21 | #define LIBC_TARGET_OS_IS_LINUX 22 | #endif 23 | 24 | #if (defined(_WIN64) || defined(_WIN32)) 25 | #define LIBC_TARGET_OS_IS_WINDOWS 26 | #endif 27 | 28 | #if defined(__Fuchsia__) 29 | #define LIBC_TARGET_OS_IS_FUCHSIA 30 | #endif 31 | 32 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H 33 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release 2 | 3 | on: 4 | # Can be triggered from the tag.yaml workflow 5 | workflow_call: 6 | inputs: 7 | tag_name: 8 | required: true 9 | type: string 10 | # In case of problems, let release engineers retry by manually dispatching 11 | # the workflow from the GitHub UI 12 | workflow_dispatch: 13 | inputs: 14 | tag_name: 15 | required: true 16 | type: string 17 | 18 | permissions: 19 | id-token: write # Needed to attest provenance 20 | attestations: write # Needed to attest provenance 21 | contents: write # Needed to create release 22 | 23 | jobs: 24 | release: 25 | uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.2.2 26 | with: 27 | bazel_test_command: bash tests/e2e.sh 28 | prerelease: false 29 | release_files: | 30 | toolchains_llvm_bootstrapped-*.tar.gz 31 | tag_name: ${{ inputs.tag_name || github.ref_name }} 32 | publish: 33 | needs: release 34 | uses: ./.github/workflows/publish.yml 35 | with: 36 | tag_name: ${{ inputs.tag_name || github.ref_name }} 37 | secrets: 38 | publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }} 39 | -------------------------------------------------------------------------------- /prebuilt/mtree.bzl: -------------------------------------------------------------------------------- 1 | def _mtree_impl(ctx): 2 | lines = [] 3 | 4 | for tgt, dst in ctx.attr.files.items(): 5 | lines.append( 6 | "%s uid=0 gid=0 time=1672560000 mode=0755 type=file content=$(location %s)" 7 | % (dst, str(tgt.label)) 8 | ) 9 | 10 | for link_path, target in ctx.attr.symlinks.items(): 11 | lines.append( 12 | "%s uid=0 gid=0 time=1672560000 mode=0755 type=link link=%s" 13 | % (link_path, target) 14 | ) 15 | 16 | content = "\n".join(lines) 17 | content = ctx.expand_location(content, targets = ctx.attr.files.keys()) 18 | 19 | if ctx.attr.format: 20 | content = content.format(**ctx.attr.format) 21 | 22 | out = ctx.actions.declare_file(ctx.attr.name) 23 | 24 | ctx.actions.write( 25 | output = out, 26 | content = content + "\n", 27 | ) 28 | 29 | return [ 30 | DefaultInfo(files = depset([out])) 31 | ] 32 | 33 | mtree = rule( 34 | implementation = _mtree_impl, 35 | attrs = { 36 | "files": attr.label_keyed_string_dict(allow_files = True), 37 | "format": attr.string_dict(), 38 | "symlinks": attr.string_dict(), 39 | }, 40 | ) 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Corentin Kerisit 4 | Copyright (c) 2024 David Zbarsky 5 | Copyright (c) Zig contributors 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/conditional.h: -------------------------------------------------------------------------------- 1 | //===-- conditional type_traits ---------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // conditional 18 | template 19 | struct conditional : type_identity {}; 20 | template 21 | struct conditional : type_identity {}; 22 | template 23 | using conditional_t = typename conditional::type; 24 | 25 | } // namespace cpp 26 | } // namespace LIBC_NAMESPACE_DECL 27 | 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/include/llvm-libc-macros/float16-macros.h: -------------------------------------------------------------------------------- 1 | //===-- Detection of _Float16 compiler builtin type -----------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_MACROS_FLOAT16_MACROS_H 10 | #define LLVM_LIBC_MACROS_FLOAT16_MACROS_H 11 | 12 | #include "../llvm-libc-types/float128.h" 13 | 14 | #if defined(__FLT16_MANT_DIG__) && \ 15 | (!defined(__GNUC__) || __GNUC__ >= 13 || defined(__clang__)) && \ 16 | !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \ 17 | !defined(_WIN32) 18 | #define LIBC_TYPES_HAS_FLOAT16 19 | 20 | // TODO: This would no longer be required if HdrGen let us guard function 21 | // declarations with multiple macros. 22 | #ifdef LIBC_TYPES_HAS_FLOAT128 23 | #define LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128 24 | #endif // LIBC_TYPES_HAS_FLOAT128 25 | #endif 26 | 27 | #endif // LLVM_LIBC_MACROS_FLOAT16_MACROS_H 28 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_const.h: -------------------------------------------------------------------------------- 1 | //===-- is_const type_traits ------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H 10 | 11 | #include "src/__support/CPP/type_traits/false_type.h" 12 | #include "src/__support/CPP/type_traits/true_type.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is_const 20 | template struct is_const : cpp::false_type {}; 21 | template struct is_const : cpp::true_type {}; 22 | template 23 | LIBC_INLINE_VAR constexpr bool is_const_v = is_const::value; 24 | 25 | } // namespace cpp 26 | } // namespace LIBC_NAMESPACE_DECL 27 | 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_trivially_copyable.h: -------------------------------------------------------------------------------- 1 | //===-- is_trivially_copyable type_traits -----------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H 10 | 11 | #include "src/__support/CPP/type_traits/integral_constant.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // is_trivially_copyable 18 | template 19 | struct is_trivially_copyable 20 | : public integral_constant {}; 21 | 22 | template 23 | LIBC_INLINE_VAR constexpr bool is_trivially_copyable_v = 24 | is_trivially_copyable::value; 25 | 26 | } // namespace cpp 27 | } // namespace LIBC_NAMESPACE_DECL 28 | 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H 30 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_same.h: -------------------------------------------------------------------------------- 1 | //===-- is_same type_traits -------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H 10 | 11 | #include "src/__support/CPP/type_traits/false_type.h" 12 | #include "src/__support/CPP/type_traits/true_type.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is_same 20 | template struct is_same : cpp::false_type {}; 21 | template struct is_same : cpp::true_type {}; 22 | template 23 | LIBC_INLINE_VAR constexpr bool is_same_v = is_same::value; 24 | 25 | } // namespace cpp 26 | } // namespace LIBC_NAMESPACE_DECL 27 | 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/remove_reference.h: -------------------------------------------------------------------------------- 1 | //===-- remove_reference type_traits ----------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // remove_reference 18 | template struct remove_reference : cpp::type_identity {}; 19 | template struct remove_reference : cpp::type_identity {}; 20 | template struct remove_reference : cpp::type_identity {}; 21 | template 22 | using remove_reference_t = typename remove_reference::type; 23 | 24 | } // namespace cpp 25 | } // namespace LIBC_NAMESPACE_DECL 26 | 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H 28 | -------------------------------------------------------------------------------- /runtimes/README.md: -------------------------------------------------------------------------------- 1 | # Runtimes 2 | 3 | # Start files (CRTstuff) 4 | 5 | Location: %sysroot/usr/lib/\/ 6 | 7 | In this order: 8 | 9 | * crt1.o: startup sequence 10 | * crt1.o: `-no-pie` 11 | * Scrt1.o: `-pie`, `-shared` 12 | * rcrt1.o: `-static-pie` 13 | * gcrt1.o: for `-pg` 14 | * crti.o: _init/_fini prolog as first object in .init section 15 | * crtbegin.o (compiler-rt): .init_array,.fini_array entries for stuff like EH frame registration and cleanup 16 | * [NOT SUPPORTED HERE] In compat mode, these also walk the .ctors, .dtors arrays. 17 | * crtbegin.o: `-no-pie` 18 | * crtbeginS.o: `-pie`, `-shared` 19 | * crtbeginT.o: `-static-pie` 20 | * crtend.o (compiler-rt): sentinel value for end of .eh_frame array. 21 | * [NOT SUPPORTED HERE] In compat mode, these also add sentinel end values for .ctors, .ctors arrays. 22 | * crtend.o: `-no-pie` 23 | * crtendS.o: `-pie`, `-shared` 24 | * crtendT.o: `-static-pie` 25 | * crtn.o: _init/_fini epilog as last object in .init section 26 | 27 | ## References 28 | - https://gist.github.com/cerisier/aadefc9d3d015799540308eb4c33db2e 29 | - https://maskray.me/blog/2021-11-07-init-ctors-init-array 30 | - https://gist.github.com/MaskRay/6c3910c7ab1df208c36cfedf965f6b51 31 | 32 | # TODO 33 | * TODO(cerisier): Write about everything else 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/remove_extent.h: -------------------------------------------------------------------------------- 1 | //===-- remove_extent type_traits -------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | #include "stddef.h" // size_t 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // remove_extent 19 | template struct remove_extent : cpp::type_identity {}; 20 | template struct remove_extent : cpp::type_identity {}; 21 | template 22 | struct remove_extent : cpp::type_identity {}; 23 | template using remove_extent_t = typename remove_extent::type; 24 | 25 | } // namespace cpp 26 | } // namespace LIBC_NAMESPACE_DECL 27 | 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H 29 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libcxx/lgamma_r.patch: -------------------------------------------------------------------------------- 1 | diff --git a/include/__random/binomial_distribution.h b/include/__random/binomial_distribution.h 2 | --- a/include/__random/binomial_distribution.h 3 | +++ b/include/__random/binomial_distribution.h 4 | @@ -97,13 +97,25 @@ class binomial_distribution { 5 | } 6 | }; 7 | 8 | -// The LLVM C library provides this with conflicting `noexcept` attributes. 9 | -#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__) 10 | -extern "C" double lgamma_r(double, int*); 11 | +// Some libc declares the math functions to be `noexcept`. 12 | +#if defined(_LIBCPP_GLIBC_PREREQ) 13 | +# if _LIBCPP_GLIBC_PREREQ(2, 8) 14 | +# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT 15 | +# else 16 | +# define _LIBCPP_LGAMMA_R_NOEXCEPT 17 | +# endif 18 | +#elif defined(__LLVM_LIBC__) 19 | +# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT 20 | +#else 21 | +# define _LIBCPP_LGAMMA_R_NOEXCEPT 22 | +#endif 23 | + 24 | +#if !defined(_LIBCPP_MSVCRT_LIKE) 25 | +extern "C" double lgamma_r(double, int*) _LIBCPP_LGAMMA_R_NOEXCEPT; 26 | #endif 27 | 28 | inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) { 29 | -#if defined(_LIBCPP_MSVCRT_LIKE) || defined(__LLVM_LIBC__) 30 | +#if defined(_LIBCPP_MSVCRT_LIKE) 31 | return lgamma(__d); 32 | #else 33 | int __sign; 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_null_pointer.h: -------------------------------------------------------------------------------- 1 | //===-- is_null_pointer type_traits -----------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H 10 | 11 | #include "src/__support/CPP/type_traits/is_same.h" 12 | #include "src/__support/CPP/type_traits/remove_cv.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is_null_pointer 20 | using nullptr_t = decltype(nullptr); 21 | template 22 | struct is_null_pointer : cpp::is_same> {}; 23 | template 24 | LIBC_INLINE_VAR constexpr bool is_null_pointer_v = is_null_pointer::value; 25 | 26 | } // namespace cpp 27 | } // namespace LIBC_NAMESPACE_DECL 28 | 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H 30 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/remove_cv.h: -------------------------------------------------------------------------------- 1 | //===-- remove_cv type_traits -----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // remove_cv 18 | template struct remove_cv : cpp::type_identity {}; 19 | template struct remove_cv : cpp::type_identity {}; 20 | template struct remove_cv : cpp::type_identity {}; 21 | template 22 | struct remove_cv : cpp::type_identity {}; 23 | template using remove_cv_t = typename remove_cv::type; 24 | 25 | } // namespace cpp 26 | } // namespace LIBC_NAMESPACE_DECL 27 | 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H 29 | -------------------------------------------------------------------------------- /runtimes/musl/extension/musl.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | load("@bazel_features//:features.bzl", "bazel_features") 3 | 4 | def _musl_extension_impl(module_ctx): 5 | """Implementation of the musl module extension.""" 6 | 7 | http_archive( 8 | name = "musl_libc", 9 | urls = ["https://musl.libc.org/releases/musl-1.2.5.tar.gz"], 10 | strip_prefix = "musl-1.2.5", 11 | patch_args = ["-p1"], 12 | patches = [ 13 | "//third_party/libc/musl:1.2.5-CVE-2025-26519-1.patch", 14 | "//third_party/libc/musl:1.2.5-CVE-2025-26519-2.patch", 15 | ], 16 | integrity = "sha256-qaEYu+hNh2TaDqDSizqz+uhHf8fkCF2QECuFlvx8deQ=", 17 | build_file = "//third_party/libc/musl:BUILD.tpl", 18 | ) 19 | 20 | metadata_kwargs = {} 21 | if bazel_features.external_deps.extension_metadata_has_reproducible: 22 | metadata_kwargs["reproducible"] = True 23 | 24 | return module_ctx.extension_metadata( 25 | root_module_direct_deps = ["musl_libc"], 26 | root_module_direct_dev_deps = [], 27 | **metadata_kwargs 28 | ) 29 | 30 | musl = module_extension( 31 | implementation = _musl_extension_impl, 32 | doc = "Extension for downloading and configuring musl libc", 33 | ) 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/invoke_result.h: -------------------------------------------------------------------------------- 1 | //===-- invoke_result type_traits -------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H 10 | 11 | #include "src/__support/CPP/type_traits/invoke.h" 12 | #include "src/__support/CPP/type_traits/type_identity.h" 13 | #include "src/__support/CPP/utility/declval.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | template 20 | struct invoke_result : cpp::type_identity(), cpp::declval()...))> {}; 22 | 23 | template 24 | using invoke_result_t = typename invoke_result::type; 25 | 26 | } // namespace cpp 27 | } // namespace LIBC_NAMESPACE_DECL 28 | 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H 30 | -------------------------------------------------------------------------------- /third_party/llvm-project/no_zlib_genrule.patch: -------------------------------------------------------------------------------- 1 | commit a8202e11aaad25ea04c93b3050898930b71ca107 2 | Author: David Zbarsky 3 | Date: Sat Dec 13 20:46:55 2025 -0500 4 | 5 | Avoid genrule in zlib 6 | 7 | diff --git a/utils/bazel/third_party_build/zlib-ng.BUILD b/utils/bazel/third_party_build/zlib-ng.BUILD 8 | index bb880c0e3279..78b2b482a9ea 100644 9 | --- a/utils/bazel/third_party_build/zlib-ng.BUILD 10 | +++ b/utils/bazel/third_party_build/zlib-ng.BUILD 11 | @@ -2,6 +2,7 @@ 12 | # See https://llvm.org/LICENSE.txt for license information. 13 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 14 | load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") 15 | +load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 16 | load("@bazel_skylib//rules:expand_template.bzl", "expand_template") 17 | load("@rules_cc//cc:cc_library.bzl", "cc_library") 18 | 19 | @@ -21,12 +22,12 @@ config_setting( 20 | flag_values = {":llvm_enable_zlib": "true"}, 21 | ) 22 | 23 | -genrule( 24 | +copy_file( 25 | # The input template is identical to the CMake output. 26 | name = "zconf_gen", 27 | - srcs = ["zconf.h.in"], 28 | - outs = ["zconf.h"], 29 | - cmd = "cp $(SRCS) $(OUTS)", 30 | + src = "zconf.h.in", 31 | + out = "zconf.h", 32 | + allow_symlink = True, 33 | ) 34 | 35 | cc_library( 36 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_array.h: -------------------------------------------------------------------------------- 1 | //===-- is_array type_traits ------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H 10 | 11 | #include "src/__support/CPP/type_traits/false_type.h" 12 | #include "src/__support/CPP/type_traits/true_type.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | #include // For size_t 17 | 18 | namespace LIBC_NAMESPACE_DECL { 19 | namespace cpp { 20 | 21 | // is_array 22 | template struct is_array : false_type {}; 23 | template struct is_array : true_type {}; 24 | template struct is_array : true_type {}; 25 | template 26 | LIBC_INLINE_VAR constexpr bool is_array_v = is_array::value; 27 | 28 | } // namespace cpp 29 | } // namespace LIBC_NAMESPACE_DECL 30 | 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H 32 | -------------------------------------------------------------------------------- /runtimes/glibc/README.md: -------------------------------------------------------------------------------- 1 | # GNU C Library (glibc) Support 2 | 3 | #TODO(cerisier): Describe how compiling against any version of the glibc works here. 4 | 5 | ## Glibc stubs 6 | 7 | The file `libc/glibc/abilist` is a Zig-specific binary blob that defines the supported 8 | glibc versions and the set of symbols each version must define. 9 | See https://github.com/ziglang/glibc-abi-tool for the tooling to generate this blob. 10 | The `glibc-stubs-generator` project uses this file to generate version-specific 11 | stub libraries on demand. 12 | 13 | The generated stub library is used for compile-time linking, with the expectation 14 | that at run-time the real glibc library will provide the actual symbol implementations. 15 | 16 | ## Notes 17 | 18 | When supporting new versions of the glibc, here are the steps required: 19 | 1. Regenerate the `abilist` file as described in https://github.com/ziglang/glibc-abi-tool 20 | 3. Ensure that headers for that version of the glibc is available in https://github.com/cerisier/glibc-headers 21 | 4. Ensure that that the kernel headers associated with that version of the glibc is 22 | available in https://github.com/cerisier/kernel-headers 23 | 5. Add the version in the various files that list glibc versions. 24 | 6. Ensure that files under `//third-party/libc/glibc` are still valid for this 25 | new version. 26 | -------------------------------------------------------------------------------- /runtimes/glibc/glibc_shared_library.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:cc_library.bzl", "cc_library") 2 | load("//toolchain/stage2:cc_stage2_shared_library.bzl", "cc_stage2_shared_library") 3 | 4 | def make_glibc_shared_library( 5 | name, 6 | lib_name, 7 | lib_version, 8 | srcs, 9 | extra_link_flags = [], 10 | ): 11 | cc_library( 12 | name = "lib%s" % lib_name, 13 | copts = [ 14 | # We compile .s (!= .S) files with a lot of -D flags. 15 | # This is easier than having to duplicate cc_flags with and without 16 | # assembly preprocessor. 17 | "-Wno-unused-command-line-argument", 18 | ], 19 | srcs = srcs, 20 | ) 21 | 22 | soname = "lib{lib}.so{version}".format( 23 | lib = lib_name, 24 | version = "."+lib_version if len(lib_version) > 0 else "" 25 | ) 26 | 27 | cc_stage2_shared_library( 28 | name = name, 29 | deps = ["lib%s" % lib_name], 30 | additional_linker_inputs = [ 31 | ":all.map", 32 | ], 33 | user_link_flags = [ 34 | "-Wl,--version-script=$(location :all.map)", 35 | "-Wl,-soname,{}".format(soname) 36 | ] + extra_link_flags, 37 | shared_lib_name = soname, 38 | visibility = ["//visibility:public"], 39 | ) 40 | 41 | return name 42 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_copy_constructible.h: -------------------------------------------------------------------------------- 1 | //===-- is_copy_constructible type_traits -----------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H 10 | 11 | #include "src/__support/CPP/type_traits/add_lvalue_reference.h" 12 | #include "src/__support/CPP/type_traits/integral_constant.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // is copy constructible 19 | template 20 | struct is_copy_constructible 21 | : public integral_constant< 22 | bool, __is_constructible(T, cpp::add_lvalue_reference_t)> {}; 23 | 24 | template 25 | LIBC_INLINE_VAR constexpr bool is_copy_constructible_v = 26 | is_copy_constructible::value; 27 | 28 | } // namespace cpp 29 | } // namespace LIBC_NAMESPACE_DECL 30 | 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H 32 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/add_pointer.h: -------------------------------------------------------------------------------- 1 | //===-- add_pointer type_traits ---------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H 10 | 11 | #include "src/__support/CPP/type_traits/remove_reference.h" 12 | #include "src/__support/CPP/type_traits/type_identity.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // add_pointer 19 | namespace detail { 20 | template 21 | auto try_add_pointer(int) -> cpp::type_identity *>; 22 | template auto try_add_pointer(...) -> cpp::type_identity; 23 | } // namespace detail 24 | template 25 | struct add_pointer : decltype(detail::try_add_pointer(0)) {}; 26 | template using add_pointer_t = typename add_pointer::type; 27 | } // namespace cpp 28 | } // namespace LIBC_NAMESPACE_DECL 29 | 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H 31 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_move_constructible.h: -------------------------------------------------------------------------------- 1 | //===-- is_move_constructible type_traits ------------------------*- C++-*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H 10 | 11 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" 12 | #include "src/__support/CPP/type_traits/integral_constant.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // is move constructible 19 | template 20 | struct is_move_constructible 21 | : public integral_constant)> {}; 23 | 24 | template 25 | LIBC_INLINE_VAR constexpr bool is_move_constructible_v = 26 | is_move_constructible::value; 27 | 28 | } // namespace cpp 29 | } // namespace LIBC_NAMESPACE_DECL 30 | 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H 32 | -------------------------------------------------------------------------------- /.github/workflows/release_prep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit -o nounset -o pipefail -x 4 | 5 | # Argument provided by reusable workflow caller, see 6 | # https://github.com/bazel-contrib/.github/blob/d197a6427c5435ac22e56e33340dff912bc9334e/.github/workflows/release_ruleset.yaml#L72 7 | TAG=$1 8 | # The prefix is chosen to match what GitHub generates for source archives 9 | PREFIX="toolchains_llvm_bootstrapped-$TAG" 10 | ARCHIVE="toolchains_llvm_bootstrapped-$TAG.tar.gz" 11 | ARCHIVE_TMP=$(mktemp) 12 | 13 | # Dummy on purpose 14 | git config user.email "you@example.com" 15 | git config user.name "Your Name" 16 | sed -i.bak "s/0.0.0/${TAG}/" MODULE.bazel && git add MODULE.bazel && git commit -m "Update version" >/dev/null 17 | 18 | # NB: configuration for 'git archive' is in /.gitattributes 19 | git archive --format=tar --prefix=${PREFIX}/ HEAD >$ARCHIVE_TMP 20 | 21 | gzip <$ARCHIVE_TMP >$ARCHIVE 22 | SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') 23 | 24 | cat << EOF 25 | ## What's Changed 26 | 27 | TODO 28 | 29 | ## Using Bzlmod 30 | 31 | 1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\` if using Bazel>=7.4.0. 32 | 2. Add to your \`MODULE.bazel\` file: 33 | 34 | \`\`\`starlark 35 | bazel_dep(name = "toolchains_llvm_bootstrapped", version = "$TAG") 36 | 37 | register_toolchains( 38 | "@toolchains_llvm_bootstrapped//toolchain:all", 39 | ) 40 | \`\`\` 41 | EOF 42 | -------------------------------------------------------------------------------- /toolchain/stage2/args/linux/BUILD.bazel: -------------------------------------------------------------------------------- 1 | 2 | load("@rules_cc//cc/toolchains:args.bzl", "cc_args") 3 | load("@rules_cc//cc/toolchains/impl:documented_api.bzl", "cc_args_list") 4 | 5 | package(default_visibility = ["//toolchain/stage2:__subpackages__"]) 6 | 7 | # Passing `/dev/null` as sysroot has the side effect of removing all default 8 | # library search paths. 9 | cc_args( 10 | name = "linux_no_sysroot", 11 | actions = [ 12 | "@rules_cc//cc/toolchains/actions:compile_actions", 13 | "@rules_cc//cc/toolchains/actions:link_actions", 14 | ], 15 | args = [ 16 | "--sysroot=/dev/null", 17 | ], 18 | ) 19 | 20 | # Differs from normal toolchain which uses -nodefaultlibs 21 | cc_args( 22 | name = "hermetic_link_flags", 23 | actions = [ 24 | "@rules_cc//cc/toolchains/actions:link_actions", 25 | ], 26 | args = [ 27 | "-nostdlib", 28 | ], 29 | ) 30 | 31 | config_setting( 32 | name = "empty_sysroot", 33 | flag_values = { 34 | "//config:empty_sysroot": "True", 35 | }, 36 | ) 37 | 38 | cc_args_list( 39 | name = "hermetic_linux_args", 40 | args = select({ 41 | ":empty_sysroot": [ 42 | ":linux_no_sysroot", 43 | ], 44 | "//conditions:default": [], 45 | }) + [ 46 | "//toolchain/args:hermetic_compile_flags", 47 | ":hermetic_link_flags", 48 | ], 49 | ) 50 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_arithmetic.h: -------------------------------------------------------------------------------- 1 | //===-- is_arithmetic type_traits -------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/is_floating_point.h" 13 | #include "src/__support/CPP/type_traits/is_integral.h" 14 | #include "src/__support/macros/attributes.h" 15 | #include "src/__support/macros/config.h" 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_arithmetic 21 | template 22 | struct is_arithmetic : cpp::bool_constant<(cpp::is_integral_v || 23 | cpp::is_floating_point_v)> {}; 24 | template 25 | LIBC_INLINE_VAR constexpr bool is_arithmetic_v = is_arithmetic::value; 26 | 27 | } // namespace cpp 28 | } // namespace LIBC_NAMESPACE_DECL 29 | 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H 31 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_copy_assignable.h: -------------------------------------------------------------------------------- 1 | //===-- is_copy_assignable type_traits --------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H 10 | 11 | #include "src/__support/CPP/type_traits/add_lvalue_reference.h" 12 | #include "src/__support/CPP/type_traits/integral_constant.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // is copy assignable 19 | template 20 | struct is_copy_assignable 21 | : public integral_constant< 22 | bool, __is_assignable(cpp::add_lvalue_reference_t, 23 | cpp::add_lvalue_reference_t)> {}; 24 | 25 | template 26 | LIBC_INLINE_VAR constexpr bool is_copy_assignable_v = 27 | is_copy_assignable::value; 28 | 29 | } // namespace cpp 30 | } // namespace LIBC_NAMESPACE_DECL 31 | 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H 33 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/add_rvalue_reference.h: -------------------------------------------------------------------------------- 1 | //===-- add_rvalue_reference type_traits ------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // add_rvalue_reference 18 | namespace detail { 19 | template 20 | auto try_add_rvalue_reference(int) -> cpp::type_identity; 21 | template auto try_add_rvalue_reference(...) -> cpp::type_identity; 22 | } // namespace detail 23 | template 24 | struct add_rvalue_reference : decltype(detail::try_add_rvalue_reference(0)) { 25 | }; 26 | template 27 | using add_rvalue_reference_t = typename add_rvalue_reference::type; 28 | 29 | } // namespace cpp 30 | } // namespace LIBC_NAMESPACE_DECL 31 | 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H 33 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/always_false.h: -------------------------------------------------------------------------------- 1 | //===-- convenient static_assert(false) helper ------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H 11 | 12 | #include "src/__support/macros/attributes.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // This is technically not part of the standard but it come often enough that 19 | // it's convenient to have around. 20 | // 21 | // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html#valid-workaround 22 | // 23 | // This will be fixed in C++23 according to [CWG 24 | // 2518](https://cplusplus.github.io/CWG/issues/2518.html). 25 | 26 | // Usage `static_assert(cpp::always_false, "error message");` 27 | template LIBC_INLINE_VAR constexpr bool always_false = false; 28 | 29 | } // namespace cpp 30 | } // namespace LIBC_NAMESPACE_DECL 31 | 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H 33 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/utility/forward.h: -------------------------------------------------------------------------------- 1 | //===-- forward utility -----------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H 10 | 11 | #include "src/__support/CPP/type_traits/is_lvalue_reference.h" 12 | #include "src/__support/CPP/type_traits/remove_reference.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // forward 20 | template 21 | LIBC_INLINE constexpr T &&forward(remove_reference_t &value) { 22 | return static_cast(value); 23 | } 24 | 25 | template 26 | LIBC_INLINE constexpr T &&forward(remove_reference_t &&value) { 27 | static_assert(!is_lvalue_reference_v, 28 | "cannot forward an rvalue as an lvalue"); 29 | return static_cast(value); 30 | } 31 | 32 | } // namespace cpp 33 | } // namespace LIBC_NAMESPACE_DECL 34 | 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H 36 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_class.h: -------------------------------------------------------------------------------- 1 | //===-- is_class type_traits ------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/false_type.h" 13 | #include "src/__support/CPP/type_traits/is_union.h" 14 | #include "src/__support/macros/attributes.h" 15 | #include "src/__support/macros/config.h" 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_class 21 | namespace detail { 22 | template cpp::bool_constant> test(int T::*); 23 | template cpp::false_type test(...); 24 | } // namespace detail 25 | template struct is_class : decltype(detail::test(nullptr)) {}; 26 | template 27 | LIBC_INLINE_VAR constexpr bool is_class_v = is_class::value; 28 | 29 | } // namespace cpp 30 | } // namespace LIBC_NAMESPACE_DECL 31 | 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H 33 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/has_unique_object_representations.h: -------------------------------------------------------------------------------- 1 | //===-- has_unique_object_representations type_traits ------------*- C++-*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H 10 | 11 | #include "src/__support/CPP/type_traits/integral_constant.h" 12 | #include "src/__support/CPP/type_traits/remove_all_extents.h" 13 | #include "src/__support/macros/config.h" 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | template 19 | struct has_unique_object_representations 20 | : public integral_constant)> {}; 22 | 23 | template 24 | LIBC_INLINE_VAR constexpr bool has_unique_object_representations_v = 25 | has_unique_object_representations::value; 26 | 27 | } // namespace cpp 28 | } // namespace LIBC_NAMESPACE_DECL 29 | 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H 31 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/macros/properties/complex_types.h: -------------------------------------------------------------------------------- 1 | //===-- Complex Types support -----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // Complex Types detection and support. 9 | 10 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H 11 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H 12 | 13 | #include "include/llvm-libc-types/cfloat128.h" 14 | #include "include/llvm-libc-types/cfloat16.h" 15 | #include "types.h" 16 | 17 | // -- cfloat16 support -------------------------------------------------------- 18 | // LIBC_TYPES_HAS_CFLOAT16 and 'cfloat16' type is provided by 19 | // "include/llvm-libc-types/cfloat16.h" 20 | 21 | // -- cfloat128 support ------------------------------------------------------- 22 | // LIBC_TYPES_HAS_CFLOAT128 and 'cfloat128' type are provided by 23 | // "include/llvm-libc-types/cfloat128.h" 24 | 25 | #if defined(LIBC_TYPES_HAS_CFLOAT128) && \ 26 | !defined(LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE) 27 | #define LIBC_TYPES_CFLOAT128_IS_NOT_COMPLEX_LONG_DOUBLE 28 | #endif 29 | 30 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H 31 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_function.h: -------------------------------------------------------------------------------- 1 | //===-- is_function type_traits ---------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/is_const.h" 13 | #include "src/__support/CPP/type_traits/is_reference.h" 14 | #include "src/__support/macros/attributes.h" 15 | #include "src/__support/macros/config.h" 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_function 21 | #if __has_builtin(__is_function) 22 | template 23 | struct is_function : integral_constant {}; 24 | #else 25 | template 26 | struct is_function 27 | : public bool_constant || is_const_v)> {}; 28 | #endif 29 | template 30 | LIBC_INLINE_VAR constexpr bool is_function_v = is_function::value; 31 | 32 | } // namespace cpp 33 | } // namespace LIBC_NAMESPACE_DECL 34 | 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H 36 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_object.h: -------------------------------------------------------------------------------- 1 | //===-- is_object type_traits -----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/is_array.h" 13 | #include "src/__support/CPP/type_traits/is_class.h" 14 | #include "src/__support/CPP/type_traits/is_scalar.h" 15 | #include "src/__support/CPP/type_traits/is_union.h" 16 | #include "src/__support/macros/attributes.h" 17 | #include "src/__support/macros/config.h" 18 | 19 | namespace LIBC_NAMESPACE_DECL { 20 | namespace cpp { 21 | 22 | // is_object 23 | template 24 | struct is_object 25 | : cpp::bool_constant || cpp::is_array_v || 26 | cpp::is_union_v || cpp::is_class_v> {}; 27 | template 28 | LIBC_INLINE_VAR constexpr bool is_object_v = is_object::value; 29 | 30 | } // namespace cpp 31 | } // namespace LIBC_NAMESPACE_DECL 32 | 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/add_lvalue_reference.h: -------------------------------------------------------------------------------- 1 | //===-- add_lvalue_reference type_traits ------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // add_lvalue_reference 18 | namespace detail { 19 | template // Note that `cv void&` is a substitution failure 20 | auto try_add_lvalue_reference(int) -> cpp::type_identity; 21 | template // Handle T = cv void case 22 | auto try_add_lvalue_reference(...) -> cpp::type_identity; 23 | } // namespace detail 24 | template 25 | struct add_lvalue_reference : decltype(detail::try_add_lvalue_reference(0)) { 26 | }; 27 | template 28 | using add_lvalue_reference_t = typename add_lvalue_reference::type; 29 | 30 | } // namespace cpp 31 | } // namespace LIBC_NAMESPACE_DECL 32 | 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_move_assignable.h: -------------------------------------------------------------------------------- 1 | //===-- is_move_assignable type_traits --------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H 10 | 11 | #include "src/__support/CPP/type_traits/add_lvalue_reference.h" 12 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" 13 | #include "src/__support/CPP/type_traits/integral_constant.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is move assignable 20 | template 21 | struct is_move_assignable 22 | : public integral_constant, 24 | cpp::add_rvalue_reference_t)> {}; 25 | 26 | template 27 | LIBC_INLINE_VAR constexpr bool is_move_assignable_v = 28 | is_move_assignable::value; 29 | 30 | } // namespace cpp 31 | } // namespace LIBC_NAMESPACE_DECL 32 | 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_pointer.h: -------------------------------------------------------------------------------- 1 | //===-- is_pointer type_traits ----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H 10 | 11 | #include "src/__support/CPP/type_traits/false_type.h" 12 | #include "src/__support/CPP/type_traits/true_type.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is_pointer 20 | template struct is_pointer : cpp::false_type {}; 21 | template struct is_pointer : cpp::true_type {}; 22 | template struct is_pointer : cpp::true_type {}; 23 | template struct is_pointer : cpp::true_type {}; 24 | template struct is_pointer : cpp::true_type {}; 25 | template 26 | LIBC_INLINE_VAR constexpr bool is_pointer_v = is_pointer::value; 27 | 28 | } // namespace cpp 29 | } // namespace LIBC_NAMESPACE_DECL 30 | 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H 32 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_member_pointer.h: -------------------------------------------------------------------------------- 1 | //===-- is_member_pointer type_traits ---------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H 10 | 11 | #include "src/__support/CPP/type_traits/false_type.h" 12 | #include "src/__support/CPP/type_traits/remove_cv.h" 13 | #include "src/__support/CPP/type_traits/true_type.h" 14 | #include "src/__support/macros/attributes.h" 15 | #include "src/__support/macros/config.h" 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_member_pointer 21 | template struct is_member_pointer_helper : cpp::false_type {}; 22 | template 23 | struct is_member_pointer_helper : cpp::true_type {}; 24 | template 25 | struct is_member_pointer : is_member_pointer_helper> {}; 26 | template 27 | LIBC_INLINE_VAR constexpr bool is_member_pointer_v = 28 | is_member_pointer::value; 29 | 30 | } // namespace cpp 31 | } // namespace LIBC_NAMESPACE_DECL 32 | 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H 34 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/utility/in_place.h: -------------------------------------------------------------------------------- 1 | //===-- in_place utility ----------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H 10 | 11 | #include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR 12 | #include "src/__support/macros/config.h" 13 | 14 | #include // size_t 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // in_place 20 | struct in_place_t { 21 | LIBC_INLINE explicit in_place_t() = default; 22 | }; 23 | LIBC_INLINE_VAR constexpr in_place_t in_place{}; 24 | 25 | template struct in_place_type_t { 26 | LIBC_INLINE explicit in_place_type_t() = default; 27 | }; 28 | template LIBC_INLINE_VAR constexpr in_place_type_t in_place_type{}; 29 | 30 | template struct in_place_index_t { 31 | LIBC_INLINE explicit in_place_index_t() = default; 32 | }; 33 | template 34 | LIBC_INLINE_VAR constexpr in_place_index_t in_place_index{}; 35 | 36 | } // namespace cpp 37 | } // namespace LIBC_NAMESPACE_DECL 38 | 39 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H 40 | -------------------------------------------------------------------------------- /third_party/libc/musl/1.2.5-CVE-2025-26519-2.patch: -------------------------------------------------------------------------------- 1 | From c47ad25ea3b484e10326f933e927c0bc8cded3da Mon Sep 17 00:00:00 2001 2 | From: Rich Felker 3 | Date: Wed, 12 Feb 2025 17:06:30 -0500 4 | Subject: [PATCH] iconv: harden UTF-8 output code path against input decoder 5 | bugs 6 | 7 | the UTF-8 output code was written assuming an invariant that iconv's 8 | decoders only emit valid Unicode Scalar Values which wctomb can encode 9 | successfully, thereby always returning a value between 1 and 4. 10 | 11 | if this invariant is not satisfied, wctomb returns (size_t)-1, and the 12 | subsequent adjustments to the output buffer pointer and remaining 13 | output byte count overflow, moving the output position backwards, 14 | potentially past the beginning of the buffer, without storing any 15 | bytes. 16 | --- 17 | src/locale/iconv.c | 4 ++++ 18 | 1 file changed, 4 insertions(+) 19 | 20 | diff --git a/src/locale/iconv.c b/src/locale/iconv.c 21 | index 008c93f0..52178950 100644 22 | --- a/src/locale/iconv.c 23 | +++ b/src/locale/iconv.c 24 | @@ -545,6 +545,10 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri 25 | if (*outb < k) goto toobig; 26 | memcpy(*out, tmp, k); 27 | } else k = wctomb_utf8(*out, c); 28 | + /* This failure condition should be unreachable, but 29 | + * is included to prevent decoder bugs from translating 30 | + * into advancement outside the output buffer range. */ 31 | + if (k>4) goto ilseq; 32 | *out += k; 33 | *outb -= k; 34 | break; 35 | -- 36 | 2.21.0 37 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_reference.h: -------------------------------------------------------------------------------- 1 | //===-- is_reference type_traits --------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/false_type.h" 13 | #include "src/__support/CPP/type_traits/true_type.h" 14 | #include "src/__support/macros/attributes.h" 15 | #include "src/__support/macros/config.h" 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_reference 21 | #if __has_builtin(__is_reference) 22 | template struct is_reference : bool_constant<__is_reference(T)> {}; 23 | #else 24 | template struct is_reference : public false_type {}; 25 | template struct is_reference : public true_type {}; 26 | template struct is_reference : public true_type {}; 27 | #endif 28 | template 29 | LIBC_INLINE_VAR constexpr bool is_reference_v = is_reference::value; 30 | 31 | } // namespace cpp 32 | } // namespace LIBC_NAMESPACE_DECL 33 | 34 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H 35 | -------------------------------------------------------------------------------- /third_party/libc/musl/1.2.5-CVE-2025-26519-1.patch: -------------------------------------------------------------------------------- 1 | From e5adcd97b5196e29991b524237381a0202a60659 Mon Sep 17 00:00:00 2001 2 | From: Rich Felker 3 | Date: Sun, 9 Feb 2025 10:07:19 -0500 4 | Subject: [PATCH] iconv: fix erroneous input validation in EUC-KR decoder 5 | 6 | as a result of incorrect bounds checking on the lead byte being 7 | decoded, certain invalid inputs which should produce an encoding 8 | error, such as "\xc8\x41", instead produced out-of-bounds loads from 9 | the ksc table. 10 | 11 | in a worst case, the loaded value may not be a valid unicode scalar 12 | value, in which case, if the output encoding was UTF-8, wctomb would 13 | return (size_t)-1, causing an overflow in the output pointer and 14 | remaining buffer size which could clobber memory outside of the output 15 | buffer. 16 | 17 | bug report was submitted in private by Nick Wellnhofer on account of 18 | potential security implications. 19 | --- 20 | src/locale/iconv.c | 2 +- 21 | 1 file changed, 1 insertion(+), 1 deletion(-) 22 | 23 | diff --git a/src/locale/iconv.c b/src/locale/iconv.c 24 | index 9605c8e9..008c93f0 100644 25 | --- a/src/locale/iconv.c 26 | +++ b/src/locale/iconv.c 27 | @@ -502,7 +502,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri 28 | if (c >= 93 || d >= 94) { 29 | c += (0xa1-0x81); 30 | d += 0xa1; 31 | - if (c >= 93 || c>=0xc6-0x81 && d>0x52) 32 | + if (c > 0xc6-0x81 || c==0xc6-0x81 && d>0x52) 33 | goto ilseq; 34 | if (d-'A'<26) d = d-'A'; 35 | else if (d-'a'<26) d = d-'a'+26; 36 | -- 37 | 2.21.0 38 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_lvalue_reference.h: -------------------------------------------------------------------------------- 1 | //===-- is_lvalue_reference type_traits -------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/false_type.h" 13 | #include "src/__support/CPP/type_traits/true_type.h" 14 | #include "src/__support/macros/attributes.h" 15 | #include "src/__support/macros/config.h" 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_lvalue_reference 21 | #if __has_builtin(__is_lvalue_reference) 22 | template 23 | struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {}; 24 | #else 25 | template struct is_lvalue_reference : public false_type {}; 26 | template struct is_lvalue_reference : public true_type {}; 27 | #endif 28 | template 29 | LIBC_INLINE_VAR constexpr bool is_lvalue_reference_v = 30 | is_lvalue_reference::value; 31 | 32 | } // namespace cpp 33 | } // namespace LIBC_NAMESPACE_DECL 34 | 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H 36 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_rvalue_reference.h: -------------------------------------------------------------------------------- 1 | //===-- is_rvalue_reference type_traits -------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/false_type.h" 13 | #include "src/__support/CPP/type_traits/true_type.h" 14 | #include "src/__support/macros/attributes.h" 15 | #include "src/__support/macros/config.h" 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_rvalue_reference 21 | #if __has_builtin(__is_rvalue_reference) 22 | template 23 | struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {}; 24 | #else 25 | template struct is_rvalue_reference : public false_type {}; 26 | template struct is_rvalue_reference : public true_type {}; 27 | #endif 28 | template 29 | LIBC_INLINE_VAR constexpr bool is_rvalue_reference_v = 30 | is_rvalue_reference::value; 31 | 32 | } // namespace cpp 33 | } // namespace LIBC_NAMESPACE_DECL 34 | 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H 36 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/utility/integer_sequence.h: -------------------------------------------------------------------------------- 1 | //===-- integer_sequence utility --------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H 10 | 11 | #include "src/__support/CPP/type_traits/is_integral.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | namespace cpp { 16 | 17 | // integer_sequence 18 | template struct integer_sequence { 19 | static_assert(cpp::is_integral_v); 20 | template using append = integer_sequence; 21 | }; 22 | 23 | namespace detail { 24 | template struct make_integer_sequence { 25 | using type = 26 | typename make_integer_sequence::type::template append; 27 | }; 28 | template struct make_integer_sequence { 29 | using type = integer_sequence; 30 | }; 31 | } // namespace detail 32 | 33 | template 34 | using make_integer_sequence = 35 | typename detail::make_integer_sequence::type; 36 | 37 | } // namespace cpp 38 | } // namespace LIBC_NAMESPACE_DECL 39 | 40 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H 41 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_scalar.h: -------------------------------------------------------------------------------- 1 | //===-- is_scalar type_traits -----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/is_arithmetic.h" 13 | #include "src/__support/CPP/type_traits/is_enum.h" 14 | #include "src/__support/CPP/type_traits/is_member_pointer.h" 15 | #include "src/__support/CPP/type_traits/is_null_pointer.h" 16 | #include "src/__support/CPP/type_traits/is_pointer.h" 17 | #include "src/__support/macros/attributes.h" 18 | #include "src/__support/macros/config.h" 19 | 20 | namespace LIBC_NAMESPACE_DECL { 21 | namespace cpp { 22 | 23 | // is_scalar 24 | template 25 | struct is_scalar 26 | : cpp::bool_constant || cpp::is_enum_v || 27 | cpp::is_pointer_v || cpp::is_member_pointer_v || 28 | cpp::is_null_pointer_v> {}; 29 | template 30 | LIBC_INLINE_VAR constexpr bool is_scalar_v = is_scalar::value; 31 | 32 | } // namespace cpp 33 | } // namespace LIBC_NAMESPACE_DECL 34 | 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H 36 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/sign.h: -------------------------------------------------------------------------------- 1 | //===-- A simple sign type --------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_SIGN_H 10 | #define LLVM_LIBC_SRC___SUPPORT_SIGN_H 11 | 12 | #include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR 13 | 14 | namespace LIBC_NAMESPACE_DECL { 15 | 16 | // A type to interact with signed arithmetic types. 17 | struct Sign { 18 | LIBC_INLINE constexpr bool is_pos() const { return !is_negative; } 19 | LIBC_INLINE constexpr bool is_neg() const { return is_negative; } 20 | 21 | LIBC_INLINE friend constexpr bool operator==(Sign a, Sign b) { 22 | return a.is_negative == b.is_negative; 23 | } 24 | 25 | LIBC_INLINE friend constexpr bool operator!=(Sign a, Sign b) { 26 | return !(a == b); 27 | } 28 | 29 | static const Sign POS; 30 | static const Sign NEG; 31 | 32 | LIBC_INLINE constexpr Sign negate() const { return Sign(!is_negative); } 33 | 34 | private: 35 | LIBC_INLINE constexpr explicit Sign(bool is_negative) 36 | : is_negative(is_negative) {} 37 | 38 | bool is_negative; 39 | }; 40 | 41 | LIBC_INLINE_VAR constexpr Sign Sign::NEG = Sign(true); 42 | LIBC_INLINE_VAR constexpr Sign Sign::POS = Sign(false); 43 | 44 | } // namespace LIBC_NAMESPACE_DECL 45 | #endif // LLVM_LIBC_SRC___SUPPORT_SIGN_H 46 | -------------------------------------------------------------------------------- /toolchain/README: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | # Support module maps 4 | # Support macOS specific flags (objc and frameworks) 5 | 6 | https://github.com/bazelbuild/rules_cc/blob/main/docs/toolchain_api.md 7 | 8 | https://github.com/CACI-International/cpp-toolchain/blob/74efb5bc636f48db86652f0cfdb7d46af100e51f/bazel/toolchain.bzl#L31 9 | 10 | https://github.com/cortecs-lang/cortecs-cc-toolchain/blob/78792fba9eec75bfac14a0cd20cb0e4973175871/sysroot/alpine/BUILD 11 | 12 | https://github.com/lukasoyen/bazel_linux_packages/blob/c50a9bf22122a507d2bb5e348231413a05e6d90f/e2e/toolchains/gcc/BUILD.bazel 13 | 14 | https://github.com/lowRISC/opentitan/blob/6d29bb86581892c43d3dea8856b275dc3a40c575/toolchain/README.md 15 | 16 | https://cs.opensource.google/pigweed/pigweed/+/main:pw_toolchain/cc/args/BUILD.bazel 17 | 18 | # extra_flags_per_feature = {} 19 | # if is_clang: 20 | # # Only supported by LLVM 14 and later, but required with C++20 and 21 | # # layering_check as C++ modules are the default. 22 | # # https://github.com/llvm/llvm-project/commit/0556138624edf48621dd49a463dbe12e7101f17d 23 | # result = repository_ctx.execute([ 24 | # cc, 25 | # "-Xclang", 26 | # "-fno-cxx-modules", 27 | # "-o", 28 | # "/dev/null", 29 | # "-c", 30 | # str(repository_ctx.path("tools/cpp/empty.cc")), 31 | # ]) 32 | # if "-fno-cxx-modules" not in result.stderr: 33 | # extra_flags_per_feature["use_module_maps"] = ["-Xclang", "-fno-cxx-modules"] 34 | 35 | 36 | # Other Resources 37 | 38 | https://github.com/envoyproxy/envoy/blob/main/bazel/rbe/toolchains/configs/linux/clang/cc/cc_toolchain_config.bzl 39 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_trivially_destructible.h: -------------------------------------------------------------------------------- 1 | //===-- is_trivially_destructible type_traits -------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H 10 | 11 | #include "src/__support/CPP/type_traits/bool_constant.h" 12 | #include "src/__support/CPP/type_traits/is_destructible.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is_trivially_destructible 20 | #if __has_builtin(__is_trivially_destructible) 21 | template 22 | struct is_trivially_destructible 23 | : public bool_constant<__is_trivially_destructible(T)> {}; 24 | #else 25 | template 26 | struct is_trivially_destructible 27 | : public bool_constant &&__has_trivial_destructor( 28 | T)> {}; 29 | #endif // __has_builtin(__is_trivially_destructible) 30 | template 31 | LIBC_INLINE_VAR constexpr bool is_trivially_destructible_v = 32 | is_trivially_destructible::value; 33 | 34 | } // namespace cpp 35 | } // namespace LIBC_NAMESPACE_DECL 36 | 37 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H 38 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/compiler-rt/targets.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:defs.bzl", "cc_library") 2 | load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 3 | 4 | """ 5 | Helper functions for defining targets. 6 | """ 7 | def atomic_helper_cc_library(name, pat, size, model): 8 | 9 | unique_filename = "lse_{}_{}_{}".format(pat, size, model) 10 | 11 | # cc_library will always produce an archive file containing lse.o. 12 | # Because those end up in a static library, cc_static_library will complain 13 | # that the archive has lse.o specified multiple times. 14 | copy_file( 15 | name = unique_filename, 16 | src = "lib/builtins/aarch64/lse.S", 17 | out = "{}.S".format(unique_filename), 18 | allow_symlink = True, 19 | ) 20 | 21 | cc_library( 22 | name = name, 23 | srcs = [unique_filename], 24 | copts = [ 25 | # Normally, we would pass -nostdinc, but since we pass -nostdlibinc 26 | # from the stage2 toolchain args regarless, having them both cause a 27 | # warning about -nostdlibinc being ignored, so we duplicate the 28 | # -nostdlibinc and add -nobuiltininc to avoid the warning. 29 | # 30 | # -nostdinc = -nostdlibinc -nobuiltininc 31 | "-nostdlibinc", 32 | "-nobuiltininc", 33 | ], 34 | local_defines = [ 35 | "L_{}".format(pat), 36 | "SIZE={}".format(size), 37 | "MODEL={}".format(model), 38 | ], 39 | hdrs = [ 40 | "lib/builtins/assembly.h", 41 | ], 42 | includes = ["lib/builtins"], 43 | ) 44 | return name 45 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/hdr/fenv_macros.h: -------------------------------------------------------------------------------- 1 | //===-- Definition of macros from fenv.h ----------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_HDR_FENV_MACROS_H 10 | #define LLVM_LIBC_HDR_FENV_MACROS_H 11 | 12 | #ifdef LIBC_FULL_BUILD 13 | 14 | #include "include/llvm-libc-macros/fenv-macros.h" 15 | 16 | #else // Overlay mode 17 | 18 | #include 19 | 20 | // In some environment, FE_ALL_EXCEPT is set to 0 and the remaining exceptions 21 | // FE_* are missing. 22 | #ifndef FE_DIVBYZERO 23 | #define FE_DIVBYZERO 0 24 | #endif // FE_DIVBYZERO 25 | 26 | #ifndef FE_INEXACT 27 | #define FE_INEXACT 0 28 | #endif // FE_INEXACT 29 | 30 | #ifndef FE_INVALID 31 | #define FE_INVALID 0 32 | #endif // FE_INVALID 33 | 34 | #ifndef FE_OVERFLOW 35 | #define FE_OVERFLOW 0 36 | #endif // FE_OVERFLOW 37 | 38 | #ifndef FE_UNDERFLOW 39 | #define FE_UNDERFLOW 0 40 | #endif // FE_UNDERFLOW 41 | 42 | // Rounding mode macros might be missing. 43 | #ifndef FE_DOWNWARD 44 | #define FE_DOWNWARD 0x400 45 | #endif // FE_DOWNWARD 46 | 47 | #ifndef FE_TONEAREST 48 | #define FE_TONEAREST 0 49 | #endif // FE_TONEAREST 50 | 51 | #ifndef FE_TOWARDZERO 52 | #define FE_TOWARDZERO 0xC00 53 | #endif // FE_TOWARDZERO 54 | 55 | #ifndef FE_UPWARD 56 | #define FE_UPWARD 0x800 57 | #endif // FE_UPWARD 58 | 59 | #endif // LLVM_LIBC_FULL_BUILD 60 | 61 | #endif // LLVM_LIBC_HDR_FENV_MACROS_H 62 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/include/llvm-libc-types/float128.h: -------------------------------------------------------------------------------- 1 | //===-- Definition of float128 type ---------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_TYPES_FLOAT128_H 10 | #define LLVM_LIBC_TYPES_FLOAT128_H 11 | 12 | #include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG 13 | 14 | // Currently, C23 `_Float128` type is only defined as a built-in type in GCC 7 15 | // or later, and only for C. For C++, or for clang, `__float128` is defined 16 | // instead, and only on x86-64 targets. 17 | // 18 | // TODO: Update C23 `_Float128` type detection again when clang supports it. 19 | // https://github.com/llvm/llvm-project/issues/80195 20 | #if defined(__STDC_IEC_60559_BFP__) && !defined(__clang__) && \ 21 | !defined(__cplusplus) 22 | #define LIBC_TYPES_HAS_FLOAT128 23 | typedef _Float128 float128; 24 | #elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) 25 | // Use __float128 type. gcc and clang sometime use __SIZEOF_FLOAT128__ to 26 | // notify the availability of __float128. 27 | // clang also uses __FLOAT128__ macro to notify the availability of __float128 28 | // type: https://reviews.llvm.org/D15120 29 | #define LIBC_TYPES_HAS_FLOAT128 30 | typedef __float128 float128; 31 | #elif (LDBL_MANT_DIG == 113) 32 | #define LIBC_TYPES_HAS_FLOAT128 33 | typedef long double float128; 34 | #endif 35 | 36 | #endif // LLVM_LIBC_TYPES_FLOAT128_H 37 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/remove_all_extents.h: -------------------------------------------------------------------------------- 1 | //===-- remove_all_extents type_traits --------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | 14 | #include // size_t 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // remove_all_extents 20 | #if __has_builtin(__remove_all_extents) 21 | template using remove_all_extents_t = __remove_all_extents(T); 22 | template 23 | struct remove_all_extents : cpp::type_identity> {}; 24 | #else 25 | template struct remove_all_extents { 26 | using type = T; 27 | }; 28 | template struct remove_all_extents { 29 | using type = typename remove_all_extents::type; 30 | }; 31 | template struct remove_all_extents { 32 | using type = typename remove_all_extents::type; 33 | }; 34 | template 35 | using remove_all_extents_t = typename remove_all_extents::type; 36 | #endif 37 | 38 | } // namespace cpp 39 | } // namespace LIBC_NAMESPACE_DECL 40 | 41 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H 42 | -------------------------------------------------------------------------------- /toolchain/stage2/cc_unsanitized_library.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") 2 | 3 | def _reset_sanitizers_impl(settings, attr): 4 | return { 5 | "//config:ubsan": False, 6 | "//config/stage1:ubsan": False, 7 | 8 | # Right now, this rule is used to compile parts of LLVM. 9 | # We can't use the stage2 toolchain for that. 10 | "//toolchain:bootstrap_setting": False, 11 | "//toolchain:stage1_bootstrap_setting": False, 12 | 13 | # And LLVM uses instead of "zlib.h" so we disable it here too. 14 | "@llvm_zlib//:llvm_enable_zlib": False, 15 | } 16 | 17 | _reset_sanitizers = transition( 18 | implementation = _reset_sanitizers_impl, 19 | inputs = [], 20 | outputs = [ 21 | "//config:ubsan", 22 | "//config/stage1:ubsan", 23 | "//toolchain:bootstrap_setting", 24 | "//toolchain:stage1_bootstrap_setting", 25 | "@llvm_zlib//:llvm_enable_zlib", 26 | ], 27 | ) 28 | 29 | def _cc_unsanitized_library_impl(ctx): 30 | # It's a list because it's transitioned. 31 | dep = ctx.attr.dep[0] 32 | 33 | providers = [ 34 | dep[DefaultInfo], 35 | dep[CcInfo], 36 | ] 37 | 38 | if OutputGroupInfo in dep: 39 | providers.append(dep[OutputGroupInfo]) 40 | 41 | if InstrumentedFilesInfo in dep: 42 | providers.append(dep[InstrumentedFilesInfo]) 43 | 44 | return providers 45 | 46 | cc_unsanitized_library = rule( 47 | implementation = _cc_unsanitized_library_impl, 48 | attrs = { 49 | "dep": attr.label( 50 | cfg = _reset_sanitizers, 51 | providers = [CcInfo], 52 | ), 53 | }, 54 | ) 55 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/decay.h: -------------------------------------------------------------------------------- 1 | //===-- decay type_traits ---------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H 10 | 11 | #include "src/__support/macros/attributes.h" 12 | 13 | #include "src/__support/CPP/type_traits/add_pointer.h" 14 | #include "src/__support/CPP/type_traits/conditional.h" 15 | #include "src/__support/CPP/type_traits/is_array.h" 16 | #include "src/__support/CPP/type_traits/is_function.h" 17 | #include "src/__support/CPP/type_traits/remove_cv.h" 18 | #include "src/__support/CPP/type_traits/remove_extent.h" 19 | #include "src/__support/CPP/type_traits/remove_reference.h" 20 | #include "src/__support/macros/config.h" 21 | 22 | namespace LIBC_NAMESPACE_DECL { 23 | namespace cpp { 24 | 25 | // decay 26 | template class decay { 27 | using U = cpp::remove_reference_t; 28 | 29 | public: 30 | using type = conditional_t< 31 | cpp::is_array_v, cpp::add_pointer_t>, 32 | cpp::conditional_t, cpp::add_pointer_t, 33 | cpp::remove_cv_t>>; 34 | }; 35 | template using decay_t = typename decay::type; 36 | 37 | } // namespace cpp 38 | } // namespace LIBC_NAMESPACE_DECL 39 | 40 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H 41 | -------------------------------------------------------------------------------- /runtimes/glibc/glibc_stubs_assembly_files.bzl: -------------------------------------------------------------------------------- 1 | 2 | def _glibc_stubs_impl(ctx): 3 | target = ctx.attr.target 4 | 5 | version_script = ctx.actions.declare_file("build/all.map") 6 | 7 | outputs = [ 8 | ctx.actions.declare_file("build/c.s"), 9 | ctx.actions.declare_file("build/dl.s"), 10 | ctx.actions.declare_file("build/ld.s"), 11 | ctx.actions.declare_file("build/m.s"), 12 | ctx.actions.declare_file("build/pthread.s"), 13 | ctx.actions.declare_file("build/resolv.s"), 14 | ctx.actions.declare_file("build/rt.s"), 15 | ctx.actions.declare_file("build/util.s"), 16 | version_script, 17 | ] 18 | 19 | args = ctx.actions.args() 20 | args.add("-target") 21 | args.add(target) 22 | args.add("-o") 23 | args.add(version_script.dirname) 24 | args.add(ctx.files.abilist[0]) 25 | 26 | ctx.actions.run( 27 | executable = ctx.executable._generator, 28 | inputs = [ctx.files.abilist[0]], 29 | arguments = [args], 30 | outputs = outputs, 31 | ) 32 | return [ 33 | DefaultInfo(files = depset(outputs)), 34 | ] 35 | 36 | glibc_stubs_assembly_files = rule( 37 | implementation = _glibc_stubs_impl, 38 | attrs = { 39 | "target": attr.string( 40 | mandatory = True, 41 | ), 42 | "_generator": attr.label( 43 | default = "//runtimes/glibc:glibc-stubs-generator", 44 | allow_single_file = True, 45 | executable = True, 46 | cfg = "exec", 47 | ), 48 | "abilist": attr.label( 49 | allow_single_file = True, 50 | ), 51 | }, 52 | doc = "Generates glibc stub files for a given target.", 53 | ) 54 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/macros/properties/compiler.h: -------------------------------------------------------------------------------- 1 | //===-- Compile time compiler detection -------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H 10 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H 11 | 12 | // Example usage of compiler version checks 13 | // #if defined(LIBC_COMPILER_CLANG_VER) 14 | // # if LIBC_COMPILER_CLANG_VER < 1500 15 | // # warning "Libc only supports Clang 15 and later" 16 | // # endif 17 | // #elif defined(LIBC_COMPILER_GCC_VER) 18 | // # if LIBC_COMPILER_GCC_VER < 1500 19 | // # warning "Libc only supports GCC 15 and later" 20 | // # endif 21 | // #elif defined(LIBC_COMPILER_MSC_VER) 22 | // # if LIBC_COMPILER_MSC_VER < 1930 23 | // # warning "Libc only supports Visual Studio 2022 RTW (17.0) and later" 24 | // # endif 25 | // #endif 26 | 27 | #if defined(__clang__) 28 | #define LIBC_COMPILER_IS_CLANG 29 | #define LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 30 | #endif 31 | 32 | #if defined(__GNUC__) && !defined(__clang__) 33 | #define LIBC_COMPILER_IS_GCC 34 | #define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__) 35 | #endif 36 | 37 | #if defined(_MSC_VER) 38 | #define LIBC_COMPILER_IS_MSC 39 | // https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros 40 | #define LIBC_COMPILER_MSC_VER (_MSC_VER) 41 | #endif 42 | 43 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H 44 | -------------------------------------------------------------------------------- /toolchain/declare_toolchains.bzl: -------------------------------------------------------------------------------- 1 | load("//platforms:common.bzl", _supported_targets = "SUPPORTED_TARGETS", _supported_execs = "SUPPORTED_EXECS") 2 | load("//toolchain:selects.bzl", "platform_cc_tool_map") 3 | load(":cc_toolchain.bzl", "cc_toolchain") 4 | 5 | def declare_all_toolchains(): 6 | for (exec_os, exec_cpu) in _supported_execs: 7 | _declare_toolchains(exec_os, exec_cpu) 8 | 9 | def _declare_toolchains(exec_os, exec_cpu): 10 | cc_toolchain_name = "{}_{}_cc_toolchain".format(exec_os, exec_cpu) 11 | 12 | # Even though `tool_map` has an exec transition, Bazel doesn't properly handle 13 | # binding a single `cc_toolchain` to multiple toolchains with different `exec_compatible_with`. 14 | # See https://github.com/bazelbuild/rules_cc/issues/299#issuecomment-2660340534 15 | cc_toolchain( 16 | name = cc_toolchain_name, 17 | tool_map = platform_cc_tool_map(exec_os, exec_cpu), 18 | ) 19 | 20 | for (target_os, target_cpu) in _supported_targets: 21 | native.toolchain( 22 | name = "{}_{}_to_{}_{}".format(exec_os, exec_cpu, target_os, target_cpu), 23 | exec_compatible_with = [ 24 | "@platforms//cpu:{}".format(exec_cpu), 25 | "@platforms//os:{}".format(exec_os), 26 | ], 27 | target_compatible_with = [ 28 | "@platforms//cpu:{}".format(target_cpu), 29 | "@platforms//os:{}".format(target_os), 30 | ], 31 | target_settings = [ 32 | "//toolchain:bootstrapped", 33 | ], 34 | toolchain = cc_toolchain_name, 35 | toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", 36 | visibility = ["//visibility:public"], 37 | ) 38 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_integral.h: -------------------------------------------------------------------------------- 1 | //===-- is_integral type_traits ---------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H 10 | 11 | #include "src/__support/CPP/type_traits/is_same.h" 12 | #include "src/__support/CPP/type_traits/remove_cv.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_integral 21 | template struct is_integral { 22 | private: 23 | template 24 | LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { 25 | return (... || is_same_v, Args>); 26 | } 27 | 28 | public: 29 | LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of< 30 | T, 31 | #ifdef LIBC_TYPES_HAS_INT128 32 | __int128_t, __uint128_t, 33 | #endif 34 | char, signed char, unsigned char, short, unsigned short, int, 35 | unsigned int, long, unsigned long, long long, unsigned long long, bool>(); 36 | }; 37 | template 38 | LIBC_INLINE_VAR constexpr bool is_integral_v = is_integral::value; 39 | 40 | } // namespace cpp 41 | } // namespace LIBC_NAMESPACE_DECL 42 | 43 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H 44 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/compiler-rt/README.md: -------------------------------------------------------------------------------- 1 | # FLAGS APPLE 2 | set(CFLAGS -fPIC -O3 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -fomit-frame-pointer) 3 | 4 | OSX EXCLUDED SYMBOLS: 5 | apple_versioning 6 | addtf3 7 | divtf3 8 | multf3 9 | powitf2 10 | subtf3 11 | trampoline_setup 12 | 13 | 14 | # FLAGS NOT APPLE 15 | -fPIC # implied 16 | -fPIE # implied 17 | -fno-builtin # always 18 | -std=c11 # always 19 | -fvisibility=hidden # always 20 | -fomit-frame-pointer # if not debug 21 | -ffreestanding # if amdgcn/nvptx 22 | -Wno-pedantic # LLVM CRT 23 | -nogpulib # if amdgcn/nvptx 24 | -flto # if amdgcn/nvptx 25 | -fconvergent-functions # if amdgcn/nvptx 26 | "-Xclang -mcode-object-version=none" # if amdgcn 27 | -Wbuiltin-declaration-mismatch # always 28 | 29 | 30 | if(APPLE) 31 | set(ARM64 arm64 arm64e) 32 | set(ARM32 armv7 armv7k armv7s) 33 | set(X86_64 x86_64 x86_64h) 34 | endif() 35 | 36 | 37 | set(ALL_BUILTIN_SUPPORTED_ARCH 38 | ${X86} ${X86_64} ${AMDGPU} ${ARM32} ${ARM64} ${AVR} 39 | ${HEXAGON} ${MIPS32} ${MIPS64} ${NVPTX} ${PPC32} ${PPC64} 40 | ${RISCV32} ${RISCV64} ${SPARC} ${SPARCV9} 41 | ${WASM32} ${WASM64} ${VE} ${LOONGARCH64}) 42 | 43 | # SOURCES 44 | 45 | if(APPLE) 46 | set(GENERIC_SOURCES 47 | ${GENERIC_SOURCES} 48 | atomic_flag_clear.c 49 | atomic_flag_clear_explicit.c 50 | atomic_flag_test_and_set.c 51 | atomic_flag_test_and_set_explicit.c 52 | atomic_signal_fence.c 53 | atomic_thread_fence.c 54 | ) 55 | endif() 56 | 57 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/macros/attributes.h: -------------------------------------------------------------------------------- 1 | //===-- Portable attributes -------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // This header file defines macros for declaring attributes for functions, 9 | // types, and variables. 10 | // 11 | // These macros are used within llvm-libc and allow the compiler to optimize, 12 | // where applicable, certain function calls. 13 | // 14 | // Most macros here are exposing GCC or Clang features, and are stubbed out for 15 | // other compilers. 16 | 17 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H 18 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H 19 | 20 | #include "properties/architectures.h" 21 | 22 | #ifndef __has_attribute 23 | #define __has_attribute(x) 0 24 | #endif 25 | 26 | #define LIBC_INLINE inline 27 | #define LIBC_INLINE_VAR inline 28 | #define LIBC_INLINE_ASM __asm__ __volatile__ 29 | #define LIBC_UNUSED __attribute__((unused)) 30 | 31 | #ifdef LIBC_TARGET_ARCH_IS_GPU 32 | #define LIBC_THREAD_LOCAL 33 | #else 34 | #define LIBC_THREAD_LOCAL thread_local 35 | #endif 36 | 37 | #if __cplusplus >= 202002L 38 | #define LIBC_CONSTINIT constinit 39 | #elif __has_attribute(__require_constant_initialization__) 40 | #define LIBC_CONSTINIT __attribute__((__require_constant_initialization__)) 41 | #else 42 | #define LIBC_CONSTINIT 43 | #endif 44 | 45 | #if defined(__clang__) && __has_attribute(preferred_type) 46 | #define LIBC_PREFERED_TYPE(TYPE) [[clang::preferred_type(TYPE)]] 47 | #else 48 | #define LIBC_PREFERED_TYPE(TYPE) 49 | #endif 50 | 51 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H 52 | -------------------------------------------------------------------------------- /third_party/libc/glibc/README.md: -------------------------------------------------------------------------------- 1 | # GNU C Library ("glibc") Edits 2 | 3 | This package contains patches to a few files from the GNU C Library project. 4 | 5 | ## `csu/abi-note-2.31.S` 6 | 7 | `csu/abi-note-2.31.S` is a copy of `csu/abi-note.S` from the glibc 8 | `release/2.31/master` branch. 9 | 10 | Starting in version 2.32, this file was rewritten in C (`abi-note.c`) and began 11 | including many headers that are difficult to handle in Bazel. 12 | 13 | Since the behavior of the new C version is identical to the original assembly 14 | file, we chose to keep using the 2.31 version for simplicity. 15 | 16 | ## `csu/elf-init-2.31.c` 17 | 18 | `csu/elf-init-2.31.c` is a copy of `csu/elf-init.c` from the glibc 19 | `release/2.31/master` branch. 20 | 21 | In glibc versions 2.32 and 2.33, support for `_init` 22 | and `_fini` became mandatory and could no longer be disabled with compile-time 23 | flags. 24 | 25 | Before 2.32, these functions could be excluded by defining `-DNO_INITFINI`. 26 | Starting with 2.32, this was replaced with an internal `#define ELF_INITFINI` 27 | in a header file, which could not be overridden. 28 | 29 | In version 2.34, `_init` and `_fini` were removed entirely. 30 | 31 | We use the version from 2.31 because it still allows opting out of `_init` and `_fini`. 32 | 33 | ## `nptl/pthread_atfork.c`, `stdlib/at_exit.c` and `stdlib/at_quick_exit.c` 34 | 35 | Those 2 files are a copy from the `ziglang/zig` glibc support package 36 | which themselves are edited versions of the same files from the glibc project. 37 | 38 | Similar to `csu/abi-note.c`, They were including many headers that are too 39 | difficult to handle in Bazel. 40 | 41 | Headers inclusions were replaced with inlined functions definitions for 42 | simplicity. 43 | 44 | # Notes 45 | 46 | Those files will be monitored everytime a new version of the glibc is supported 47 | to ensure that they can be used for all versions, otherwise we will branch as 48 | needed. 49 | -------------------------------------------------------------------------------- /toolchain/cc_toolchain.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc/toolchains:toolchain.bzl", _cc_toolchain = "cc_toolchain") 2 | 3 | def cc_toolchain(name, tool_map): 4 | _cc_toolchain( 5 | name = name, 6 | args = ["//toolchain:toolchain_args"], 7 | artifact_name_patterns = select({ 8 | "@platforms//os:windows": [ 9 | "//toolchain:windows_executable_pattern", 10 | ], 11 | "//conditions:default": [], 12 | }), 13 | known_features = [ 14 | "//toolchain/features:static_link_cpp_runtimes", 15 | "@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features", 16 | "//toolchain/features:all_non_legacy_builtin_features", 17 | "//toolchain/features/legacy:all_legacy_builtin_features", 18 | ] + select({ 19 | "@platforms//os:linux": [ 20 | "@rules_cc//cc/toolchains/args/thin_lto:feature", 21 | ], 22 | "//conditions:default": [], 23 | }), 24 | enabled_features = select({ 25 | "@platforms//os:linux": [ 26 | "//toolchain/features:static_link_cpp_runtimes", 27 | ], 28 | "@platforms//os:macos": [], 29 | "@platforms//os:windows": [ 30 | "//toolchain/features:static_link_cpp_runtimes", 31 | ], 32 | "@platforms//os:none": [], 33 | }) + [ 34 | "@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features", 35 | # Do not enable this manually. Those features are enabled internally by --compilation_mode flags family. 36 | "//toolchain/features/legacy:all_legacy_builtin_features", 37 | ], 38 | tool_map = tool_map, 39 | static_runtime_lib = "//runtimes:static_runtime_lib", 40 | dynamic_runtime_lib = "//runtimes:dynamic_runtime_lib", 41 | compiler = "clang", 42 | ) 43 | -------------------------------------------------------------------------------- /third_party/libc/glibc/helpers.bzl: -------------------------------------------------------------------------------- 1 | def glibc_includes(cpu): 2 | 3 | x86_64_variant = [ 4 | "sysdeps/unix/sysv/linux/x86_64/64".format(cpu), 5 | ] if cpu == "x86_64" else [] 6 | 7 | return [ 8 | "include", 9 | "sysdeps/unix/sysv/linux/{}".format(cpu), 10 | ] + x86_64_variant + [ 11 | "sysdeps/{}".format(cpu), 12 | "sysdeps/unix/sysv/linux/generic", 13 | "sysdeps/unix/sysv/linux/include", 14 | "sysdeps/unix/sysv/linux", 15 | "sysdeps/{}/nptl".format(cpu), 16 | "sysdeps/nptl", 17 | "sysdeps/pthread", 18 | "sysdeps/unix/sysv", 19 | "sysdeps/unix/{}".format(cpu), 20 | "sysdeps/unix", 21 | "sysdeps/{}".format(cpu), 22 | "sysdeps/generic", 23 | ".", 24 | ] 25 | 26 | # hdrs = glob([ 27 | # "lib/libc/glibc/**/*.h", 28 | # ], exclude = [ 29 | # "lib/libc/glibc/sysdeps/**", 30 | # "lib/libc/glibc/include/**", 31 | # ]) + glob([ 32 | # "lib/libc/glibc/include/*.h", 33 | # "lib/libc/glibc/include/*.h", 34 | # ]) 35 | # + glob( 36 | # [ 37 | # "lib/libc/glibc/sysdeps/unix/sysv/linux/x86_64/**", 38 | # "lib/libc/glibc/sysdeps/x86_64/**", 39 | # "lib/libc/glibc/sysdeps/unix/sysv/linux/generic/**", 40 | # "lib/libc/glibc/sysdeps/unix/sysv/linux/include/**", 41 | # ], 42 | # allow_empty = True 43 | # ) + glob( 44 | # [ 45 | # "lib/libc/glibc/sysdeps/unix/sysv/linux/*", 46 | # "lib/libc/glibc/sysdeps/unix/sysv/linux/bits/**", 47 | # "lib/libc/glibc/sysdeps/unix/sysv/linux/sys/**", 48 | # ], 49 | # allow_empty = True 50 | # ) 51 | # + glob([ 52 | # # "lib/libc/glibc/sysdeps/nptl/**", 53 | # "lib/libc/glibc/sysdeps/pthread/**", 54 | # "lib/libc/glibc/sysdeps/unix/x86_64/**", 55 | # # "lib/libc/glibc/sysdeps/x86_64/**", 56 | # "lib/libc/glibc/sysdeps/generic/**", 57 | # ], 58 | # allow_empty = True 59 | # ), 60 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/macros/null_check.h: -------------------------------------------------------------------------------- 1 | //===-- Safe nullptr check --------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H 10 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H 11 | 12 | #include "src/__support/macros/config.h" 13 | #include "src/__support/macros/optimization.h" 14 | #include "src/__support/macros/sanitizer.h" 15 | 16 | #if defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER) 17 | #define LIBC_CRASH_ON_NULLPTR(ptr) \ 18 | do { \ 19 | if (LIBC_UNLIKELY((ptr) == nullptr)) \ 20 | __builtin_trap(); \ 21 | } while (0) 22 | #define LIBC_CRASH_ON_VALUE(var, value) \ 23 | do { \ 24 | if (LIBC_UNLIKELY((var) == (value))) \ 25 | __builtin_trap(); \ 26 | } while (0) 27 | 28 | #else 29 | #define LIBC_CRASH_ON_NULLPTR(ptr) \ 30 | do { \ 31 | } while (0) 32 | #define LIBC_CRASH_ON_VALUE(var, value) \ 33 | do { \ 34 | } while (0) 35 | #endif 36 | 37 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H 38 | -------------------------------------------------------------------------------- /toolchain/stage2/args/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc/toolchains:args.bzl", "cc_args") 2 | load("@rules_cc//cc/toolchains/impl:documented_api.bzl", "cc_args_list") 3 | 4 | package(default_visibility = ["//toolchain/stage2:__subpackages__"]) 5 | 6 | # compile_actions minus assemble_actions (only preprocess_assemble) 7 | OPT_FLAGS_COMPILE_ACTIONS = [ 8 | "@rules_cc//cc/toolchains/actions:cpp_compile_actions", 9 | "@rules_cc//cc/toolchains/actions:c_compile_actions", 10 | "@rules_cc//cc/toolchains/actions:preprocess_assemble", 11 | "@rules_cc//cc/toolchains/actions:objc_compile", 12 | "@rules_cc//cc/toolchains/actions:objcpp_compile", 13 | ] 14 | 15 | # libc must be compiled with optimizations (should match with above) 16 | cc_args( 17 | name = "opt_compile_flags", 18 | # compile_actions minus assemble_actions (only preprocess_assemble) 19 | actions = OPT_FLAGS_COMPILE_ACTIONS, 20 | args = [ 21 | "-DNDEBUG", 22 | "-O2", 23 | ], 24 | ) 25 | 26 | cc_args( 27 | name = "dbg_compile_flags", 28 | actions = OPT_FLAGS_COMPILE_ACTIONS, 29 | args = [ 30 | "-D_DEBUG", 31 | "-O0", 32 | "-g", 33 | ], 34 | ) 35 | 36 | # Use args/use_lld when it's fixed 37 | cc_args( 38 | name = "default_link_flags", 39 | actions = [ 40 | "@rules_cc//cc/toolchains/actions:link_actions", 41 | ], 42 | args = [ 43 | "-fuse-ld=lld", 44 | # "--ld-path={lld_path}", 45 | ], 46 | ) 47 | 48 | cc_args_list( 49 | name = "ubsan_flags", 50 | args = select({ 51 | # We just need to recompile with sanitizer flags, don't need linker flags. 52 | # And in fact linker flags will cause a cycle. If we ever need a sanitizer 53 | # for compilation, we would need an extra bootstrap stage. 54 | "//toolchain/args:ubsan_enabled": [ 55 | "//toolchain/args:ubsan_compiler_flags", 56 | ], 57 | "//conditions:default": [], 58 | }), 59 | ) 60 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_floating_point.h: -------------------------------------------------------------------------------- 1 | //===-- is_floating_point type_traits ---------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H 10 | 11 | #include "src/__support/CPP/type_traits/is_same.h" 12 | #include "src/__support/CPP/type_traits/remove_cv.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128 16 | 17 | namespace LIBC_NAMESPACE_DECL { 18 | namespace cpp { 19 | 20 | // is_floating_point 21 | template struct is_floating_point { 22 | private: 23 | template 24 | LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { 25 | return (... || is_same_v, Args>); 26 | } 27 | 28 | public: 29 | LIBC_INLINE_VAR static constexpr bool value = 30 | __is_unqualified_any_of(); 41 | }; 42 | template 43 | LIBC_INLINE_VAR constexpr bool is_floating_point_v = 44 | is_floating_point::value; 45 | 46 | } // namespace cpp 47 | } // namespace LIBC_NAMESPACE_DECL 48 | 49 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H 50 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/include/llvm-libc-types/cfloat128.h: -------------------------------------------------------------------------------- 1 | //===-- Definition of cfloat128 type --------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_LIBC_TYPES_CFLOAT128_H 10 | #define LLVM_LIBC_TYPES_CFLOAT128_H 11 | 12 | #include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG 13 | 14 | // Currently, the complex variant of C23 `_Float128` type is only defined as a 15 | // built-in type in GCC 7 or later, for C and in GCC 13 or later, for C++. For 16 | // clang, the complex variant of `__float128` is defined instead, and only on 17 | // x86-64 targets for clang 11 or later. 18 | // 19 | // TODO: Update the complex variant of C23 `_Float128` type detection again when 20 | // clang supports it. 21 | #ifdef __clang__ 22 | #if (__clang_major__ >= 11) && \ 23 | (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)) 24 | // Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__ 25 | // macro to notify the availability of __float128 type: 26 | // https://reviews.llvm.org/D15120 27 | #define LIBC_TYPES_HAS_CFLOAT128 28 | typedef _Complex __float128 cfloat128; 29 | #endif 30 | #elif defined(__GNUC__) 31 | #if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \ 32 | (__GNUC__ >= 13 || (!defined(__cplusplus))) 33 | #define LIBC_TYPES_HAS_CFLOAT128 34 | typedef _Complex _Float128 cfloat128; 35 | #endif 36 | #endif 37 | 38 | #if !defined(LIBC_TYPES_HAS_CFLOAT128) && (LDBL_MANT_DIG == 113) 39 | #define LIBC_TYPES_HAS_CFLOAT128 40 | #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE 41 | typedef _Complex long double cfloat128; 42 | #endif 43 | 44 | #endif // LLVM_LIBC_TYPES_CFLOAT128_H 45 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_convertible.h: -------------------------------------------------------------------------------- 1 | //===-- is_convertible type_traits ------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H 10 | 11 | #include "src/__support/CPP/type_traits/is_void.h" 12 | #include "src/__support/CPP/utility/declval.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | 16 | namespace LIBC_NAMESPACE_DECL { 17 | namespace cpp { 18 | 19 | // is_convertible 20 | namespace detail { 21 | template 22 | auto test_returnable(int) 23 | -> decltype(void(static_cast(nullptr)), cpp::true_type{}); 24 | template auto test_returnable(...) -> cpp::false_type; 25 | 26 | template 27 | auto test_implicitly_convertible(int) 28 | -> decltype(void(cpp::declval()(cpp::declval())), 29 | cpp::true_type{}); 30 | template 31 | auto test_implicitly_convertible(...) -> cpp::false_type; 32 | } // namespace detail 33 | 34 | template 35 | struct is_convertible 36 | : cpp::bool_constant< 37 | (decltype(detail::test_returnable(0))::value && 38 | decltype(detail::test_implicitly_convertible(0))::value) || 39 | (cpp::is_void_v && cpp::is_void_v)> {}; 40 | 41 | template 42 | LIBC_INLINE_VAR constexpr bool is_convertible_v = 43 | is_convertible::value; 44 | 45 | } // namespace cpp 46 | } // namespace LIBC_NAMESPACE_DECL 47 | 48 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H 49 | -------------------------------------------------------------------------------- /toolchain/args/macos/BUILD.bazel: -------------------------------------------------------------------------------- 1 | 2 | load("@rules_cc//cc/toolchains:args.bzl", "cc_args") 3 | load("@rules_cc//cc/toolchains/args:sysroot.bzl", "cc_sysroot") 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | cc_sysroot( 8 | name = "macos_sdk_sysroot", 9 | sysroot = "@macosx15.4.sdk//:sysroot-minimal", 10 | data = [ 11 | "@macosx15.4.sdk//:sysroot-minimal", 12 | ], 13 | ) 14 | 15 | cc_args( 16 | name = "macos_minimum_os_flags", 17 | actions = [ 18 | "@rules_cc//cc/toolchains/actions:compile_actions", 19 | "@rules_cc//cc/toolchains/actions:link_actions", 20 | ], 21 | args = [ 22 | #TODO: This should be configurable or retrieved from the apple fragment 23 | "-mmacosx-version-min=14.0", 24 | ], 25 | ) 26 | 27 | cc_args( 28 | name = "macos_default_link_flags", 29 | actions = [ 30 | "@rules_cc//cc/toolchains/actions:link_actions", 31 | ], 32 | args = [ 33 | "-headerpad_max_install_names", 34 | "-Wl,-no_warn_duplicate_libraries", 35 | "-Wl,-oso_prefix,.", # Strip absolute paths from debug info file references 36 | ], 37 | env = { 38 | # Required for hermetic links on macOS 39 | "ZERO_AR_DATE": "1", 40 | }, 41 | ) 42 | 43 | cc_args( 44 | name = "macos_default_libs", 45 | actions = [ 46 | "@rules_cc//cc/toolchains/actions:link_actions", 47 | ], 48 | # -l: is not supported by lld64 49 | args = [ 50 | # provides a stub for -lunwind on macOS 51 | "-L{libunwind_library_search_path}", 52 | 53 | "{libclang_rt.builtins.a}", 54 | "-lSystem", 55 | ], 56 | format = { 57 | "libclang_rt.builtins.a": "//runtimes/compiler-rt:clang_rt.builtins.static", 58 | "libunwind_library_search_path": "//runtimes/libunwind:libunwind_library_search_directory", 59 | }, 60 | data = [ 61 | "//runtimes/compiler-rt:clang_rt.builtins.static", 62 | "//runtimes/libunwind:libunwind_library_search_directory", 63 | ], 64 | ) 65 | 66 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_base_of.h: -------------------------------------------------------------------------------- 1 | //===-- is_base_of type_traits ----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H 10 | 11 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" 12 | #include "src/__support/CPP/type_traits/false_type.h" 13 | #include "src/__support/CPP/type_traits/is_class.h" 14 | #include "src/__support/CPP/type_traits/remove_all_extents.h" 15 | #include "src/__support/CPP/type_traits/true_type.h" 16 | #include "src/__support/macros/attributes.h" 17 | #include "src/__support/macros/config.h" 18 | 19 | namespace LIBC_NAMESPACE_DECL { 20 | namespace cpp { 21 | 22 | // is_base_of 23 | namespace detail { 24 | template cpp::true_type __test_ptr_conv(const volatile B *); 25 | template cpp::false_type __test_ptr_conv(const volatile void *); 26 | 27 | template 28 | auto is_base_of(int) -> decltype(__test_ptr_conv(static_cast(nullptr))); 29 | 30 | template 31 | auto is_base_of(...) -> cpp::true_type; // private or ambiguous base 32 | 33 | } // namespace detail 34 | 35 | template 36 | struct is_base_of 37 | : cpp::bool_constant< 38 | cpp::is_class_v && 39 | cpp::is_class_v &&decltype(detail::is_base_of( 40 | 0))::value> {}; 41 | template 42 | LIBC_INLINE_VAR constexpr bool is_base_of_v = is_base_of::value; 43 | 44 | } // namespace cpp 45 | } // namespace LIBC_NAMESPACE_DECL 46 | 47 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H 48 | -------------------------------------------------------------------------------- /http_pkg_archive.bzl: -------------------------------------------------------------------------------- 1 | load( 2 | "@bazel_tools//tools/build_defs/repo:utils.bzl", 3 | "get_auth", 4 | "patch", 5 | "workspace_and_buildfile", 6 | ) 7 | 8 | def _http_pkg_archive_impl(rctx): 9 | if rctx.attr.build_file and rctx.attr.build_file_content: 10 | fail("Only one of build_file and build_file_content can be provided.") 11 | rctx.download( 12 | url = rctx.attr.urls, 13 | output = ".downloaded.pkg", 14 | sha256 = rctx.attr.sha256, 15 | canonical_id = " ".join(rctx.attr.urls), 16 | auth = get_auth(rctx, rctx.attr.urls), 17 | ) 18 | 19 | res = rctx.execute(["/usr/sbin/pkgutil", "--expand-full", ".downloaded.pkg", "tmp"]) 20 | if res.return_code != 0: 21 | fail("Failed to extract package: {}".format(res.stdout)) 22 | rctx.delete(".downloaded.pkg") 23 | 24 | if rctx.attr.strip_files: 25 | for file in rctx.attr.strip_files: 26 | rctx.delete("tmp/Payload/" + file) 27 | 28 | strip_prefix = "tmp/Payload/" 29 | if rctx.attr.strip_prefix: 30 | strip_prefix += rctx.attr.strip_prefix + "/" 31 | extracted = rctx.path(strip_prefix) 32 | if not extracted.is_dir or not extracted.exists: 33 | fail("Extracted package does not contain expected directory: {}".format(strip_prefix)) 34 | entries = extracted.readdir(watch = "no") 35 | for entry in entries: 36 | rctx.execute(["mv", str(entry), entry.basename]) 37 | rctx.delete(extracted) 38 | workspace_and_buildfile(rctx) 39 | patch(rctx) 40 | 41 | http_pkg_archive = repository_rule( 42 | _http_pkg_archive_impl, 43 | attrs = { 44 | "urls": attr.string_list(mandatory = True), 45 | "sha256": attr.string(mandatory = True), 46 | "strip_prefix": attr.string(), 47 | "strip_files": attr.string_list(), 48 | "build_file": attr.label(allow_single_file = True), 49 | "build_file_content": attr.string(), 50 | "workspace_file": attr.label(allow_single_file = True), 51 | "workspace_file_content": attr.string(), 52 | }, 53 | ) 54 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/compiler-rt/filter_builtin_sources.bzl: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Utilities used by compiler-rt BUILD rules. 4 | 5 | `filter_builtin_sources` is a rule similar to filegroup, but it also ensures 6 | that only the last occurrence of each basename is kept. This makes it possible 7 | to list architecture specific builtins after the generic ones without pulling 8 | both into the build. The rule also filters out the entries listed in 9 | `lib/builtins/Darwin-excludes.txt` when building for macOS so that we match the 10 | upstream Darwin build. 11 | """ 12 | 13 | # TODO: Generate this list from lib/builtins/Darwin-excludes.txt. 14 | _MACOS_EXCLUDE_LIST = [ 15 | "apple_versioning", 16 | "addtf3", 17 | "divtf3", 18 | "multf3", 19 | "powitf2", 20 | "subtf3", 21 | "trampoline_setup", 22 | ] 23 | 24 | def _filter_builtin_sources_impl(ctx): 25 | is_macos = ctx.target_platform_has_constraint( 26 | ctx.attr._macos_constraint[platform_common.ConstraintValueInfo] 27 | ) 28 | 29 | basename_to_file = {} 30 | for f in ctx.files.srcs: 31 | excluded = False 32 | 33 | if is_macos: 34 | for e in _MACOS_EXCLUDE_LIST: 35 | if e in f.path: 36 | excluded = True 37 | break 38 | 39 | if not excluded: 40 | basename_to_file[f.basename] = f 41 | 42 | # Only keep the last occurrence for each basename 43 | unique_files = list(basename_to_file.values()) 44 | 45 | return [ 46 | DefaultInfo( 47 | files = depset(unique_files), 48 | ) 49 | ] 50 | 51 | filter_builtin_sources = rule( 52 | implementation = _filter_builtin_sources_impl, 53 | attrs = { 54 | "srcs": attr.label_list(allow_files = True), 55 | "_macos_constraint": attr.label( 56 | default = Label("@platforms//os:macos"), 57 | providers = [platform_common.ConstraintValueInfo], 58 | ), 59 | }, 60 | doc = "Like filegroup, but filters OSX sources and removes duplicate basenames, keeping only the last one.", 61 | ) 62 | -------------------------------------------------------------------------------- /toolchain/features/legacy/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc/toolchains:args.bzl", "cc_args") 2 | load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") 3 | load("@rules_cc//cc/toolchains:feature_set.bzl", "cc_feature_set") 4 | 5 | cc_args( 6 | name = "legacy_default_cxx_compile_flags", 7 | actions = [ 8 | "@rules_cc//cc/toolchains/actions:cpp_compile_actions", 9 | ], 10 | args = [ 11 | "-std=c++17", 12 | ], 13 | ) 14 | 15 | cc_args( 16 | name = "legacy_default_compile_flags", 17 | actions = [ 18 | "@rules_cc//cc/toolchains/actions:compile_actions", 19 | ], 20 | args = [ 21 | "-fstack-protector", 22 | # All warnings are enabled. 23 | "-Wall", 24 | # Enable a few more warnings that aren't part of -Wall. 25 | "-Wthread-safety", 26 | "-Wself-assign", 27 | # Disable problematic warnings. 28 | "-Wunused-but-set-parameter", 29 | # has false positives 30 | "-Wno-free-nonheap-object", 31 | # Enable coloring even if there's no attached terminal. Bazel removes the 32 | # escape sequences if --nocolor is specified. 33 | "-fcolor-diagnostics", 34 | # Keep stack frames for debugging, even in opt mode. 35 | "-fno-omit-frame-pointer", 36 | ], 37 | ) 38 | 39 | cc_feature( 40 | name = "default_compile_flags", 41 | overrides = "@rules_cc//cc/toolchains/features/legacy:default_compile_flags", 42 | args = [ 43 | ":legacy_default_cxx_compile_flags", 44 | ":legacy_default_compile_flags", 45 | ], 46 | ) 47 | 48 | cc_feature( 49 | name = "supports_start_end_lib", 50 | feature_name = "supports_start_end_lib", 51 | visibility = ["//visibility:public"], 52 | ) 53 | 54 | ### 55 | 56 | cc_feature_set( 57 | name = "all_legacy_builtin_features", 58 | all_of = [ 59 | ":default_compile_flags", 60 | ] + select({ 61 | "@platforms//os:windows": [], 62 | "//conditions:default": [ 63 | ":supports_start_end_lib", 64 | ], 65 | }), 66 | visibility = ["//visibility:public"], 67 | ) 68 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_complex.h: -------------------------------------------------------------------------------- 1 | //===-- is_complex type_traits ----------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H 10 | 11 | #include "src/__support/CPP/type_traits/is_same.h" 12 | #include "src/__support/CPP/type_traits/remove_cv.h" 13 | #include "src/__support/macros/attributes.h" 14 | #include "src/__support/macros/config.h" 15 | // LIBC_TYPES_HAS_CFLOAT16 && LIBC_TYPES_HAS_CFLOAT128 16 | #include "src/__support/macros/properties/complex_types.h" 17 | 18 | namespace LIBC_NAMESPACE_DECL { 19 | namespace cpp { 20 | 21 | // is_complex 22 | template struct is_complex { 23 | private: 24 | template 25 | LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { 26 | return (... || is_same_v, Args>); 27 | } 28 | 29 | public: 30 | LIBC_INLINE_VAR static constexpr bool value = 31 | __is_unqualified_any_of(); 42 | }; 43 | template 44 | LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex::value; 45 | template 46 | LIBC_INLINE_VAR constexpr bool is_complex_type_same() { 47 | return is_same_v, T2>; 48 | } 49 | 50 | } // namespace cpp 51 | } // namespace LIBC_NAMESPACE_DECL 52 | 53 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H 54 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/make_signed.h: -------------------------------------------------------------------------------- 1 | //===-- make_signed type_traits ---------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H 10 | 11 | #include "src/__support/CPP/type_traits/type_identity.h" 12 | #include "src/__support/macros/config.h" 13 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 14 | 15 | namespace LIBC_NAMESPACE_DECL { 16 | namespace cpp { 17 | 18 | // make_signed 19 | template struct make_signed; 20 | template <> struct make_signed : type_identity {}; 21 | template <> struct make_signed : type_identity {}; 22 | template <> struct make_signed : type_identity {}; 23 | template <> struct make_signed : type_identity {}; 24 | template <> struct make_signed : type_identity {}; 25 | template <> struct make_signed : type_identity {}; 26 | template <> struct make_signed : type_identity {}; 27 | template <> struct make_signed : type_identity {}; 28 | template <> struct make_signed : type_identity {}; 29 | template <> struct make_signed : type_identity {}; 30 | template <> 31 | struct make_signed : type_identity {}; 32 | #ifdef LIBC_TYPES_HAS_INT128 33 | template <> struct make_signed<__int128_t> : type_identity<__int128_t> {}; 34 | template <> struct make_signed<__uint128_t> : type_identity<__int128_t> {}; 35 | #endif 36 | template using make_signed_t = typename make_signed::type; 37 | 38 | } // namespace cpp 39 | } // namespace LIBC_NAMESPACE_DECL 40 | 41 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H 42 | -------------------------------------------------------------------------------- /defs.bzl: -------------------------------------------------------------------------------- 1 | def exec_test(rule, name, tags=[], args=[], env={}, data = [], tools = [], **kwargs): 2 | rule( 3 | name = name + "_", 4 | tags = tags + (["manual"] if "manual" not in tags else []), 5 | data = data, 6 | **kwargs 7 | ) 8 | 9 | _exec_test( 10 | name = name, 11 | inner = name + "_", 12 | tags = tags, 13 | args = args, 14 | env = env, 15 | data = data, 16 | tools = tools, 17 | ) 18 | 19 | def _exec_test_impl(ctx): 20 | inner = ctx.attr.inner[DefaultInfo] 21 | out = ctx.outputs.executable 22 | 23 | ctx.actions.symlink( 24 | target_file = inner.files_to_run.executable, 25 | output = out, 26 | ) 27 | 28 | runfiles = ctx.runfiles(ctx.files.data + ctx.files.tools) 29 | 30 | data = ctx.attr.data + ctx.attr.tools 31 | 32 | return [ 33 | DefaultInfo( 34 | files = depset([out]), 35 | executable = out, 36 | runfiles = runfiles.merge(inner.default_runfiles), 37 | ), 38 | RunEnvironmentInfo( 39 | environment = { 40 | k: ctx.expand_location(v, data) 41 | for k, v in ctx.attr.env.items() 42 | }, 43 | ), 44 | ] 45 | 46 | _exec_test = rule( 47 | implementation = _exec_test_impl, 48 | attrs = { 49 | "inner": attr.label( 50 | executable = True, 51 | cfg = "exec", 52 | mandatory = True, 53 | ), 54 | "data": attr.label_list( 55 | doc = "The service manager will merge these variables into the environment when spawning the underlying binary.", 56 | allow_files = True, 57 | ), 58 | "tools": attr.label_list( 59 | doc = "The service manager will merge these variables into the environment when spawning the underlying binary.", 60 | cfg = "exec", 61 | allow_files = True, 62 | ), 63 | "env": attr.string_dict( 64 | doc = "The service manager will merge these variables into the environment when spawning the underlying binary.", 65 | ), 66 | }, 67 | test = True, 68 | ) 69 | -------------------------------------------------------------------------------- /third_party/llvm-project/llvm-extra.patch: -------------------------------------------------------------------------------- 1 | diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 2 | index a17b0b54a49b..12aa69678e2c 100644 3 | --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 4 | +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 5 | @@ -1900,6 +1900,11 @@ genrule( 6 | toolchains = [":workspace_root"], 7 | ) 8 | 9 | +filegroup( 10 | + name = "builtin_headers_files", 11 | + srcs = builtin_headers, 12 | +) 13 | + 14 | cc_library( 15 | name = "frontend", 16 | srcs = glob([ 17 | diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl 18 | index 2309175d04a9..4b3c6b2791db 100644 19 | --- a/utils/bazel/llvm-project-overlay/llvm/config.bzl 20 | +++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl 21 | @@ -28,8 +28,8 @@ def native_arch_defines(arch, triple): 22 | 23 | posix_defines = [ 24 | "LLVM_ON_UNIX=1", 25 | - "HAVE_BACKTRACE=1", 26 | - "BACKTRACE_HEADER=", 27 | + # "HAVE_BACKTRACE=1", 28 | + # "BACKTRACE_HEADER=", 29 | r'LTDL_SHLIB_EXT=\".so\"', 30 | r'LLVM_PLUGIN_EXT=\".so\"', 31 | "LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS=1", 32 | @@ -51,7 +51,7 @@ posix_defines = [ 33 | linux_defines = posix_defines + [ 34 | "_GNU_SOURCE", 35 | "HAVE_GETAUXVAL=1", 36 | - "HAVE_MALLINFO=1", 37 | + # "HAVE_MALLINFO=1", 38 | "HAVE_SBRK=1", 39 | "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=1", 40 | ] 41 | diff --git a/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl b/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl 42 | index e45ba1fe0ef7..5af5db59c608 100644 43 | --- a/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl 44 | +++ b/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl 45 | @@ -172,7 +172,7 @@ def _gentbl_rule_impl(ctx): 46 | # Make sure action_env settings are honored so the env is the same as 47 | # when the tool was built. Important for locating shared libraries with 48 | # a custom LD_LIBRARY_PATH. 49 | - use_default_shell_env = True, 50 | + # use_default_shell_env = True, 51 | mnemonic = "TdGenerate", 52 | ) 53 | 54 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/CPP/type_traits/is_fixed_point.h: -------------------------------------------------------------------------------- 1 | //===-- is_fixed_point type_traits ------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H 10 | 11 | #include "src/__support/CPP/type_traits/is_same.h" 12 | #include "src/__support/CPP/type_traits/remove_cv.h" 13 | #include "src/__support/macros/attributes.h" 14 | 15 | #include "include/llvm-libc-macros/stdfix-macros.h" 16 | #include "src/__support/macros/config.h" 17 | 18 | namespace LIBC_NAMESPACE_DECL { 19 | namespace cpp { 20 | 21 | // is_fixed_point 22 | #ifdef LIBC_COMPILER_HAS_FIXED_POINT 23 | template struct is_fixed_point { 24 | private: 25 | template 26 | LIBC_INLINE static constexpr bool __is_unqualified_any_of() { 27 | return (... || is_same_v, Args>); 28 | } 29 | 30 | public: 31 | LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of< 32 | T, short fract, fract, long fract, unsigned short fract, unsigned fract, 33 | unsigned long fract, short accum, accum, long accum, unsigned short accum, 34 | unsigned accum, unsigned long accum, short sat fract, sat fract, 35 | long sat fract, unsigned short sat fract, unsigned sat fract, 36 | unsigned long sat fract, short sat accum, sat accum, long sat accum, 37 | unsigned short sat accum, unsigned sat accum, unsigned long sat accum>(); 38 | }; 39 | #else 40 | template struct is_fixed_point : false_type {}; 41 | #endif // LIBC_COMPILER_HAS_FIXED_POINT 42 | 43 | template 44 | LIBC_INLINE_VAR constexpr bool is_fixed_point_v = is_fixed_point::value; 45 | 46 | } // namespace cpp 47 | } // namespace LIBC_NAMESPACE_DECL 48 | 49 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H 50 | -------------------------------------------------------------------------------- /third_party/libc/glibc/stdlib/at_quick_exit.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1991-2021 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | In addition to the permissions in the GNU Lesser General Public 10 | License, the Free Software Foundation gives you unlimited 11 | permission to link the compiled version of this file with other 12 | programs, and to distribute those programs without any restriction 13 | coming from the use of this file. (The GNU Lesser General Public 14 | License restrictions do apply in other respects; for example, they 15 | cover modification of the file, and distribution when not linked 16 | into another program.) 17 | 18 | Note that people who make modified versions of this file are not 19 | obligated to grant this special exception for their modified 20 | versions; it is their choice whether to do so. The GNU Lesser 21 | General Public License gives permission to release a modified 22 | version without this exception; this exception also makes it 23 | possible to release a modified version which carries forward this 24 | exception. 25 | 26 | The GNU C Library is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | Lesser General Public License for more details. 30 | 31 | You should have received a copy of the GNU Lesser General Public 32 | License along with the GNU C Library; if not, see 33 | . */ 34 | 35 | extern void *__dso_handle __attribute__ ((__visibility__ ("hidden"))); 36 | extern int __cxa_at_quick_exit (void (*func) (void *), void *d); 37 | 38 | /* Register FUNC to be executed by `quick_exit'. */ 39 | int 40 | __attribute__ ((__visibility__ ("hidden"))) 41 | at_quick_exit (void (*func) (void)) 42 | { 43 | return __cxa_at_quick_exit ((void (*) (void *)) func, __dso_handle); 44 | } 45 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/str_to_num_result.h: -------------------------------------------------------------------------------- 1 | //===-- A data structure for str_to_number to return ------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | // ----------------------------------------------------------------------------- 10 | // **** WARNING **** 11 | // This file is shared with libc++. You should also be careful when adding 12 | // dependencies to this file, since it needs to build for all libc++ targets. 13 | // ----------------------------------------------------------------------------- 14 | 15 | #ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H 16 | #define LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H 17 | 18 | #include "src/__support/macros/attributes.h" // LIBC_INLINE 19 | #include "src/__support/macros/config.h" 20 | 21 | #include 22 | 23 | namespace LIBC_NAMESPACE_DECL { 24 | 25 | // ----------------------------------------------------------------------------- 26 | // **** WARNING **** 27 | // This interface is shared with libc++, if you change this interface you need 28 | // to update it in both libc and libc++. 29 | // ----------------------------------------------------------------------------- 30 | template struct StrToNumResult { 31 | T value; 32 | int error; 33 | ptrdiff_t parsed_len; 34 | 35 | LIBC_INLINE constexpr StrToNumResult(T value) 36 | : value(value), error(0), parsed_len(0) {} 37 | LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len) 38 | : value(value), error(0), parsed_len(parsed_len) {} 39 | LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len, int error) 40 | : value(value), error(error), parsed_len(parsed_len) {} 41 | 42 | LIBC_INLINE constexpr bool has_error() { return error != 0; } 43 | 44 | LIBC_INLINE constexpr operator T() { return value; } 45 | }; 46 | } // namespace LIBC_NAMESPACE_DECL 47 | 48 | #endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H 49 | -------------------------------------------------------------------------------- /toolchain/args/windows/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc/toolchains:args.bzl", "cc_args") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_args( 6 | name = "mingw_headers_include_search_paths", 7 | actions = [ 8 | "@rules_cc//cc/toolchains/actions:compile_actions", 9 | ], 10 | args = [ 11 | "-isystem", 12 | "{mingw_generated_headers_crt}", 13 | "-isystem", 14 | "{mingw_w64_headers_include}", 15 | "-isystem", 16 | "{mingw_w64_headers_crt}", 17 | ], 18 | format = { 19 | "mingw_generated_headers_crt": "@mingw//:mingw_generated_headers_crt_directory", 20 | "mingw_w64_headers_include": "@mingw//:mingw_w64_headers_include_directory", 21 | "mingw_w64_headers_crt": "@mingw//:mingw_w64_headers_crt_directory", 22 | }, 23 | allowlist_include_directories = [ 24 | "@mingw//:mingw_generated_headers_crt_directory", 25 | "@mingw//:mingw_w64_headers_include_directory", 26 | "@mingw//:mingw_w64_headers_crt_directory", 27 | ], 28 | data = [ 29 | "@mingw//:mingw_generated_headers_crt_directory", 30 | "@mingw//:mingw_w64_headers_include_directory", 31 | "@mingw//:mingw_w64_headers_crt_directory", 32 | ], 33 | ) 34 | 35 | cc_args( 36 | name = "default_libs", 37 | actions = [ 38 | "@rules_cc//cc/toolchains/actions:link_actions", 39 | ], 40 | args = [ 41 | "-L{mingw_import_library_search_path}", 42 | "-L{mingw_crt_library_search_path}", 43 | 44 | "-nostdlib++", 45 | 46 | # Clang will respect the user's chosen crt variant. 47 | # It defaults on -lmsvcrt if it doesn't find any -l option 48 | # For now, we force on ucrt. 49 | # TODO(cerisier): make this either a constraint or a build setting 50 | "-lucrt", 51 | ], 52 | format = { 53 | "mingw_crt_library_search_path": "//runtimes/mingw:mingw_crt_library_search_directory", 54 | "mingw_import_library_search_path": "@mingw//:mingw_import_libraries_directory", 55 | }, 56 | data = [ 57 | "//runtimes/mingw:mingw_crt_library_search_directory", 58 | "@mingw//:mingw_import_libraries_directory", 59 | ], 60 | ) 61 | -------------------------------------------------------------------------------- /third_party/llvm-project/20.x/libc/src/__support/macros/config.h: -------------------------------------------------------------------------------- 1 | //===-- Portable attributes -------------------------------------*- C++ -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // This header file defines a set of macros for checking the presence of 9 | // important compiler and platform features. Such macros can be used to 10 | // produce portable code by parameterizing compilation based on the presence or 11 | // lack of a given feature. 12 | 13 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H 14 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H 15 | 16 | // Workaround for compilers that do not support builtin detection. 17 | // FIXME: This is only required for the GPU portion which should be moved. 18 | #ifndef __has_builtin 19 | #define __has_builtin(b) 0 20 | #endif 21 | 22 | // Compiler feature-detection. 23 | // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension 24 | #ifdef __has_feature 25 | #define LIBC_HAS_FEATURE(f) __has_feature(f) 26 | #else 27 | #define LIBC_HAS_FEATURE(f) 0 28 | #endif 29 | 30 | #ifdef __clang__ 31 | // Declare a LIBC_NAMESPACE with hidden visibility. `namespace 32 | // LIBC_NAMESPACE_DECL {` should be used around all declarations and definitions 33 | // for libc internals as opposed to just `namespace LIBC_NAMESPACE {`. This 34 | // ensures that all declarations within this namespace have hidden 35 | // visibility, which optimizes codegen for uses of symbols defined in other 36 | // translation units in ways that can be necessary for correctness by avoiding 37 | // dynamic relocations. This does not affect the public C symbols which are 38 | // controlled independently via `LLVM_LIBC_FUNCTION_ATTR`. 39 | #define LIBC_NAMESPACE_DECL [[gnu::visibility("hidden")]] LIBC_NAMESPACE 40 | #else 41 | // TODO(#98548): GCC emits a warning when using the visibility attribute which 42 | // needs to be diagnosed and addressed. 43 | #define LIBC_NAMESPACE_DECL LIBC_NAMESPACE 44 | #endif 45 | 46 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H 47 | -------------------------------------------------------------------------------- /third_party/libc/glibc/stdlib/atexit.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1991-2021 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | In addition to the permissions in the GNU Lesser General Public 10 | License, the Free Software Foundation gives you unlimited 11 | permission to link the compiled version of this file with other 12 | programs, and to distribute those programs without any restriction 13 | coming from the use of this file. (The GNU Lesser General Public 14 | License restrictions do apply in other respects; for example, they 15 | cover modification of the file, and distribution when not linked 16 | into another program.) 17 | 18 | Note that people who make modified versions of this file are not 19 | obligated to grant this special exception for their modified 20 | versions; it is their choice whether to do so. The GNU Lesser 21 | General Public License gives permission to release a modified 22 | version without this exception; this exception also makes it 23 | possible to release a modified version which carries forward this 24 | exception. 25 | 26 | The GNU C Library is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | Lesser General Public License for more details. 30 | 31 | You should have received a copy of the GNU Lesser General Public 32 | License along with the GNU C Library; if not, see 33 | . */ 34 | 35 | extern int __cxa_atexit (void (*func) (void *), void *arg, void *d); 36 | libc_hidden_proto (__cxa_atexit); 37 | extern void *__dso_handle __attribute__ ((__visibility__ ("hidden"))); 38 | 39 | /* Register FUNC to be executed by `exit'. */ 40 | int 41 | __attribute__ ((__visibility__ ("hidden"))) 42 | atexit (void (*func) (void)) 43 | { 44 | return __cxa_atexit ((void (*) (void *)) func, 0, __dso_handle); 45 | } 46 | --------------------------------------------------------------------------------