1load( 2 "@nix_config//:config.bzl", 3 "CLANG", 4 "CLANG_LIB", 5 "CLANG_LIB_VERSION", 6 "LLVM", 7 "SDK_UNIVERSAL_APPLE_DARWIN", 8) 9load("@rules_cc//cc:defs.bzl", "cc_toolchain") 10load("//bazel/toolchain_rules:llvm_cc_toolchain_config.bzl", "llvm_cc_toolchain_config") 11 12llvm_cc_toolchain_config( 13 name = "cc_toolchain_config", 14 archive_flags = [], 15 builtin_executable_objects = [], 16 builtin_framework_directories = [ 17 "{}/System/Library/Frameworks".format(SDK_UNIVERSAL_APPLE_DARWIN), 18 ], 19 builtin_frameworks = [], 20 builtin_include_directories = [ 21 "{}/usr/include/c++/v1".format(SDK_UNIVERSAL_APPLE_DARWIN), 22 "{}/lib/clang/{}/include".format(CLANG_LIB, CLANG_LIB_VERSION), 23 "{}/usr/include".format(SDK_UNIVERSAL_APPLE_DARWIN), 24 ], 25 builtin_libraries = [], 26 builtin_library_directories = [ 27 "{}/usr/lib".format(SDK_UNIVERSAL_APPLE_DARWIN), 28 ], 29 clang = CLANG, 30 compile_flags = [ 31 "-fno-exceptions", 32 "-Werror", 33 "-Wall", 34 "-Wthread-safety", 35 "-Wself-assign", 36 ], 37 dbg_compile_flags = [ 38 "-g", 39 "-fstandalone-debug", 40 ], 41 dbg_link_flags = [], 42 fastbuild_compile_flags = [], 43 fastbuild_link_flags = [], 44 link_flags = [ 45 "-fatal_warnings", 46 "-arch", 47 "arm64", 48 "-macos_version_min", 49 "13.0.0", 50 "-platform_version", 51 "macos", 52 "13.0.0", 53 "13.1", 54 "-headerpad_max_install_names", 55 "-undefined", 56 "dynamic_lookup", 57 ], 58 llvm = LLVM, 59 opt_compile_flags = [ 60 "-g0", 61 "-O2", 62 "-D_FORTIFY_SOURCE=1", 63 "-DNDEBUG", 64 "-ffunction-sections", 65 "-fdata-sections", 66 ], 67 opt_link_flags = [ 68 "--gc-sections", 69 ], 70 tags = ["manual"], 71 target = "aarch64-apple-darwin", 72) 73 74cc_toolchain( 75 name = "cc_toolchain", 76 all_files = "@nix_config//:config.bzl", 77 ar_files = "@nix_config//:config.bzl", 78 as_files = "@nix_config//:config.bzl", 79 compiler_files = "@nix_config//:config.bzl", 80 coverage_files = "@nix_config//:config.bzl", 81 dwp_files = "@nix_config//:config.bzl", 82 linker_files = "@nix_config//:config.bzl", 83 objcopy_files = "@nix_config//:config.bzl", 84 strip_files = "@nix_config//:config.bzl", 85 tags = ["manual"], 86 toolchain_config = "cc_toolchain_config", 87) 88 89toolchain( 90 name = "toolchain", 91 exec_compatible_with = [ 92 "@platforms//cpu:x86_64", 93 "@platforms//os:nixos", 94 ], 95 target_compatible_with = [ 96 "@platforms//cpu:aarch64", 97 "@platforms//os:macos", 98 ], 99 toolchain = ":cc_toolchain", 100 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", 101) 102