[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / utils / bazel / llvm-project-overlay / lld / BUILD.bazel
bloba01aa13ed4f9a6c6240c32f4c2ed9c96be266fdd
1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
6 load("//llvm:tblgen.bzl", "gentbl")
7 load("//llvm:binary_alias.bzl", "binary_alias")
8 load(
9     "//:vars.bzl",
10     "LLVM_VERSION",
13 package(
14     default_visibility = ["//visibility:public"],
15     features = ["layering_check"],
18 licenses(["notice"])
20 # TODO: Actually compute version info
21 genrule(
22     name = "config_version_gen",
23     outs = ["include/lld/Common/Version.inc"],
24     cmd = "echo '#define LLD_VERSION_STRING \"{}\"' > $@".format(LLVM_VERSION),
27 genrule(
28     name = "vcs_version_gen",
29     outs = ["Common/VCSVersion.inc"],
30     cmd = "echo '#undef LLD_REVISION' >> $@\n" +
31           "echo '#undef LLD_REPOSITORY' >> $@\n",
34 # See https://github.com/bazelbuild/bazel/issues/13803
35 cc_library(
36     name = "vcs_version",
37     hdrs = ["Common/VCSVersion.inc"],
38     strip_include_prefix = "Common",
41 cc_library(
42     name = "Common",
43     srcs = [":config_version_gen"] + glob(["Common/*.cpp"]),
44     hdrs = glob(["include/lld/Common/*.h"]),
45     includes = ["include"],
46     deps = [
47         ":vcs_version",
48         "//llvm:CodeGen",
49         "//llvm:Core",
50         "//llvm:DebugInfoDWARF",
51         "//llvm:IRPrinter",
52         "//llvm:Option",
53         "//llvm:Support",
54         "//llvm:Target",
55         "//llvm:TargetParser",
56         "//llvm:config",
57     ],
60 gentbl(
61     name = "elf_options_inc_gen",
62     # See https://github.com/bazelbuild/bazel/issues/13803
63     strip_include_prefix = "ELF",
64     tbl_outs = [(
65         "-gen-opt-parser-defs",
66         "ELF/Options.inc",
67     )],
68     tblgen = "//llvm:llvm-tblgen",
69     td_file = "ELF/Options.td",
70     td_srcs = [
71         "//llvm:include/llvm/Option/OptParser.td",
72     ],
75 cc_library(
76     name = "ELF",
77     srcs = glob([
78         "ELF/*.cpp",
79         "ELF/*.h",
80         "ELF/Arch/*.cpp",
81     ]),
82     includes = ["ELF"],
83     textual_hdrs = [
84         "ELF/Arch/PPCInsns.def",
85     ],
86     deps = [
87         ":Common",
88         ":elf_options_inc_gen",
89         "//llvm:AllTargetsAsmParsers",
90         "//llvm:AllTargetsCodeGens",
91         "//llvm:AllTargetsDisassemblers",
92         "//llvm:Analysis",
93         "//llvm:BinaryFormat",
94         "//llvm:BitReader",
95         "//llvm:BitWriter",
96         "//llvm:CodeGen",
97         "//llvm:Core",
98         "//llvm:DebugInfoDWARF",
99         "//llvm:Demangle",
100         "//llvm:IPO",
101         "//llvm:LTO",
102         "//llvm:Linker",
103         "//llvm:MC",
104         "//llvm:Object",
105         "//llvm:Option",
106         "//llvm:Passes",
107         "//llvm:Remarks",
108         "//llvm:Support",
109         "//llvm:TargetParser",
110         "//llvm:TransformUtils",
111         "//llvm:config",
112         "@llvm_zlib//:zlib",
113         "@llvm_zstd//:zstd",
114     ],
117 gentbl(
118     name = "coff_options_inc_gen",
119     # See https://github.com/bazelbuild/bazel/issues/13803
120     strip_include_prefix = "COFF",
121     tbl_outs = [(
122         "-gen-opt-parser-defs",
123         "COFF/Options.inc",
124     )],
125     tblgen = "//llvm:llvm-tblgen",
126     td_file = "COFF/Options.td",
127     td_srcs = [
128         "//llvm:include/llvm/Option/OptParser.td",
129     ],
132 cc_library(
133     name = "COFF",
134     srcs = glob([
135         "COFF/*.cpp",
136         "COFF/*.h",
137     ]),
138     includes = ["COFF"],
139     deps = [
140         ":Common",
141         ":coff_options_inc_gen",
142         "//llvm:AllTargetsAsmParsers",
143         "//llvm:AllTargetsCodeGens",
144         "//llvm:AllTargetsDisassemblers",
145         "//llvm:Analysis",
146         "//llvm:BinaryFormat",
147         "//llvm:BitReader",
148         "//llvm:BitWriter",
149         "//llvm:Core",
150         "//llvm:DebugInfo",
151         "//llvm:DebugInfoCodeView",
152         "//llvm:DebugInfoMSF",
153         "//llvm:DebugInfoPDB",
154         "//llvm:Demangle",
155         "//llvm:IPO",
156         "//llvm:LTO",
157         "//llvm:LibDriver",
158         "//llvm:Linker",
159         "//llvm:MC",
160         "//llvm:Object",
161         "//llvm:Option",
162         "//llvm:Support",
163         "//llvm:Symbolize",
164         "//llvm:Target",
165         "//llvm:TargetParser",
166         "//llvm:TransformUtils",
167         "//llvm:WindowsDriver",
168         "//llvm:WindowsManifest",
169         "//llvm:config",
170     ],
173 gentbl(
174     name = "mingw_options_inc_gen",
175     tbl_outs = [(
176         "-gen-opt-parser-defs",
177         "MinGW/Options.inc",
178     )],
179     tblgen = "//llvm:llvm-tblgen",
180     td_file = "MinGW/Options.td",
181     td_srcs = [
182         "//llvm:include/llvm/Option/OptParser.td",
183     ],
186 cc_library(
187     name = "MinGW",
188     srcs = glob([
189         "MinGW/*.cpp",
190         "MinGW/*.h",
191     ]),
192     includes = ["MinGW"],
193     deps = [
194         ":Common",
195         ":mingw_options_inc_gen",
196         "//llvm:Option",
197         "//llvm:Support",
198         "//llvm:TargetParser",
199     ],
202 gentbl(
203     name = "macho_options_inc_gen",
204     # See https://github.com/bazelbuild/bazel/issues/13803
205     strip_include_prefix = "MachO",
206     tbl_outs = [(
207         "-gen-opt-parser-defs",
208         "MachO/Options.inc",
209     )],
210     tblgen = "//llvm:llvm-tblgen",
211     td_file = "MachO/Options.td",
212     td_srcs = [
213         "//llvm:include/llvm/Option/OptParser.td",
214     ],
217 cc_library(
218     name = "MachO",
219     srcs = glob([
220         "MachO/**/*.cpp",
221         "MachO/**/*.h",
222     ]),
223     includes = ["MachO"],
224     deps = [
225         ":Common",
226         ":macho_options_inc_gen",
227         "//libunwind:unwind_headers_only",
228         "//llvm:BinaryFormat",
229         "//llvm:BitReader",
230         "//llvm:BitWriter",
231         "//llvm:Core",
232         "//llvm:DebugInfoDWARF",
233         "//llvm:Demangle",
234         "//llvm:LTO",
235         "//llvm:MC",
236         "//llvm:ObjCARC",
237         "//llvm:Object",
238         "//llvm:Option",
239         "//llvm:Support",
240         "//llvm:TargetParser",
241         "//llvm:TextAPI",
242         "//llvm:config",
243     ],
246 gentbl(
247     name = "wasm_options_inc_gen",
248     # See https://github.com/bazelbuild/bazel/issues/13803
249     strip_include_prefix = "wasm",
250     tbl_outs = [(
251         "-gen-opt-parser-defs",
252         "wasm/Options.inc",
253     )],
254     tblgen = "//llvm:llvm-tblgen",
255     td_file = "wasm/Options.td",
256     td_srcs = [
257         "//llvm:include/llvm/Option/OptParser.td",
258     ],
261 cc_library(
262     name = "Wasm",
263     srcs = glob([
264         "wasm/*.cpp",
265         "wasm/*.h",
266     ]),
267     includes = ["wasm"],
268     deps = [
269         ":Common",
270         ":wasm_options_inc_gen",
271         "//llvm:AllTargetsAsmParsers",
272         "//llvm:AllTargetsCodeGens",
273         "//llvm:BinaryFormat",
274         "//llvm:Core",
275         "//llvm:Demangle",
276         "//llvm:LTO",
277         "//llvm:MC",
278         "//llvm:Object",
279         "//llvm:Option",
280         "//llvm:Support",
281         "//llvm:TargetParser",
282         "//llvm:config",
283     ],
286 expand_template(
287     name = "lld_main",
288     out = "lld-driver.cpp",
289     substitutions = {
290         "@TOOL_NAME@": "lld",
291     },
292     template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
295 cc_binary(
296     name = "lld",
297     srcs = glob([
298         "tools/lld/*.cpp",
299         "tools/lld/*.h",
300     ]) + ["lld-driver.cpp"],
301     deps = [
302         ":COFF",
303         ":Common",
304         ":ELF",
305         ":MachO",
306         ":MinGW",
307         ":Wasm",
308         "//llvm:Support",
309         "//llvm:TargetParser",
310     ],
313 # These are the required names for lld running under different environs.
315 # Unix/Linux require that the binary be named "ld.lld".
316 # macOS require that the binary be named "ld64.lld".
317 # Windows require that the binary be named "lld-link".
318 # WebAssembly builds require that the binary be named "wasm-ld".
320     binary_alias(
321         name = name,
322         binary = ":lld",
323     )
324     for name in [
325         "ld.lld",
326         "ld64.lld",
327         "lld-link",
328         "wasm-ld",
329     ]