|
1 | | -load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") |
2 | 1 | load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template") |
3 | 2 | load("@llvm_version//:llvm_version.bzl", "LLVM_VERSION") |
4 | 3 | load("//:cmake.bzl", "cmake") |
5 | 4 | load("//:config.bzl", "LINUX_TARGETS") |
6 | 5 | load("//:host.bzl", "HOST_TARGET") |
7 | | -load("//:tar.bzl", "tar_package") |
| 6 | +load("//util:tar.bzl", "tar_package") |
8 | 7 |
|
9 | 8 | package(default_visibility = ["//visibility:public"]) |
10 | 9 |
|
@@ -46,35 +45,21 @@ package(default_visibility = ["//visibility:public"]) |
46 | 45 | working_directory = "compiler-rt", |
47 | 46 | ), |
48 | 47 |
|
49 | | - # Arrange components into a sysroot |
50 | | - copy_to_directory( |
51 | | - name = "sysroot-{}".format(target), |
52 | | - srcs = [ |
53 | | - "//gcc:{}".format(target), |
54 | | - "openmp-{}".format(target), |
55 | | - "targets/{}.cfg".format(target), |
56 | | - ], |
57 | | - exclude_srcs_patterns = [ |
| 48 | + # Package the sysroot into a tar |
| 49 | + tar_package( |
| 50 | + name = "sysroot-package-{}".format(target), |
| 51 | + srcs = { |
| 52 | + "//gcc:{}-srcs".format(target): "targets/{}/toolchain:.".format(target), # don't use copy_to_directory here, because it erases symlinks |
| 53 | + "openmp-{}".format(target): "openmp-{}:{}/sysroot/usr".format(target, target), |
| 54 | + "targets/{}.cfg".format(target): "targets:.", |
| 55 | + }, |
| 56 | + exclude = [ |
58 | 57 | "build.log.bz2", |
59 | 58 | "bin/**", |
60 | 59 | "libexec/**", |
61 | 60 | "{}/bin/**".format(target), |
62 | 61 | ], |
63 | | - replace_prefixes = { |
64 | | - "**/openmp-*": "{}/sysroot/usr".format(target), |
65 | | - }, |
66 | | - root_paths = [ |
67 | | - "gcc/{}".format(target), |
68 | | - "linux/targets", |
69 | | - ".", |
70 | | - ], |
71 | | - ), |
72 | | - |
73 | | - # Package the sysroot into a tar |
74 | | - tar_package( |
75 | | - "sysroot-package-{}".format(target), |
76 | | - "sysroot-{}".format(target), |
77 | | - "sysroot-{}".format(target), |
| 62 | + output = "sysroot-" + target, |
78 | 63 | ), |
79 | 64 |
|
80 | 65 | # toolchain.cmake files for building with the GCC and LLVM cross-compilers |
@@ -113,41 +98,26 @@ cmake( |
113 | 98 | lib_source = "@zlib", |
114 | 99 | ) |
115 | 100 |
|
116 | | -ALL_COMPILER_RT_SRCS = ["compiler-rt-{}".format(target) for target in LINUX_TARGETS] |
117 | | - |
118 | | -COMPILER_RT_PREFIX = { |
119 | | - "**/compiler-rt-*": "lib/clang/" + LLVM_VERSION.split(".")[0], |
| 101 | +COMPILER_RT_SRCS = { |
| 102 | + "compiler-rt-" + target: "compiler-rt-{}:lib/clang/{}".format( |
| 103 | + target, |
| 104 | + LLVM_VERSION.split(".")[0], |
| 105 | + ) |
| 106 | + for target in LINUX_TARGETS |
120 | 107 | } |
121 | 108 |
|
122 | | -# Add compiler-rt to LLVM installation |
123 | | -copy_to_directory( |
124 | | - name = "llvm", |
125 | | - srcs = ["//:llvm"] + ALL_COMPILER_RT_SRCS, |
126 | | - allow_overwrites = True, |
127 | | - replace_prefixes = COMPILER_RT_PREFIX, |
128 | | - root_paths = [ |
129 | | - "llvm", |
130 | | - ".", |
131 | | - ], |
132 | | -) |
133 | | - |
134 | | -# Make standalone compiler-rt for macOS hosts |
135 | | -copy_to_directory( |
136 | | - name = "compiler-rt", |
137 | | - srcs = ALL_COMPILER_RT_SRCS, |
138 | | - allow_overwrites = True, |
139 | | - replace_prefixes = COMPILER_RT_PREFIX, |
140 | | -) |
141 | | - |
142 | 109 | # Package the compiler into a tar |
143 | 110 | tar_package( |
144 | | - "llvm-package", |
145 | | - "llvm-{}".format(HOST_TARGET), |
146 | | - "llvm", |
| 111 | + name = "llvm-package", |
| 112 | + srcs = { |
| 113 | + "//:llvm": "llvm:.", |
| 114 | + } | COMPILER_RT_SRCS, |
| 115 | + output = "llvm-{}".format(HOST_TARGET), |
147 | 116 | ) |
148 | 117 |
|
| 118 | +# Make standalone compiler-rt for macOS hosts |
149 | 119 | tar_package( |
150 | | - "compiler-rt-package", |
151 | | - "compiler-rt-linux", |
152 | | - "compiler-rt", |
| 120 | + name = "compiler-rt-package", |
| 121 | + srcs = COMPILER_RT_SRCS, |
| 122 | + output = "compiler-rt-linux", |
153 | 123 | ) |
0 commit comments