/src/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- FreeBSD.cpp - FreeBSD ToolChain Implementations --------*- C++ -*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include "FreeBSD.h" |
10 | | #include "Arch/ARM.h" |
11 | | #include "Arch/Mips.h" |
12 | | #include "Arch/Sparc.h" |
13 | | #include "CommonArgs.h" |
14 | | #include "clang/Config/config.h" |
15 | | #include "clang/Driver/Compilation.h" |
16 | | #include "clang/Driver/DriverDiagnostic.h" |
17 | | #include "clang/Driver/Options.h" |
18 | | #include "clang/Driver/SanitizerArgs.h" |
19 | | #include "llvm/Option/ArgList.h" |
20 | | #include "llvm/Support/VirtualFileSystem.h" |
21 | | |
22 | | using namespace clang::driver; |
23 | | using namespace clang::driver::tools; |
24 | | using namespace clang::driver::toolchains; |
25 | | using namespace clang; |
26 | | using namespace llvm::opt; |
27 | | |
28 | | void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA, |
29 | | const InputInfo &Output, |
30 | | const InputInfoList &Inputs, |
31 | | const ArgList &Args, |
32 | 0 | const char *LinkingOutput) const { |
33 | 0 | const auto &ToolChain = static_cast<const FreeBSD &>(getToolChain()); |
34 | 0 | const auto &D = getToolChain().getDriver(); |
35 | 0 | const llvm::Triple &Triple = ToolChain.getTriple(); |
36 | 0 | ArgStringList CmdArgs; |
37 | |
|
38 | 0 | claimNoWarnArgs(Args); |
39 | | |
40 | | // When building 32-bit code on FreeBSD/amd64, we have to explicitly |
41 | | // instruct as in the base system to assemble 32-bit code. |
42 | 0 | switch (ToolChain.getArch()) { |
43 | 0 | default: |
44 | 0 | break; |
45 | 0 | case llvm::Triple::x86: |
46 | 0 | CmdArgs.push_back("--32"); |
47 | 0 | break; |
48 | 0 | case llvm::Triple::ppc: |
49 | 0 | case llvm::Triple::ppcle: |
50 | 0 | CmdArgs.push_back("-a32"); |
51 | 0 | break; |
52 | 0 | case llvm::Triple::mips: |
53 | 0 | case llvm::Triple::mipsel: |
54 | 0 | case llvm::Triple::mips64: |
55 | 0 | case llvm::Triple::mips64el: { |
56 | 0 | StringRef CPUName; |
57 | 0 | StringRef ABIName; |
58 | 0 | mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName); |
59 | |
|
60 | 0 | CmdArgs.push_back("-march"); |
61 | 0 | CmdArgs.push_back(CPUName.data()); |
62 | |
|
63 | 0 | CmdArgs.push_back("-mabi"); |
64 | 0 | CmdArgs.push_back(mips::getGnuCompatibleMipsABIName(ABIName).data()); |
65 | |
|
66 | 0 | if (Triple.isLittleEndian()) |
67 | 0 | CmdArgs.push_back("-EL"); |
68 | 0 | else |
69 | 0 | CmdArgs.push_back("-EB"); |
70 | |
|
71 | 0 | if (Arg *A = Args.getLastArg(options::OPT_G)) { |
72 | 0 | StringRef v = A->getValue(); |
73 | 0 | CmdArgs.push_back(Args.MakeArgString("-G" + v)); |
74 | 0 | A->claim(); |
75 | 0 | } |
76 | |
|
77 | 0 | AddAssemblerKPIC(ToolChain, Args, CmdArgs); |
78 | 0 | break; |
79 | 0 | } |
80 | 0 | case llvm::Triple::arm: |
81 | 0 | case llvm::Triple::armeb: |
82 | 0 | case llvm::Triple::thumb: |
83 | 0 | case llvm::Triple::thumbeb: { |
84 | 0 | arm::FloatABI ABI = arm::getARMFloatABI(ToolChain, Args); |
85 | |
|
86 | 0 | if (ABI == arm::FloatABI::Hard) |
87 | 0 | CmdArgs.push_back("-mfpu=vfp"); |
88 | 0 | else |
89 | 0 | CmdArgs.push_back("-mfpu=softvfp"); |
90 | |
|
91 | 0 | CmdArgs.push_back("-meabi=5"); |
92 | 0 | break; |
93 | 0 | } |
94 | 0 | case llvm::Triple::sparcv9: { |
95 | 0 | std::string CPU = getCPUName(D, Args, Triple); |
96 | 0 | CmdArgs.push_back(sparc::getSparcAsmModeForCPU(CPU, Triple)); |
97 | 0 | AddAssemblerKPIC(ToolChain, Args, CmdArgs); |
98 | 0 | break; |
99 | 0 | } |
100 | 0 | } |
101 | | |
102 | 0 | for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ, |
103 | 0 | options::OPT_fdebug_prefix_map_EQ)) { |
104 | 0 | StringRef Map = A->getValue(); |
105 | 0 | if (!Map.contains('=')) |
106 | 0 | D.Diag(diag::err_drv_invalid_argument_to_option) |
107 | 0 | << Map << A->getOption().getName(); |
108 | 0 | else { |
109 | 0 | CmdArgs.push_back(Args.MakeArgString("--debug-prefix-map")); |
110 | 0 | CmdArgs.push_back(Args.MakeArgString(Map)); |
111 | 0 | } |
112 | 0 | A->claim(); |
113 | 0 | } |
114 | |
|
115 | 0 | Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler); |
116 | |
|
117 | 0 | CmdArgs.push_back("-o"); |
118 | 0 | CmdArgs.push_back(Output.getFilename()); |
119 | |
|
120 | 0 | for (const auto &II : Inputs) |
121 | 0 | CmdArgs.push_back(II.getFilename()); |
122 | |
|
123 | 0 | const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("as")); |
124 | 0 | C.addCommand(std::make_unique<Command>(JA, *this, |
125 | 0 | ResponseFileSupport::AtFileCurCP(), |
126 | 0 | Exec, CmdArgs, Inputs, Output)); |
127 | 0 | } |
128 | | |
129 | | void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, |
130 | | const InputInfo &Output, |
131 | | const InputInfoList &Inputs, |
132 | | const ArgList &Args, |
133 | 0 | const char *LinkingOutput) const { |
134 | 0 | const auto &ToolChain = static_cast<const FreeBSD &>(getToolChain()); |
135 | 0 | const Driver &D = ToolChain.getDriver(); |
136 | 0 | const llvm::Triple::ArchType Arch = ToolChain.getArch(); |
137 | 0 | const bool IsPIE = |
138 | 0 | !Args.hasArg(options::OPT_shared) && |
139 | 0 | (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault(Args)); |
140 | 0 | ArgStringList CmdArgs; |
141 | | |
142 | | // Silence warning for "clang -g foo.o -o foo" |
143 | 0 | Args.ClaimAllArgs(options::OPT_g_Group); |
144 | | // and "clang -emit-llvm foo.o -o foo" |
145 | 0 | Args.ClaimAllArgs(options::OPT_emit_llvm); |
146 | | // and for "clang -w foo.o -o foo". Other warning options are already |
147 | | // handled somewhere else. |
148 | 0 | Args.ClaimAllArgs(options::OPT_w); |
149 | |
|
150 | 0 | if (!D.SysRoot.empty()) |
151 | 0 | CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); |
152 | |
|
153 | 0 | if (IsPIE) |
154 | 0 | CmdArgs.push_back("-pie"); |
155 | |
|
156 | 0 | CmdArgs.push_back("--eh-frame-hdr"); |
157 | 0 | if (Args.hasArg(options::OPT_static)) { |
158 | 0 | CmdArgs.push_back("-Bstatic"); |
159 | 0 | } else { |
160 | 0 | if (Args.hasArg(options::OPT_rdynamic)) |
161 | 0 | CmdArgs.push_back("-export-dynamic"); |
162 | 0 | if (Args.hasArg(options::OPT_shared)) { |
163 | 0 | CmdArgs.push_back("-shared"); |
164 | 0 | } else if (!Args.hasArg(options::OPT_r)) { |
165 | 0 | CmdArgs.push_back("-dynamic-linker"); |
166 | 0 | CmdArgs.push_back("/libexec/ld-elf.so.1"); |
167 | 0 | } |
168 | 0 | const llvm::Triple &T = ToolChain.getTriple(); |
169 | 0 | if (Arch == llvm::Triple::arm || T.isX86()) |
170 | 0 | CmdArgs.push_back("--hash-style=both"); |
171 | 0 | CmdArgs.push_back("--enable-new-dtags"); |
172 | 0 | } |
173 | | |
174 | | // Explicitly set the linker emulation for platforms that might not |
175 | | // be the default emulation for the linker. |
176 | 0 | switch (Arch) { |
177 | 0 | case llvm::Triple::x86: |
178 | 0 | CmdArgs.push_back("-m"); |
179 | 0 | CmdArgs.push_back("elf_i386_fbsd"); |
180 | 0 | break; |
181 | 0 | case llvm::Triple::ppc: |
182 | 0 | CmdArgs.push_back("-m"); |
183 | 0 | CmdArgs.push_back("elf32ppc_fbsd"); |
184 | 0 | break; |
185 | 0 | case llvm::Triple::ppcle: |
186 | 0 | CmdArgs.push_back("-m"); |
187 | | // Use generic -- only usage is for freestanding. |
188 | 0 | CmdArgs.push_back("elf32lppc"); |
189 | 0 | break; |
190 | 0 | case llvm::Triple::mips: |
191 | 0 | CmdArgs.push_back("-m"); |
192 | 0 | CmdArgs.push_back("elf32btsmip_fbsd"); |
193 | 0 | break; |
194 | 0 | case llvm::Triple::mipsel: |
195 | 0 | CmdArgs.push_back("-m"); |
196 | 0 | CmdArgs.push_back("elf32ltsmip_fbsd"); |
197 | 0 | break; |
198 | 0 | case llvm::Triple::mips64: |
199 | 0 | CmdArgs.push_back("-m"); |
200 | 0 | if (tools::mips::hasMipsAbiArg(Args, "n32")) |
201 | 0 | CmdArgs.push_back("elf32btsmipn32_fbsd"); |
202 | 0 | else |
203 | 0 | CmdArgs.push_back("elf64btsmip_fbsd"); |
204 | 0 | break; |
205 | 0 | case llvm::Triple::mips64el: |
206 | 0 | CmdArgs.push_back("-m"); |
207 | 0 | if (tools::mips::hasMipsAbiArg(Args, "n32")) |
208 | 0 | CmdArgs.push_back("elf32ltsmipn32_fbsd"); |
209 | 0 | else |
210 | 0 | CmdArgs.push_back("elf64ltsmip_fbsd"); |
211 | 0 | break; |
212 | 0 | case llvm::Triple::riscv64: |
213 | 0 | CmdArgs.push_back("-m"); |
214 | 0 | CmdArgs.push_back("elf64lriscv"); |
215 | 0 | CmdArgs.push_back("-X"); |
216 | 0 | break; |
217 | 0 | default: |
218 | 0 | break; |
219 | 0 | } |
220 | | |
221 | 0 | if (Arg *A = Args.getLastArg(options::OPT_G)) { |
222 | 0 | if (ToolChain.getTriple().isMIPS()) { |
223 | 0 | StringRef v = A->getValue(); |
224 | 0 | CmdArgs.push_back(Args.MakeArgString("-G" + v)); |
225 | 0 | A->claim(); |
226 | 0 | } |
227 | 0 | } |
228 | |
|
229 | 0 | assert((Output.isFilename() || Output.isNothing()) && "Invalid output."); |
230 | 0 | if (Output.isFilename()) { |
231 | 0 | CmdArgs.push_back("-o"); |
232 | 0 | CmdArgs.push_back(Output.getFilename()); |
233 | 0 | } |
234 | |
|
235 | 0 | if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, |
236 | 0 | options::OPT_r)) { |
237 | 0 | const char *crt1 = nullptr; |
238 | 0 | if (!Args.hasArg(options::OPT_shared)) { |
239 | 0 | if (Args.hasArg(options::OPT_pg)) |
240 | 0 | crt1 = "gcrt1.o"; |
241 | 0 | else if (IsPIE) |
242 | 0 | crt1 = "Scrt1.o"; |
243 | 0 | else |
244 | 0 | crt1 = "crt1.o"; |
245 | 0 | } |
246 | 0 | if (crt1) |
247 | 0 | CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1))); |
248 | |
|
249 | 0 | CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o"))); |
250 | |
|
251 | 0 | const char *crtbegin = nullptr; |
252 | 0 | if (Args.hasArg(options::OPT_static)) |
253 | 0 | crtbegin = "crtbeginT.o"; |
254 | 0 | else if (Args.hasArg(options::OPT_shared) || IsPIE) |
255 | 0 | crtbegin = "crtbeginS.o"; |
256 | 0 | else |
257 | 0 | crtbegin = "crtbegin.o"; |
258 | |
|
259 | 0 | CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin))); |
260 | 0 | } |
261 | |
|
262 | 0 | Args.AddAllArgs(CmdArgs, options::OPT_L); |
263 | 0 | ToolChain.AddFilePathLibArgs(Args, CmdArgs); |
264 | 0 | Args.addAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_s, |
265 | 0 | options::OPT_t, options::OPT_r}); |
266 | |
|
267 | 0 | if (D.isUsingLTO()) { |
268 | 0 | assert(!Inputs.empty() && "Must have at least one input."); |
269 | | // Find the first filename InputInfo object. |
270 | 0 | auto Input = llvm::find_if( |
271 | 0 | Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); }); |
272 | 0 | if (Input == Inputs.end()) |
273 | | // For a very rare case, all of the inputs to the linker are |
274 | | // InputArg. If that happens, just use the first InputInfo. |
275 | 0 | Input = Inputs.begin(); |
276 | |
|
277 | 0 | addLTOOptions(ToolChain, Args, CmdArgs, Output, *Input, |
278 | 0 | D.getLTOMode() == LTOK_Thin); |
279 | 0 | } |
280 | | |
281 | 0 | bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); |
282 | 0 | bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); |
283 | 0 | addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs); |
284 | 0 | AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); |
285 | |
|
286 | 0 | unsigned Major = ToolChain.getTriple().getOSMajorVersion(); |
287 | 0 | bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14; |
288 | 0 | if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, |
289 | 0 | options::OPT_r)) { |
290 | | // Use the static OpenMP runtime with -static-openmp |
291 | 0 | bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) && |
292 | 0 | !Args.hasArg(options::OPT_static); |
293 | 0 | addOpenMPRuntime(CmdArgs, ToolChain, Args, StaticOpenMP); |
294 | |
|
295 | 0 | if (D.CCCIsCXX()) { |
296 | 0 | if (ToolChain.ShouldLinkCXXStdlib(Args)) |
297 | 0 | ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); |
298 | 0 | if (Profiling) |
299 | 0 | CmdArgs.push_back("-lm_p"); |
300 | 0 | else |
301 | 0 | CmdArgs.push_back("-lm"); |
302 | 0 | } |
303 | | |
304 | | // Silence warnings when linking C code with a C++ '-stdlib' argument. |
305 | 0 | Args.ClaimAllArgs(options::OPT_stdlib_EQ); |
306 | | |
307 | | // Additional linker set-up and flags for Fortran. This is required in order |
308 | | // to generate executables. As Fortran runtime depends on the C runtime, |
309 | | // these dependencies need to be listed before the C runtime below (i.e. |
310 | | // AddRunTimeLibs). |
311 | 0 | if (D.IsFlangMode()) { |
312 | 0 | addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs); |
313 | 0 | addFortranRuntimeLibs(ToolChain, Args, CmdArgs); |
314 | 0 | if (Profiling) |
315 | 0 | CmdArgs.push_back("-lm_p"); |
316 | 0 | else |
317 | 0 | CmdArgs.push_back("-lm"); |
318 | 0 | } |
319 | |
|
320 | 0 | if (NeedsSanitizerDeps) |
321 | 0 | linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs); |
322 | 0 | if (NeedsXRayDeps) |
323 | 0 | linkXRayRuntimeDeps(ToolChain, Args, CmdArgs); |
324 | | // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding |
325 | | // the default system libraries. Just mimic this for now. |
326 | 0 | if (Profiling) |
327 | 0 | CmdArgs.push_back("-lgcc_p"); |
328 | 0 | else |
329 | 0 | CmdArgs.push_back("-lgcc"); |
330 | 0 | if (Args.hasArg(options::OPT_static)) { |
331 | 0 | CmdArgs.push_back("-lgcc_eh"); |
332 | 0 | } else if (Profiling) { |
333 | 0 | CmdArgs.push_back("-lgcc_eh_p"); |
334 | 0 | } else { |
335 | 0 | CmdArgs.push_back("--as-needed"); |
336 | 0 | CmdArgs.push_back("-lgcc_s"); |
337 | 0 | CmdArgs.push_back("--no-as-needed"); |
338 | 0 | } |
339 | |
|
340 | 0 | if (Args.hasArg(options::OPT_pthread)) { |
341 | 0 | if (Profiling) |
342 | 0 | CmdArgs.push_back("-lpthread_p"); |
343 | 0 | else |
344 | 0 | CmdArgs.push_back("-lpthread"); |
345 | 0 | } |
346 | |
|
347 | 0 | if (Profiling) { |
348 | 0 | if (Args.hasArg(options::OPT_shared)) |
349 | 0 | CmdArgs.push_back("-lc"); |
350 | 0 | else |
351 | 0 | CmdArgs.push_back("-lc_p"); |
352 | 0 | CmdArgs.push_back("-lgcc_p"); |
353 | 0 | } else { |
354 | 0 | CmdArgs.push_back("-lc"); |
355 | 0 | CmdArgs.push_back("-lgcc"); |
356 | 0 | } |
357 | |
|
358 | 0 | if (Args.hasArg(options::OPT_static)) { |
359 | 0 | CmdArgs.push_back("-lgcc_eh"); |
360 | 0 | } else if (Profiling) { |
361 | 0 | CmdArgs.push_back("-lgcc_eh_p"); |
362 | 0 | } else { |
363 | 0 | CmdArgs.push_back("--as-needed"); |
364 | 0 | CmdArgs.push_back("-lgcc_s"); |
365 | 0 | CmdArgs.push_back("--no-as-needed"); |
366 | 0 | } |
367 | 0 | } |
368 | |
|
369 | 0 | if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, |
370 | 0 | options::OPT_r)) { |
371 | 0 | const char *crtend = nullptr; |
372 | 0 | if (Args.hasArg(options::OPT_shared) || IsPIE) |
373 | 0 | crtend = "crtendS.o"; |
374 | 0 | else |
375 | 0 | crtend = "crtend.o"; |
376 | 0 | CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend))); |
377 | 0 | CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o"))); |
378 | 0 | } |
379 | |
|
380 | 0 | ToolChain.addProfileRTLibs(Args, CmdArgs); |
381 | |
|
382 | 0 | const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath()); |
383 | 0 | C.addCommand(std::make_unique<Command>(JA, *this, |
384 | 0 | ResponseFileSupport::AtFileCurCP(), |
385 | 0 | Exec, CmdArgs, Inputs, Output)); |
386 | 0 | } |
387 | | |
388 | | /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly. |
389 | | |
390 | | FreeBSD::FreeBSD(const Driver &D, const llvm::Triple &Triple, |
391 | | const ArgList &Args) |
392 | 0 | : Generic_ELF(D, Triple, Args) { |
393 | | |
394 | | // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall |
395 | | // back to '/usr/lib' if it doesn't exist. |
396 | 0 | if (Triple.isArch32Bit() && |
397 | 0 | D.getVFS().exists(concat(getDriver().SysRoot, "/usr/lib32/crt1.o"))) |
398 | 0 | getFilePaths().push_back(concat(getDriver().SysRoot, "/usr/lib32")); |
399 | 0 | else |
400 | 0 | getFilePaths().push_back(concat(getDriver().SysRoot, "/usr/lib")); |
401 | 0 | } |
402 | | |
403 | | void FreeBSD::AddClangSystemIncludeArgs( |
404 | | const llvm::opt::ArgList &DriverArgs, |
405 | 0 | llvm::opt::ArgStringList &CC1Args) const { |
406 | 0 | const Driver &D = getDriver(); |
407 | |
|
408 | 0 | if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc)) |
409 | 0 | return; |
410 | | |
411 | 0 | if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { |
412 | 0 | SmallString<128> Dir(D.ResourceDir); |
413 | 0 | llvm::sys::path::append(Dir, "include"); |
414 | 0 | addSystemInclude(DriverArgs, CC1Args, Dir.str()); |
415 | 0 | } |
416 | |
|
417 | 0 | if (DriverArgs.hasArg(options::OPT_nostdlibinc)) |
418 | 0 | return; |
419 | | |
420 | | // Check for configure-time C include directories. |
421 | 0 | StringRef CIncludeDirs(C_INCLUDE_DIRS); |
422 | 0 | if (CIncludeDirs != "") { |
423 | 0 | SmallVector<StringRef, 5> dirs; |
424 | 0 | CIncludeDirs.split(dirs, ":"); |
425 | 0 | for (StringRef dir : dirs) { |
426 | 0 | StringRef Prefix = |
427 | 0 | llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : ""; |
428 | 0 | addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir); |
429 | 0 | } |
430 | 0 | return; |
431 | 0 | } |
432 | | |
433 | 0 | addExternCSystemInclude(DriverArgs, CC1Args, |
434 | 0 | concat(D.SysRoot, "/usr/include")); |
435 | 0 | } |
436 | | |
437 | | void FreeBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, |
438 | 0 | llvm::opt::ArgStringList &CC1Args) const { |
439 | 0 | addSystemInclude(DriverArgs, CC1Args, |
440 | 0 | concat(getDriver().SysRoot, "/usr/include/c++/v1")); |
441 | 0 | } |
442 | | |
443 | | void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args, |
444 | 0 | ArgStringList &CmdArgs) const { |
445 | 0 | unsigned Major = getTriple().getOSMajorVersion(); |
446 | 0 | bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14; |
447 | |
|
448 | 0 | CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++"); |
449 | 0 | if (Args.hasArg(options::OPT_fexperimental_library)) |
450 | 0 | CmdArgs.push_back("-lc++experimental"); |
451 | 0 | } |
452 | | |
453 | | void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs, |
454 | 0 | ArgStringList &CC1Args) const { |
455 | 0 | CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args); |
456 | 0 | } |
457 | | |
458 | | void FreeBSD::AddHIPIncludeArgs(const ArgList &DriverArgs, |
459 | 0 | ArgStringList &CC1Args) const { |
460 | 0 | RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args); |
461 | 0 | } |
462 | | |
463 | 0 | Tool *FreeBSD::buildAssembler() const { |
464 | 0 | return new tools::freebsd::Assembler(*this); |
465 | 0 | } |
466 | | |
467 | 0 | Tool *FreeBSD::buildLinker() const { return new tools::freebsd::Linker(*this); } |
468 | | |
469 | 0 | bool FreeBSD::HasNativeLLVMSupport() const { return true; } |
470 | | |
471 | | ToolChain::UnwindTableLevel |
472 | 0 | FreeBSD::getDefaultUnwindTableLevel(const ArgList &Args) const { |
473 | 0 | return UnwindTableLevel::Asynchronous; |
474 | 0 | } |
475 | | |
476 | 0 | bool FreeBSD::isPIEDefault(const llvm::opt::ArgList &Args) const { |
477 | 0 | return getSanitizerArgs(Args).requiresPIE(); |
478 | 0 | } |
479 | | |
480 | 0 | SanitizerMask FreeBSD::getSupportedSanitizers() const { |
481 | 0 | const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64; |
482 | 0 | const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; |
483 | 0 | const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; |
484 | 0 | const bool IsMIPS64 = getTriple().isMIPS64(); |
485 | 0 | SanitizerMask Res = ToolChain::getSupportedSanitizers(); |
486 | 0 | Res |= SanitizerKind::Address; |
487 | 0 | Res |= SanitizerKind::PointerCompare; |
488 | 0 | Res |= SanitizerKind::PointerSubtract; |
489 | 0 | Res |= SanitizerKind::Vptr; |
490 | 0 | if (IsAArch64 || IsX86_64 || IsMIPS64) { |
491 | 0 | Res |= SanitizerKind::Leak; |
492 | 0 | Res |= SanitizerKind::Thread; |
493 | 0 | } |
494 | 0 | if (IsAArch64 || IsX86 || IsX86_64) { |
495 | 0 | Res |= SanitizerKind::SafeStack; |
496 | 0 | Res |= SanitizerKind::Fuzzer; |
497 | 0 | Res |= SanitizerKind::FuzzerNoLink; |
498 | 0 | } |
499 | 0 | if (IsAArch64 || IsX86_64) { |
500 | 0 | Res |= SanitizerKind::KernelAddress; |
501 | 0 | Res |= SanitizerKind::KernelMemory; |
502 | 0 | Res |= SanitizerKind::Memory; |
503 | 0 | } |
504 | 0 | return Res; |
505 | 0 | } |