Brian Silverman | 7d89e28 | 2021-11-17 17:36:54 -0800 | [diff] [blame] | 1 | # Copyright 2021 The Bazel Authors. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | load( |
| 16 | "//toolchain/internal:common.bzl", |
| 17 | _os = "os", |
| 18 | ) |
| 19 | load( |
Tyler Chatow | ec100e2 | 2022-03-22 16:23:04 -0700 | [diff] [blame] | 20 | "//toolchain/internal:common.bzl", |
| 21 | _arch = "arch", |
| 22 | ) |
| 23 | load( |
Brian Silverman | 7d89e28 | 2021-11-17 17:36:54 -0800 | [diff] [blame] | 24 | "//toolchain/internal:llvm_distributions.bzl", |
| 25 | _download_llvm_preconfigured = "download_llvm_preconfigured", |
| 26 | ) |
| 27 | |
| 28 | def llvm_repo_impl(rctx): |
| 29 | os = _os(rctx) |
Tyler Chatow | ec100e2 | 2022-03-22 16:23:04 -0700 | [diff] [blame] | 30 | arch = _arch(rctx) |
Brian Silverman | 7d89e28 | 2021-11-17 17:36:54 -0800 | [diff] [blame] | 31 | if os == "windows": |
| 32 | rctx.file("BUILD", executable = False) |
| 33 | return |
| 34 | |
| 35 | rctx.file( |
| 36 | "BUILD.bazel", |
| 37 | content = rctx.read(Label("//toolchain:BUILD.llvm_repo")), |
| 38 | executable = False, |
| 39 | ) |
| 40 | |
Tyler Chatow | ec100e2 | 2022-03-22 16:23:04 -0700 | [diff] [blame] | 41 | if os == "linux": |
| 42 | if arch == "x86_64": |
| 43 | rctx.symlink( |
Austin Schuh | 94dbdf3 | 2024-04-11 22:51:09 -0700 | [diff] [blame^] | 44 | Label("@clang_amd64_deps//:lib/x86_64-linux-gnu/libtinfo.so.5.9"), |
Tyler Chatow | ec100e2 | 2022-03-22 16:23:04 -0700 | [diff] [blame] | 45 | "lib/libtinfo.so.5.9", |
| 46 | ) |
Austin Schuh | 94dbdf3 | 2024-04-11 22:51:09 -0700 | [diff] [blame^] | 47 | rctx.symlink( |
| 48 | Label("@clang_amd64_deps//:usr/lib/x86_64-linux-gnu/libxml2.so.2.9.14"), |
| 49 | "lib/libxml2.so.2.9.14", |
| 50 | ) |
| 51 | rctx.symlink("lib/libxml2.so.2.9.14", "lib/libxml2.so.2") |
| 52 | |
| 53 | for lib in ["libicudata", "libicuuc"]: |
| 54 | rctx.symlink( |
| 55 | Label("@clang_amd64_deps//:usr/lib/x86_64-linux-gnu/" + lib + ".so.72.1"), |
| 56 | "lib/" + lib + ".so.72.1", |
| 57 | ) |
| 58 | rctx.symlink("lib/" + lib + ".so.72.1", "lib/" + lib + ".so.72") |
Tyler Chatow | ec100e2 | 2022-03-22 16:23:04 -0700 | [diff] [blame] | 59 | elif arch == "aarch64": |
| 60 | rctx.symlink( |
| 61 | Label("@libtinfo5_arm64//lib/aarch64-linux-gnu:libtinfo.so.5.9"), |
| 62 | "lib/libtinfo.so.5.9", |
| 63 | ) |
Tyler Chatow | 8a51ac6 | 2022-03-15 13:23:12 -0700 | [diff] [blame] | 64 | |
Tyler Chatow | ec100e2 | 2022-03-22 16:23:04 -0700 | [diff] [blame] | 65 | rctx.symlink("lib/libtinfo.so.5.9", "lib/libtinfo.so.5") |
Tyler Chatow | 8a51ac6 | 2022-03-15 13:23:12 -0700 | [diff] [blame] | 66 | |
Brian Silverman | 7d89e28 | 2021-11-17 17:36:54 -0800 | [diff] [blame] | 67 | _download_llvm_preconfigured(rctx) |
| 68 | |
| 69 | # We try to avoid patches to the downloaded repo so that it is easier for |
| 70 | # users to bring their own LLVM distribution through `http_archive`. If we |
| 71 | # do want to make changes, then we should do it through a patch file, and |
| 72 | # document it for users of toolchain_roots attribute. |