|
| 1 | +From 19d5d9913778ca95da272f41c5916907154a5e73 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Chandler Carruth < [email protected]> |
| 3 | +Date: Thu, 24 Apr 2025 05:03:43 +0000 |
| 4 | +Subject: [PATCH] Introduce filegroups for compiler-rt builtins runtimes |
| 5 | + |
| 6 | +These filegroups allow downstream projects to package and build |
| 7 | +customized runtime libraries. |
| 8 | + |
| 9 | +The filegroups work hard to use globs and a careful structuring to |
| 10 | +create the structured breakdown of sources needed to target different |
| 11 | +architectures and platforms without having to maintain a complete |
| 12 | +parallel list of sources from CMake. |
| 13 | +--- |
| 14 | + .../compiler-rt/BUILD.bazel | 167 ++++++++++++++++++ |
| 15 | + 1 file changed, 167 insertions(+) |
| 16 | + |
| 17 | +diff --git a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel b/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel |
| 18 | +index 6a5a89fdee40..7d158f0c13f2 100644 |
| 19 | +--- a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel |
| 20 | ++++ b/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel |
| 21 | +@@ -128,3 +128,170 @@ cc_library( |
| 22 | + ], |
| 23 | + includes = ["lib/fuzzer"], |
| 24 | + ) |
| 25 | ++ |
| 26 | ++BUILTINS_CRTBEGIN_SRCS = ["lib/builtins/crtbegin.c"] |
| 27 | ++ |
| 28 | ++filegroup( |
| 29 | ++ name = "builtins_crtbegin_src", |
| 30 | ++ srcs = BUILTINS_CRTBEGIN_SRCS, |
| 31 | ++) |
| 32 | ++ |
| 33 | ++BUILTINS_CRTEND_SRCS = ["lib/builtins/crtend.c"] |
| 34 | ++ |
| 35 | ++filegroup( |
| 36 | ++ name = "builtins_crtend_src", |
| 37 | ++ srcs = BUILTINS_CRTEND_SRCS, |
| 38 | ++) |
| 39 | ++ |
| 40 | ++# Note that while LLVM's CompilerRT provides a few hosted sources, we don't |
| 41 | ++# currently build them: |
| 42 | ++# |
| 43 | ++# - `emutls.c`: Unclear we need to support targets with software emulated |
| 44 | ++# TLS rather than hardware support. |
| 45 | ++# - `enable_execute_stack.c`: Used to implement support for a builtin that |
| 46 | ++# marks part of the stack as *executable* to support the GCC extension of |
| 47 | ++# nested functions. This extension was never implemented in Clang, and is |
| 48 | ++# generally considered a security issue to include. We expect to be able |
| 49 | ++# to avoid even linking the support code for this into binaries at this |
| 50 | ++# point. |
| 51 | ++# - `eprintf.c`: This provided a legacy `__eprintf` builtin used by old |
| 52 | ++# versions of `assert.h` in its macros, but does not appear to be needed |
| 53 | ++# when building with modern versions of this header. |
| 54 | ++BUILTINS_HOSTED_SRCS = [ |
| 55 | ++ "lib/builtins/emutls.c", |
| 56 | ++ "lib/builtins/enable_execute_stack.c", |
| 57 | ++ "lib/builtins/eprintf.c", |
| 58 | ++] |
| 59 | ++ |
| 60 | ++filegroup( |
| 61 | ++ name = "builtins_hosted_srcs", |
| 62 | ++ srcs = BUILTINS_HOSTED_SRCS, |
| 63 | ++) |
| 64 | ++ |
| 65 | ++BUILTINS_BF16_SRCS_PATTERNS = [ |
| 66 | ++ # `bf` marks 16-bit Brain floating-point number builtins. |
| 67 | ++ "lib/builtins/*bf*.c", |
| 68 | ++] |
| 69 | ++ |
| 70 | ++filegroup( |
| 71 | ++ name = "builtins_bf16_srcs", |
| 72 | ++ srcs = glob(BUILTINS_BF16_SRCS_PATTERNS), |
| 73 | ++) |
| 74 | ++ |
| 75 | ++BUILTINS_X86_FP80_SRCS_PATTERNS = [ |
| 76 | ++ # `xc` marks 80-bit complex number builtins. |
| 77 | ++ "lib/builtins/*xc*.c", |
| 78 | ++ |
| 79 | ++ # `xf` marks 80-bit floating-point builtins. |
| 80 | ++ "lib/builtins/*xf*.c", |
| 81 | ++] |
| 82 | ++ |
| 83 | ++filegroup( |
| 84 | ++ name = "builtins_x86_fp80_srcs", |
| 85 | ++ srcs = glob( |
| 86 | ++ BUILTINS_X86_FP80_SRCS_PATTERNS, |
| 87 | ++ exclude = BUILTINS_BF16_SRCS_PATTERNS, |
| 88 | ++ ), |
| 89 | ++) |
| 90 | ++ |
| 91 | ++BUILTINS_TF_SRCS_PATTERNS = [ |
| 92 | ++ # `tc` marks 128-bit complex number builtins. |
| 93 | ++ "lib/builtins/*tc*.c", |
| 94 | ++ |
| 95 | ++ # `tf` marks 128-bit floating-point builtins. |
| 96 | ++ "lib/builtins/*tf*.c", |
| 97 | ++] |
| 98 | ++ |
| 99 | ++BUILTINS_TF_EXCLUDES = ( |
| 100 | ++ BUILTINS_HOSTED_SRCS + |
| 101 | ++ BUILTINS_BF16_SRCS_PATTERNS + |
| 102 | ++ BUILTINS_X86_FP80_SRCS_PATTERNS |
| 103 | ++) |
| 104 | ++ |
| 105 | ++filegroup( |
| 106 | ++ name = "builtins_tf_srcs", |
| 107 | ++ srcs = glob( |
| 108 | ++ BUILTINS_TF_SRCS_PATTERNS, |
| 109 | ++ exclude = BUILTINS_TF_EXCLUDES, |
| 110 | ++ ), |
| 111 | ++) |
| 112 | ++ |
| 113 | ++BUILTINS_MACOS_ATOMIC_SRCS_PATTERNS = [ |
| 114 | ++ "lib/builtins/atomic_*.c", |
| 115 | ++] |
| 116 | ++ |
| 117 | ++filegroup( |
| 118 | ++ name = "builtins_macos_atomic_srcs", |
| 119 | ++ srcs = glob(BUILTINS_MACOS_ATOMIC_SRCS_PATTERNS), |
| 120 | ++) |
| 121 | ++ |
| 122 | ++filegroup( |
| 123 | ++ name = "builtins_aarch64_srcs", |
| 124 | ++ srcs = [ |
| 125 | ++ "lib/builtins/cpu_model/aarch64.c", |
| 126 | ++ "lib/builtins/cpu_model/aarch64.h", |
| 127 | ++ ] + glob( |
| 128 | ++ [ |
| 129 | ++ "lib/builtins/cpu_model/AArch64*.inc", |
| 130 | ++ "lib/builtins/cpu_model/aarch64/**/*.inc", |
| 131 | ++ "lib/builtins/aarch64/*.S", |
| 132 | ++ "lib/builtins/aarch64/*.c", |
| 133 | ++ ], |
| 134 | ++ exclude = [ |
| 135 | ++ # This file isn't intended to directly compile, but to be used to |
| 136 | ++ # generate a collection of outline atomic helpers. |
| 137 | ++ # TODO: Add support for generating the sources for these helpers if |
| 138 | ++ # there are users that need this functionality from the builtins |
| 139 | ++ # library. |
| 140 | ++ "lib/builtins/aarch64/lse.S", |
| 141 | ++ ], |
| 142 | ++ ), |
| 143 | ++) |
| 144 | ++ |
| 145 | ++filegroup( |
| 146 | ++ name = "builtins_x86_arch_srcs", |
| 147 | ++ srcs = [ |
| 148 | ++ "lib/builtins/cpu_model/x86.c", |
| 149 | ++ "lib/builtins/i386/fp_mode.c", |
| 150 | ++ ], |
| 151 | ++) |
| 152 | ++ |
| 153 | ++filegroup( |
| 154 | ++ name = "builtins_x86_64_srcs", |
| 155 | ++ srcs = glob([ |
| 156 | ++ "lib/builtins/x86_64/*.c", |
| 157 | ++ "lib/builtins/x86_64/*.S", |
| 158 | ++ ]), |
| 159 | ++) |
| 160 | ++ |
| 161 | ++filegroup( |
| 162 | ++ name = "builtins_i386_srcs", |
| 163 | ++ srcs = glob( |
| 164 | ++ [ |
| 165 | ++ "lib/builtins/i386/*.c", |
| 166 | ++ "lib/builtins/i386/*.S", |
| 167 | ++ ], |
| 168 | ++ exclude = [ |
| 169 | ++ # This file is used for both i386 and x86_64. |
| 170 | ++ "lib/builtins/i386/fp_mode.c", |
| 171 | ++ ], |
| 172 | ++ ), |
| 173 | ++) |
| 174 | ++ |
| 175 | ++filegroup( |
| 176 | ++ name = "builtins_generic_srcs", |
| 177 | ++ srcs = ["lib/builtins/cpu_model/cpu_model.h"] + glob( |
| 178 | ++ [ |
| 179 | ++ "lib/builtins/*.c", |
| 180 | ++ "lib/builtins/*.h", |
| 181 | ++ "lib/builtins/*.inc", |
| 182 | ++ ], |
| 183 | ++ exclude = ( |
| 184 | ++ BUILTINS_CRTBEGIN_SRCS + |
| 185 | ++ BUILTINS_CRTEND_SRCS + |
| 186 | ++ BUILTINS_TF_EXCLUDES + |
| 187 | ++ BUILTINS_TF_SRCS_PATTERNS + |
| 188 | ++ BUILTINS_MACOS_ATOMIC_SRCS_PATTERNS |
| 189 | ++ ), |
| 190 | ++ ), |
| 191 | ++) |
| 192 | +-- |
| 193 | +2.49.0.850.g28803427d3-goog |
| 194 | + |
0 commit comments