15#include "clang/Config/config.h"
21#include "llvm/ADT/StringSwitch.h"
22#include "llvm/Option/ArgList.h"
23#include "llvm/ProfileData/InstrProf.h"
24#include "llvm/Support/Path.h"
25#include "llvm/Support/ScopedPrinter.h"
26#include "llvm/Support/Threading.h"
27#include "llvm/Support/VirtualFileSystem.h"
28#include "llvm/TargetParser/TargetParser.h"
29#include "llvm/TargetParser/Triple.h"
39 return VersionTuple(13, 1);
55 return llvm::StringSwitch<llvm::Triple::ArchType>(Str)
56 .Cases(
"i386",
"i486",
"i486SX",
"i586",
"i686", llvm::Triple::x86)
57 .Cases(
"pentium",
"pentpro",
"pentIIm3",
"pentIIm5",
"pentium4",
59 .Cases(
"x86_64",
"x86_64h", llvm::Triple::x86_64)
61 .Cases(
"arm",
"armv4t",
"armv5",
"armv6",
"armv6m", llvm::Triple::arm)
62 .Cases(
"armv7",
"armv7em",
"armv7k",
"armv7m", llvm::Triple::arm)
63 .Cases(
"armv7s",
"xscale", llvm::Triple::arm)
64 .Cases(
"arm64",
"arm64e", llvm::Triple::aarch64)
65 .Case(
"arm64_32", llvm::Triple::aarch64_32)
66 .Case(
"r600", llvm::Triple::r600)
67 .Case(
"amdgcn", llvm::Triple::amdgcn)
68 .Case(
"nvptx", llvm::Triple::nvptx)
69 .Case(
"nvptx64", llvm::Triple::nvptx64)
70 .Case(
"amdil", llvm::Triple::amdil)
71 .Case(
"spir", llvm::Triple::spir)
72 .Default(llvm::Triple::UnknownArch);
76 const ArgList &Args) {
77 const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
78 llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Str);
80 if (Arch != llvm::Triple::UnknownArch)
83 if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
84 ArchKind == llvm::ARM::ArchKind::ARMV7M ||
85 ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
87 if (
T.getOS() == llvm::Triple::IOS)
88 for (Arg *A : Args.filtered(options::OPT_mios_version_min_EQ))
89 A->ignoreTargetSpecific();
90 if (
T.getOS() == llvm::Triple::WatchOS)
91 for (Arg *A : Args.filtered(options::OPT_mwatchos_version_min_EQ))
92 A->ignoreTargetSpecific();
93 if (
T.getOS() == llvm::Triple::TvOS)
94 for (Arg *A : Args.filtered(options::OPT_mtvos_version_min_EQ))
95 A->ignoreTargetSpecific();
97 T.setOS(llvm::Triple::UnknownOS);
98 T.setObjectFormat(llvm::Triple::MachO);
106 const char *LinkingOutput)
const {
109 ArgStringList CmdArgs;
111 assert(Inputs.size() == 1 &&
"Unexpected number of inputs.");
115 const Action *SourceAction = &JA;
117 assert(!SourceAction->
getInputs().empty() &&
"unexpected root action!");
118 SourceAction = SourceAction->
getInputs()[0];
126 if (Args.hasArg(options::OPT_fno_integrated_as)) {
127 if (!(
T.isMacOSX() &&
T.isMacOSXVersionLT(10, 7)))
128 CmdArgs.push_back(
"-Q");
132 if (SourceAction->
getType() == types::TY_Asm ||
133 SourceAction->
getType() == types::TY_PP_Asm) {
134 if (Args.hasArg(options::OPT_gstabs))
135 CmdArgs.push_back(
"--gstabs");
136 else if (Args.hasArg(options::OPT_g_Group))
137 CmdArgs.push_back(
"-g");
144 if (
T.isX86() || Args.hasArg(options::OPT_force__cpusubtype__ALL))
145 CmdArgs.push_back(
"-force_cpusubtype_ALL");
148 (((Args.hasArg(options::OPT_mkernel) ||
149 Args.hasArg(options::OPT_fapple_kext)) &&
151 Args.hasArg(options::OPT_static)))
152 CmdArgs.push_back(
"-static");
154 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
156 assert(Output.
isFilename() &&
"Unexpected lipo output.");
157 CmdArgs.push_back(
"-o");
160 assert(Input.
isFilename() &&
"Invalid input.");
165 const char *Exec = Args.MakeArgString(
getToolChain().GetProgramPath(
"as"));
167 Exec, CmdArgs, Inputs, Output));
170void darwin::MachOTool::anchor() {}
173 ArgStringList &CmdArgs)
const {
174 StringRef ArchName = getMachOToolChain().getMachOArchName(Args);
177 CmdArgs.push_back(
"-arch");
178 CmdArgs.push_back(Args.MakeArgString(ArchName));
181 if (ArchName ==
"arm")
182 CmdArgs.push_back(
"-force_cpusubtype_ALL");
185bool darwin::Linker::NeedsTempPath(
const InputInfoList &Inputs)
const {
189 for (
const auto &Input : Inputs)
190 if (Input.getType() != types::TY_Object)
204 if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
205 if (A->getOption().matches(options::OPT_O0))
207 if (A->getOption().matches(options::OPT_O))
208 return llvm::StringSwitch<bool>(A->getValue())
214 if (!IsLinkerOnlyAction)
219void darwin::Linker::AddLinkArgs(
Compilation &
C,
const ArgList &Args,
220 ArgStringList &CmdArgs,
222 VersionTuple Version,
bool LinkerIsLLD,
223 bool UsePlatformVersion)
const {
224 const Driver &
D = getToolChain().getDriver();
229 if ((Version >= VersionTuple(100) || LinkerIsLLD) &&
230 !Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
231 CmdArgs.push_back(
"-demangle");
233 if (Args.hasArg(options::OPT_rdynamic) &&
234 (Version >= VersionTuple(137) || LinkerIsLLD))
235 CmdArgs.push_back(
"-export_dynamic");
239 if (Args.hasFlag(options::OPT_fapplication_extension,
240 options::OPT_fno_application_extension,
false))
241 CmdArgs.push_back(
"-application_extension");
243 if (
D.isUsingLTO() && (Version >= VersionTuple(116) || LinkerIsLLD) &&
244 NeedsTempPath(Inputs)) {
245 std::string TmpPathName;
254 TmpPathName =
D.GetTemporaryDirectory(
"thinlto");
256 if (!TmpPathName.empty()) {
257 auto *TmpPath =
C.getArgs().MakeArgString(TmpPathName);
258 C.addTempFile(TmpPath);
259 CmdArgs.push_back(
"-object_path_lto");
260 CmdArgs.push_back(TmpPath);
273 if (Version >= VersionTuple(133) && !LinkerIsLLD) {
275 StringRef
P = llvm::sys::path::parent_path(
D.Dir);
277 llvm::sys::path::append(LibLTOPath,
"lib");
278 llvm::sys::path::append(LibLTOPath,
"libLTO.dylib");
279 CmdArgs.push_back(
"-lto_library");
280 CmdArgs.push_back(
C.getArgs().MakeArgString(LibLTOPath));
286 if (Version >= VersionTuple(262) &&
288 CmdArgs.push_back(
"-no_deduplicate");
291 Args.AddAllArgs(CmdArgs, options::OPT_static);
292 if (!Args.hasArg(options::OPT_static))
293 CmdArgs.push_back(
"-dynamic");
294 if (Args.hasArg(options::OPT_fgnu_runtime)) {
299 if (!Args.hasArg(options::OPT_dynamiclib)) {
300 AddMachOArch(Args, CmdArgs);
302 Args.AddLastArg(CmdArgs, options::OPT_force__cpusubtype__ALL);
304 Args.AddLastArg(CmdArgs, options::OPT_bundle);
305 Args.AddAllArgs(CmdArgs, options::OPT_bundle__loader);
306 Args.AddAllArgs(CmdArgs, options::OPT_client__name);
309 if ((A = Args.getLastArg(options::OPT_compatibility__version)) ||
310 (A = Args.getLastArg(options::OPT_current__version)) ||
311 (A = Args.getLastArg(options::OPT_install__name)))
312 D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
315 Args.AddLastArg(CmdArgs, options::OPT_force__flat__namespace);
316 Args.AddLastArg(CmdArgs, options::OPT_keep__private__externs);
317 Args.AddLastArg(CmdArgs, options::OPT_private__bundle);
319 CmdArgs.push_back(
"-dylib");
322 if ((A = Args.getLastArg(options::OPT_bundle)) ||
323 (A = Args.getLastArg(options::OPT_bundle__loader)) ||
324 (A = Args.getLastArg(options::OPT_client__name)) ||
325 (A = Args.getLastArg(options::OPT_force__flat__namespace)) ||
326 (A = Args.getLastArg(options::OPT_keep__private__externs)) ||
327 (A = Args.getLastArg(options::OPT_private__bundle)))
328 D.Diag(diag::err_drv_argument_not_allowed_with) << A->getAsString(Args)
331 Args.AddAllArgsTranslated(CmdArgs, options::OPT_compatibility__version,
332 "-dylib_compatibility_version");
333 Args.AddAllArgsTranslated(CmdArgs, options::OPT_current__version,
334 "-dylib_current_version");
336 AddMachOArch(Args, CmdArgs);
338 Args.AddAllArgsTranslated(CmdArgs, options::OPT_install__name,
339 "-dylib_install_name");
342 Args.AddLastArg(CmdArgs, options::OPT_all__load);
343 Args.AddAllArgs(CmdArgs, options::OPT_allowable__client);
344 Args.AddLastArg(CmdArgs, options::OPT_bind__at__load);
346 Args.AddLastArg(CmdArgs, options::OPT_arch__errors__fatal);
347 Args.AddLastArg(CmdArgs, options::OPT_dead__strip);
348 Args.AddLastArg(CmdArgs, options::OPT_no__dead__strip__inits__and__terms);
349 Args.AddAllArgs(CmdArgs, options::OPT_dylib__file);
350 Args.AddLastArg(CmdArgs, options::OPT_dynamic);
351 Args.AddAllArgs(CmdArgs, options::OPT_exported__symbols__list);
352 Args.AddLastArg(CmdArgs, options::OPT_flat__namespace);
353 Args.AddAllArgs(CmdArgs, options::OPT_force__load);
354 Args.AddAllArgs(CmdArgs, options::OPT_headerpad__max__install__names);
355 Args.AddAllArgs(CmdArgs, options::OPT_image__base);
356 Args.AddAllArgs(CmdArgs, options::OPT_init);
359 if (Version >= VersionTuple(520) || LinkerIsLLD || UsePlatformVersion)
364 Args.AddLastArg(CmdArgs, options::OPT_nomultidefs);
365 Args.AddLastArg(CmdArgs, options::OPT_multi__module);
366 Args.AddLastArg(CmdArgs, options::OPT_single__module);
367 Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined);
368 Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined__unused);
371 Args.getLastArg(options::OPT_fpie, options::OPT_fPIE,
372 options::OPT_fno_pie, options::OPT_fno_PIE)) {
373 if (A->getOption().matches(options::OPT_fpie) ||
374 A->getOption().matches(options::OPT_fPIE))
375 CmdArgs.push_back(
"-pie");
377 CmdArgs.push_back(
"-no_pie");
381 if (
C.getDriver().embedBitcodeEnabled()) {
384 CmdArgs.push_back(
"-bitcode_bundle");
386 if (
C.getDriver().embedBitcodeMarkerOnly() &&
387 Version >= VersionTuple(278)) {
388 CmdArgs.push_back(
"-bitcode_process_mode");
389 CmdArgs.push_back(
"marker");
392 D.Diag(diag::err_drv_bitcode_unsupported_on_toolchain);
396 if (Arg *A = Args.getLastArg(options::OPT_fglobal_isel,
397 options::OPT_fno_global_isel)) {
398 if (A->getOption().matches(options::OPT_fglobal_isel)) {
399 CmdArgs.push_back(
"-mllvm");
400 CmdArgs.push_back(
"-global-isel");
402 CmdArgs.push_back(
"-mllvm");
403 CmdArgs.push_back(
"-global-isel-abort=0");
407 if (Args.hasArg(options::OPT_mkernel) ||
408 Args.hasArg(options::OPT_fapple_kext) ||
409 Args.hasArg(options::OPT_ffreestanding)) {
410 CmdArgs.push_back(
"-mllvm");
411 CmdArgs.push_back(
"-disable-atexit-based-global-dtor-lowering");
414 Args.AddLastArg(CmdArgs, options::OPT_prebind);
415 Args.AddLastArg(CmdArgs, options::OPT_noprebind);
416 Args.AddLastArg(CmdArgs, options::OPT_nofixprebinding);
417 Args.AddLastArg(CmdArgs, options::OPT_prebind__all__twolevel__modules);
418 Args.AddLastArg(CmdArgs, options::OPT_read__only__relocs);
419 Args.AddAllArgs(CmdArgs, options::OPT_sectcreate);
420 Args.AddAllArgs(CmdArgs, options::OPT_sectorder);
421 Args.AddAllArgs(CmdArgs, options::OPT_seg1addr);
422 Args.AddAllArgs(CmdArgs, options::OPT_segprot);
423 Args.AddAllArgs(CmdArgs, options::OPT_segaddr);
424 Args.AddAllArgs(CmdArgs, options::OPT_segs__read__only__addr);
425 Args.AddAllArgs(CmdArgs, options::OPT_segs__read__write__addr);
426 Args.AddAllArgs(CmdArgs, options::OPT_seg__addr__table);
427 Args.AddAllArgs(CmdArgs, options::OPT_seg__addr__table__filename);
428 Args.AddAllArgs(CmdArgs, options::OPT_sub__library);
429 Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella);
435 if (
const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ)) {
436 CmdArgs.push_back(
"-syslibroot");
437 CmdArgs.push_back(A->getValue());
438 }
else if (
const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
439 CmdArgs.push_back(
"-syslibroot");
440 CmdArgs.push_back(A->getValue());
441 }
else if (StringRef sysroot =
C.getSysRoot(); sysroot !=
"") {
442 CmdArgs.push_back(
"-syslibroot");
443 CmdArgs.push_back(
C.getArgs().MakeArgString(sysroot));
446 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace);
447 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace__hints);
448 Args.AddAllArgs(CmdArgs, options::OPT_umbrella);
449 Args.AddAllArgs(CmdArgs, options::OPT_undefined);
450 Args.AddAllArgs(CmdArgs, options::OPT_unexported__symbols__list);
451 Args.AddAllArgs(CmdArgs, options::OPT_weak__reference__mismatches);
452 Args.AddLastArg(CmdArgs, options::OPT_X_Flag);
453 Args.AddAllArgs(CmdArgs, options::OPT_y);
454 Args.AddLastArg(CmdArgs, options::OPT_w);
455 Args.AddAllArgs(CmdArgs, options::OPT_pagezero__size);
456 Args.AddAllArgs(CmdArgs, options::OPT_segs__read__);
457 Args.AddLastArg(CmdArgs, options::OPT_seglinkedit);
458 Args.AddLastArg(CmdArgs, options::OPT_noseglinkedit);
459 Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
460 Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
461 Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
462 Args.AddLastArg(CmdArgs, options::OPT_why_load);
463 Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
464 Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
465 Args.AddLastArg(CmdArgs, options::OPT_dylinker);
466 Args.AddLastArg(CmdArgs, options::OPT_Mach);
472 : CSPGOGenerateArg->getValue());
473 llvm::sys::path::append(
Path,
"default_%m.profraw");
474 CmdArgs.push_back(
"--cs-profile-generate");
475 CmdArgs.push_back(Args.MakeArgString(Twine(
"--cs-profile-path=") +
Path));
478 ProfileUseArg->getNumValues() == 0 ?
"" : ProfileUseArg->getValue());
479 if (
Path.empty() || llvm::sys::fs::is_directory(
Path))
480 llvm::sys::path::append(
Path,
"default.profdata");
481 CmdArgs.push_back(Args.MakeArgString(Twine(
"--cs-profile-path=") +
Path));
484 auto *CodeGenDataGenArg =
485 Args.getLastArg(options::OPT_fcodegen_data_generate_EQ);
486 if (CodeGenDataGenArg)
488 Args.MakeArgString(Twine(
"--codegen-data-generate-path=") +
489 CodeGenDataGenArg->getValue()));
496 Args.ClaimAllArgs(options::OPT_fobjc_link_runtime);
499 return Args.hasArg(options::OPT_fobjc_link_runtime);
503 const llvm::Triple &Triple) {
508 Args.getAllArgValues(options::OPT_arch).size() > 1;
509 bool hasExplicitOutputFile =
510 Args.getLastArg(options::OPT_foptimization_record_file_EQ);
512 D.Diag(diag::err_drv_invalid_output_with_multiple_archs)
513 <<
"-foptimization-record-file";
520 const llvm::Triple &Triple,
522 StringRef Format =
"yaml";
523 if (
const Arg *A = Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
524 Format = A->getValue();
526 CmdArgs.push_back(
"-mllvm");
527 CmdArgs.push_back(
"-lto-pass-remarks-output");
528 CmdArgs.push_back(
"-mllvm");
530 const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
532 CmdArgs.push_back(A->getValue());
534 assert(Output.
isFilename() &&
"Unexpected ld output.");
540 CmdArgs.push_back(Args.MakeArgString(F));
544 Args.getLastArg(options::OPT_foptimization_record_passes_EQ)) {
545 CmdArgs.push_back(
"-mllvm");
547 std::string(
"-lto-pass-remarks-filter=") + A->getValue();
548 CmdArgs.push_back(Args.MakeArgString(Passes));
551 if (!Format.empty()) {
552 CmdArgs.push_back(
"-mllvm");
553 Twine FormatArg = Twine(
"-lto-pass-remarks-format=") + Format;
554 CmdArgs.push_back(Args.MakeArgString(FormatArg));
558 CmdArgs.push_back(
"-mllvm");
559 CmdArgs.push_back(
"-lto-pass-remarks-with-hotness");
562 Args.getLastArg(options::OPT_fdiagnostics_hotness_threshold_EQ)) {
563 CmdArgs.push_back(
"-mllvm");
565 std::string(
"-lto-pass-remarks-hotness-threshold=") + A->getValue();
566 CmdArgs.push_back(Args.MakeArgString(Opt));
577 const char *LinkingOutput)
const {
578 assert(Output.
getType() == types::TY_Image &&
"Invalid linker output type.");
584 llvm::opt::ArgStringList InputFileList;
589 ArgStringList CmdArgs;
592 if (Args.hasArg(options::OPT_ccc_arcmt_check,
593 options::OPT_ccc_arcmt_migrate)) {
594 for (
const auto &Arg : Args)
597 Args.MakeArgString(getToolChain().GetProgramPath(
"touch"));
599 C.addCommand(std::make_unique<Command>(JA, *
this,
601 CmdArgs, std::nullopt, Output));
605 VersionTuple Version = getMachOToolChain().getLinkerVersion(Args);
609 Args.MakeArgString(getToolChain().GetLinkerPath(&LinkerIsLLD));
612 bool UsePlatformVersion = getToolChain().getTriple().isXROS();
616 AddLinkArgs(
C, Args, CmdArgs, Inputs, Version, LinkerIsLLD,
621 getToolChain().getTriple()))
626 Args.getLastArg(options::OPT_moutline, options::OPT_mno_outline)) {
627 if (A->getOption().matches(options::OPT_moutline)) {
628 if (getMachOToolChain().getMachOArchName(Args) ==
"arm64") {
629 CmdArgs.push_back(
"-mllvm");
630 CmdArgs.push_back(
"-enable-machine-outliner");
636 CmdArgs.push_back(
"-mllvm");
637 CmdArgs.push_back(
"-enable-machine-outliner=never");
644 CmdArgs.push_back(
"-mllvm");
645 CmdArgs.push_back(
"-enable-linkonceodr-outlining");
648 auto *CodeGenDataGenArg =
649 Args.getLastArg(options::OPT_fcodegen_data_generate_EQ);
650 auto *CodeGenDataUseArg = Args.getLastArg(options::OPT_fcodegen_data_use_EQ);
653 const Driver &
D = getToolChain().getDriver();
654 if (CodeGenDataGenArg && CodeGenDataUseArg)
655 D.Diag(diag::err_drv_argument_not_allowed_with)
656 << CodeGenDataGenArg->getAsString(Args)
657 << CodeGenDataUseArg->getAsString(Args);
661 if (CodeGenDataGenArg) {
662 CmdArgs.push_back(
"-mllvm");
663 CmdArgs.push_back(
"-codegen-data-generate");
667 if (CodeGenDataUseArg) {
668 CmdArgs.push_back(
"-mllvm");
669 CmdArgs.push_back(Args.MakeArgString(Twine(
"-codegen-data-use-path=") +
670 CodeGenDataUseArg->getValue()));
676 if (!StatsFile.empty()) {
677 CmdArgs.push_back(
"-mllvm");
678 CmdArgs.push_back(Args.MakeArgString(
"-lto-stats-file=" + StatsFile.str()));
683 Args.addAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, options::OPT_t,
684 options::OPT_Z_Flag, options::OPT_u_Group});
689 if (Args.hasArg(options::OPT_ObjC) || Args.hasArg(options::OPT_ObjCXX))
690 CmdArgs.push_back(
"-ObjC");
692 CmdArgs.push_back(
"-o");
695 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
696 getMachOToolChain().addStartObjectFileArgs(Args, CmdArgs);
698 Args.AddAllArgs(CmdArgs, options::OPT_L);
703 for (
const auto &II : Inputs) {
704 if (!II.isFilename()) {
709 if (InputFileList.size() > 0)
715 InputFileList.push_back(II.getFilename());
720 if (getToolChain().getDriver().IsFlangMode() &&
721 !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
726 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
730 !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
732 getMachOToolChain().AddLinkARCArgs(Args, CmdArgs);
734 CmdArgs.push_back(
"-framework");
735 CmdArgs.push_back(
"Foundation");
737 CmdArgs.push_back(
"-lobjc");
741 CmdArgs.push_back(
"-arch_multiple");
742 CmdArgs.push_back(
"-final_output");
743 CmdArgs.push_back(LinkingOutput);
746 if (Args.hasArg(options::OPT_fnested_functions))
747 CmdArgs.push_back(
"-allow_stack_execute");
749 getMachOToolChain().addProfileRTLibs(Args, CmdArgs);
752 if (!Parallelism.empty()) {
753 CmdArgs.push_back(
"-mllvm");
754 unsigned NumThreads =
755 llvm::get_threadpool_strategy(Parallelism)->compute_thread_count();
756 CmdArgs.push_back(Args.MakeArgString(
"-threads=" + Twine(NumThreads)));
759 if (getToolChain().ShouldLinkCXXStdlib(Args))
760 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
762 bool NoStdOrDefaultLibs =
763 Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
764 bool ForceLinkBuiltins = Args.hasArg(options::OPT_fapple_link_rtlib);
765 if (!NoStdOrDefaultLibs || ForceLinkBuiltins) {
770 if (NoStdOrDefaultLibs && ForceLinkBuiltins) {
771 getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
"builtins");
774 getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs,
778 Args.ClaimAllArgs(options::OPT_pthread);
779 Args.ClaimAllArgs(options::OPT_pthreads);
783 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
787 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
788 Args.AddAllArgs(CmdArgs, options::OPT_F);
791 for (
const Arg *A : Args.filtered(options::OPT_iframework))
792 CmdArgs.push_back(Args.MakeArgString(std::string(
"-F") + A->getValue()));
794 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
795 if (Arg *A = Args.getLastArg(options::OPT_fveclib)) {
796 if (A->getValue() == StringRef(
"Accelerate")) {
797 CmdArgs.push_back(
"-framework");
798 CmdArgs.push_back(
"Accelerate");
807 bool NonStandardSearchPath =
false;
808 const auto &Triple = getToolChain().getTriple();
809 if (Triple.isDriverKit()) {
811 NonStandardSearchPath =
812 Version.getMajor() < 605 ||
813 (Version.getMajor() == 605 && Version.getMinor().value_or(0) < 1);
816 if (NonStandardSearchPath) {
817 if (
auto *Sysroot = Args.getLastArg(options::OPT_isysroot)) {
818 auto AddSearchPath = [&](StringRef Flag, StringRef SearchPath) {
821 llvm::sys::path::append(
P, SearchPath);
822 if (getToolChain().getVFS().exists(
P)) {
823 CmdArgs.push_back(Args.MakeArgString(Flag +
P));
826 AddSearchPath(
"-L",
"/usr/lib");
827 AddSearchPath(
"-F",
"/System/Library/Frameworks");
833 if (Version >= VersionTuple(705) || LinkerIsLLD) {
841 std::unique_ptr<Command>
Cmd = std::make_unique<Command>(
842 JA, *
this, ResponseSupport, Exec, CmdArgs, Inputs, Output);
843 Cmd->setInputFileList(std::move(InputFileList));
844 C.addCommand(std::move(
Cmd));
851 const char *LinkingOutput)
const {
852 const Driver &
D = getToolChain().getDriver();
855 Args.ClaimAllArgs(options::OPT_g_Group);
857 Args.ClaimAllArgs(options::OPT_emit_llvm);
860 Args.ClaimAllArgs(options::OPT_w);
862 Args.ClaimAllArgs(options::OPT_stdlib_EQ);
865 ArgStringList CmdArgs;
867 CmdArgs.push_back(
"-static");
868 CmdArgs.push_back(
"-D");
869 CmdArgs.push_back(
"-no_warning_for_no_symbols");
870 CmdArgs.push_back(
"-o");
873 for (
const auto &II : Inputs) {
874 if (II.isFilename()) {
875 CmdArgs.push_back(II.getFilename());
882 if (Output.
isFilename() && llvm::sys::fs::exists(OutputFileName)) {
883 if (std::error_code EC = llvm::sys::fs::remove(OutputFileName)) {
884 D.Diag(diag::err_drv_unable_to_remove_file) << EC.message();
889 const char *Exec = Args.MakeArgString(getToolChain().GetStaticLibToolPath());
890 C.addCommand(std::make_unique<Command>(JA, *
this,
892 Exec, CmdArgs, Inputs, Output));
899 const char *LinkingOutput)
const {
900 ArgStringList CmdArgs;
902 CmdArgs.push_back(
"-create");
903 assert(Output.
isFilename() &&
"Unexpected lipo output.");
905 CmdArgs.push_back(
"-output");
908 for (
const auto &II : Inputs) {
909 assert(II.isFilename() &&
"Unexpected lipo input.");
910 CmdArgs.push_back(II.getFilename());
913 const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(
"lipo"));
915 Exec, CmdArgs, Inputs, Output));
922 const char *LinkingOutput)
const {
923 ArgStringList CmdArgs;
925 CmdArgs.push_back(
"-o");
928 assert(Inputs.size() == 1 &&
"Unable to handle multiple inputs.");
930 assert(Input.
isFilename() &&
"Unexpected dsymutil input.");
934 Args.MakeArgString(getToolChain().GetProgramPath(
"dsymutil"));
936 Exec, CmdArgs, Inputs, Output));
943 const char *LinkingOutput)
const {
944 ArgStringList CmdArgs;
945 CmdArgs.push_back(
"--verify");
946 CmdArgs.push_back(
"--debug-info");
947 CmdArgs.push_back(
"--eh-frame");
948 CmdArgs.push_back(
"--quiet");
950 assert(Inputs.size() == 1 &&
"Unable to handle multiple inputs.");
952 assert(Input.
isFilename() &&
"Unexpected verify input");
958 Args.MakeArgString(getToolChain().GetProgramPath(
"dwarfdump"));
960 Exec, CmdArgs, Inputs, Output));
971 :
MachO(
D, Triple, Args), TargetInitialized(
false),
972 CudaInstallation(
D, Triple, Args), RocmInstallation(
D, Triple, Args) {}
978 if (Ty == types::TY_PP_Asm)
979 return types::TY_Asm;
999 auto T = llvm::Triple(Twine(
"arm64-apple-") +
1000 llvm::Triple::getOSTypeName(llvm::Triple::XROS) +
1022 ArgStringList &CC1Args)
const {
1027 ArgStringList &CC1Args)
const {
1036 return llvm::StringSwitch<const char *>(Arch)
1037 .Case(
"armv6k",
"armv6")
1038 .Case(
"armv6m",
"armv6m")
1039 .Case(
"armv5tej",
"armv5")
1040 .Case(
"xscale",
"xscale")
1041 .Case(
"armv4t",
"armv4t")
1042 .Case(
"armv7",
"armv7")
1043 .Cases(
"armv7a",
"armv7-a",
"armv7")
1044 .Cases(
"armv7r",
"armv7-r",
"armv7")
1045 .Cases(
"armv7em",
"armv7e-m",
"armv7em")
1046 .Cases(
"armv7k",
"armv7-k",
"armv7k")
1047 .Cases(
"armv7m",
"armv7-m",
"armv7m")
1048 .Cases(
"armv7s",
"armv7-s",
"armv7s")
1053 llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU);
1054 if (ArchKind == llvm::ARM::ArchKind::INVALID)
1056 StringRef Arch = llvm::ARM::getArchName(ArchKind);
1060 if (Arch.starts_with(
"armv5"))
1061 Arch = Arch.substr(0, 5);
1063 else if (Arch.starts_with(
"armv6") && !Arch.ends_with(
"6m"))
1064 Arch = Arch.substr(0, 5);
1066 else if (Arch.ends_with(
"v7a"))
1067 Arch = Arch.substr(0, 5);
1076 case llvm::Triple::aarch64_32:
1079 case llvm::Triple::aarch64: {
1085 case llvm::Triple::thumb:
1086 case llvm::Triple::arm:
1087 if (
const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ))
1091 if (
const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
1100 if (LinkerVersion) {
1102 VersionTuple NewLinkerVersion;
1103 if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ))
1104 (void)NewLinkerVersion.tryParse(A->getValue());
1105 assert(NewLinkerVersion == LinkerVersion);
1107 return *LinkerVersion;
1110 VersionTuple NewLinkerVersion;
1111 if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ))
1112 if (NewLinkerVersion.tryParse(A->getValue()))
1114 << A->getAsString(Args);
1116 LinkerVersion = NewLinkerVersion;
1117 return *LinkerVersion;
1131 return Triple.getTriple();
1143 Str += llvm::Triple::getOSTypeName(llvm::Triple::XROS);
1147 Triple.setOSName(Str);
1149 return Triple.getTriple();
1161 return Dsymutil.get();
1165 return VerifyDebug.get();
1182 const ArgList &Args)
1187 CC1Args.push_back(
"-Wundef-prefix=TARGET_OS_");
1188 CC1Args.push_back(
"-Werror=undef-prefix");
1194 CC1Args.push_back(
"-Wdeprecated-objc-isa-usage");
1195 CC1Args.push_back(
"-Werror=deprecated-objc-isa-usage");
1200 CC1Args.push_back(
"-Werror=implicit-function-declaration");
1208 static constexpr llvm::StringLiteral XcodeAppSuffix(
1209 ".app/Contents/Developer");
1210 size_t Index = PathIntoXcode.find(XcodeAppSuffix);
1211 if (Index == StringRef::npos)
1213 return PathIntoXcode.take_front(Index + XcodeAppSuffix.size());
1217 ArgStringList &CmdArgs)
const {
1236 llvm::sys::path::remove_filename(
P);
1237 llvm::sys::path::remove_filename(
P);
1238 llvm::sys::path::append(
P,
"lib",
"arc");
1245 auto updatePath = [&](
const Arg *A) {
1249 if (XcodePathForSDK.empty())
1252 P = XcodePathForSDK;
1253 llvm::sys::path::append(
P,
"Toolchains/XcodeDefault.xctoolchain/usr",
1258 bool updated =
false;
1259 if (
const Arg *A = Args.getLastArg(options::OPT_isysroot))
1260 updated = updatePath(A);
1263 if (
const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
1268 CmdArgs.push_back(
"-force_load");
1269 llvm::sys::path::append(
P,
"libarclite_");
1272 P +=
"watchsimulator";
1276 P +=
"appletvsimulator";
1280 P +=
"iphonesimulator";
1288 getDriver().
Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) <<
P;
1290 CmdArgs.push_back(Args.MakeArgString(
P));
1312 bool IsShared)
const {
1320 const char *LibArg = Args.MakeArgString(
P);
1321 CmdArgs.push_back(LibArg);
1329 assert(StringRef(
P).ends_with(
".dylib") &&
"must be a dynamic library");
1333 CmdArgs.push_back(
"-rpath");
1334 CmdArgs.push_back(
"@executable_path");
1338 CmdArgs.push_back(
"-rpath");
1339 CmdArgs.push_back(Args.MakeArgString(llvm::sys::path::parent_path(
P)));
1346 "it doesn't make sense to ask for the compiler-rt library name as an "
1350 if (Component !=
"builtins") {
1351 MachOLibName +=
'.';
1352 MachOLibName += Component;
1357 llvm::sys::path::append(FullPath,
"lib",
"darwin",
"macho_embedded",
1359 return std::string(FullPath);
1365 "it doesn't make sense to ask for the compiler-rt library name as an "
1369 if (Component !=
"builtins") {
1370 DarwinLibName += Component;
1371 DarwinLibName +=
'_';
1377 llvm::sys::path::append(FullPath,
"lib",
"darwin", DarwinLibName);
1378 return std::string(FullPath);
1398 llvm_unreachable(
"Unsupported platform");
1403 auto BeginSDK = llvm::sys::path::rbegin(isysroot);
1404 auto EndSDK = llvm::sys::path::rend(isysroot);
1405 for (
auto IT = BeginSDK; IT != EndSDK; ++IT) {
1406 StringRef SDK = *IT;
1407 if (SDK.ends_with(
".sdk"))
1408 return SDK.slice(0, SDK.size() - 4);
1434 llvm_unreachable(
"Unsupported platform");
1439 for (Arg *A : Args) {
1440 if (A->getOption().matches(options::OPT_exported__symbols__list))
1442 if (!A->getOption().matches(options::OPT_Wl_COMMA) &&
1443 !A->getOption().matches(options::OPT_Xlinker))
1445 if (A->containsValue(
"-exported_symbols_list") ||
1446 A->containsValue(
"-exported_symbol"))
1454 CmdArgs.push_back(
"-exported_symbol");
1455 CmdArgs.push_back(Symbol);
1465 StringRef Segment, StringRef Section) {
1466 for (
const char *A : {
"-sectalign", Args.MakeArgString(Segment),
1467 Args.MakeArgString(Section),
"0x4000"})
1468 CmdArgs.push_back(A);
1472 ArgStringList &CmdArgs)
const {
1501 for (
auto IPSK : {llvm::IPSK_cnts, llvm::IPSK_bitmap, llvm::IPSK_data}) {
1503 Args, CmdArgs,
"__DATA",
1504 llvm::getInstrProfSectionName(IPSK, llvm::Triple::MachO,
1510void DarwinClang::AddLinkSanitizerLibArgs(
const ArgList &Args,
1511 ArgStringList &CmdArgs,
1512 StringRef Sanitizer,
1513 bool Shared)
const {
1519 const ArgList &Args)
const {
1520 if (Arg* A = Args.getLastArg(options::OPT_rtlib_EQ)) {
1521 StringRef
Value = A->getValue();
1522 if (
Value !=
"compiler-rt" &&
Value !=
"platform")
1523 getDriver().
Diag(clang::diag::err_drv_unsupported_rtlib_for_platform)
1524 <<
Value <<
"darwin";
1531 ArgStringList &CmdArgs,
1532 bool ForceLinkBuiltinRT)
const {
1538 if (Args.hasArg(options::OPT_static) ||
1539 Args.hasArg(options::OPT_fapple_kext) ||
1540 Args.hasArg(options::OPT_mkernel)) {
1541 if (ForceLinkBuiltinRT)
1549 if (
const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) {
1550 getDriver().
Diag(diag::err_drv_unsupported_opt) << A->getAsString(Args);
1557 const char *sanitizer =
nullptr;
1559 sanitizer =
"UndefinedBehaviorSanitizer";
1561 sanitizer =
"RealtimeSanitizer";
1563 sanitizer =
"AddressSanitizer";
1565 sanitizer =
"ThreadSanitizer";
1568 getDriver().
Diag(diag::err_drv_unsupported_static_sanitizer_darwin)
1577 AddLinkSanitizerLibArgs(Args, CmdArgs,
"asan_abi",
false);
1580 "Static sanitizer runtimes not supported");
1581 AddLinkSanitizerLibArgs(Args, CmdArgs,
"asan");
1586 "Static sanitizer runtimes not supported");
1587 AddLinkSanitizerLibArgs(Args, CmdArgs,
"rtsan");
1590 AddLinkSanitizerLibArgs(Args, CmdArgs,
"lsan");
1593 "Static sanitizer runtimes not supported");
1594 AddLinkSanitizerLibArgs(
1600 "Static sanitizer runtimes not supported");
1601 AddLinkSanitizerLibArgs(Args, CmdArgs,
"tsan");
1604 AddLinkSanitizerLibArgs(Args, CmdArgs,
"tysan");
1605 if (Sanitize.
needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
1606 AddLinkSanitizerLibArgs(Args, CmdArgs,
"fuzzer",
false);
1613 AddLinkSanitizerLibArgs(Args, CmdArgs,
"stats");
1625 CmdArgs.push_back(
"-framework");
1626 CmdArgs.push_back(
"DriverKit");
1632 CmdArgs.push_back(
"-lSystem");
1641 CmdArgs.push_back(
"-lgcc_s.1");
1651 llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
1652 if (!SystemTriple.isMacOSX())
1653 return std::string(MacOSSDKVersion);
1654 VersionTuple SystemVersion;
1655 SystemTriple.getMacOSXVersion(SystemVersion);
1657 unsigned Major, Minor, Micro;
1661 return std::string(MacOSSDKVersion);
1662 VersionTuple SDKVersion(Major, Minor, Micro);
1664 if (SDKVersion > SystemVersion)
1665 return SystemVersion.getAsString();
1666 return std::string(MacOSSDKVersion);
1672struct DarwinPlatform {
1681 DeploymentTargetEnv,
1691 DarwinPlatformKind getPlatform()
const {
return Platform; }
1693 DarwinEnvironmentKind getEnvironment()
const {
return Environment; }
1695 void setEnvironment(DarwinEnvironmentKind
Kind) {
1697 InferSimulatorFromArch =
false;
1700 StringRef getOSVersion()
const {
1701 if (
Kind == OSVersionArg)
1702 return Argument->getValue();
1706 void setOSVersion(StringRef S) {
1707 assert(
Kind == TargetArg &&
"Unexpected kind!");
1708 OSVersion = std::string(S);
1711 bool hasOSVersion()
const {
return HasOSVersion; }
1713 VersionTuple getNativeTargetVersion()
const {
1714 assert(Environment == DarwinEnvironmentKind::MacCatalyst &&
1715 "native target version is specified only for Mac Catalyst");
1716 return NativeTargetVersion;
1720 bool isExplicitlySpecified()
const {
return Kind <= DeploymentTargetEnv; }
1723 bool canInferSimulatorFromArch()
const {
return InferSimulatorFromArch; }
1725 const std::optional<llvm::Triple> &getTargetVariantTriple()
const {
1726 return TargetVariantTriple;
1730 void addOSVersionMinArgument(DerivedArgList &Args,
const OptTable &Opts) {
1733 assert(
Kind != TargetArg &&
Kind != MTargetOSArg &&
Kind != OSVersionArg &&
1737 case DarwinPlatformKind::MacOS:
1738 Opt = options::OPT_mmacos_version_min_EQ;
1740 case DarwinPlatformKind::IPhoneOS:
1741 Opt = options::OPT_mios_version_min_EQ;
1743 case DarwinPlatformKind::TvOS:
1744 Opt = options::OPT_mtvos_version_min_EQ;
1746 case DarwinPlatformKind::WatchOS:
1747 Opt = options::OPT_mwatchos_version_min_EQ;
1749 case DarwinPlatformKind::XROS:
1752 case DarwinPlatformKind::DriverKit:
1756 Argument = Args.MakeJoinedArg(
nullptr, Opts.getOption(Opt), OSVersion);
1757 Args.append(Argument);
1762 std::string
getAsString(DerivedArgList &Args,
const OptTable &Opts) {
1767 case InferredFromSDK:
1768 case InferredFromArch:
1769 assert(Argument &&
"OS version argument not yet inferred");
1770 return Argument->getAsString(Args);
1771 case DeploymentTargetEnv:
1772 return (llvm::Twine(EnvVarName) +
"=" + OSVersion).str();
1774 llvm_unreachable(
"Unsupported Darwin Source Kind");
1777 void setEnvironment(llvm::Triple::EnvironmentType EnvType,
1778 const VersionTuple &OSVersion,
1779 const std::optional<DarwinSDKInfo> &SDKInfo) {
1781 case llvm::Triple::Simulator:
1782 Environment = DarwinEnvironmentKind::Simulator;
1784 case llvm::Triple::MacABI: {
1785 Environment = DarwinEnvironmentKind::MacCatalyst;
1787 NativeTargetVersion = VersionTuple(10, 15);
1788 if (HasOSVersion && SDKInfo) {
1789 if (
const auto *MacCatalystToMacOSMapping = SDKInfo->getVersionMapping(
1791 if (
auto MacOSVersion = MacCatalystToMacOSMapping->map(
1792 OSVersion, NativeTargetVersion, std::nullopt)) {
1793 NativeTargetVersion = *MacOSVersion;
1800 if (TargetVariantTriple) {
1801 auto TargetVariantVersion = TargetVariantTriple->getOSVersion();
1802 if (TargetVariantVersion.getMajor()) {
1803 if (TargetVariantVersion < NativeTargetVersion)
1804 NativeTargetVersion = TargetVariantVersion;
1814 static DarwinPlatform
1815 createFromTarget(
const llvm::Triple &TT, StringRef OSVersion, Arg *A,
1816 std::optional<llvm::Triple> TargetVariantTriple,
1817 const std::optional<DarwinSDKInfo> &SDKInfo) {
1818 DarwinPlatform Result(TargetArg, getPlatformFromOS(TT.getOS()), OSVersion,
1820 VersionTuple OsVersion = TT.getOSVersion();
1821 if (OsVersion.getMajor() == 0)
1822 Result.HasOSVersion =
false;
1823 Result.TargetVariantTriple = TargetVariantTriple;
1824 Result.setEnvironment(TT.getEnvironment(), OsVersion, SDKInfo);
1827 static DarwinPlatform
1828 createFromMTargetOS(llvm::Triple::OSType OS, VersionTuple OSVersion,
1829 llvm::Triple::EnvironmentType Environment, Arg *A,
1830 const std::optional<DarwinSDKInfo> &SDKInfo) {
1831 DarwinPlatform Result(MTargetOSArg, getPlatformFromOS(OS),
1832 OSVersion.getAsString(), A);
1833 Result.InferSimulatorFromArch =
false;
1834 Result.setEnvironment(Environment, OSVersion, SDKInfo);
1837 static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform, Arg *A,
1839 DarwinPlatform Result{OSVersionArg, Platform, A};
1841 Result.Environment = DarwinEnvironmentKind::Simulator;
1844 static DarwinPlatform createDeploymentTargetEnv(DarwinPlatformKind Platform,
1845 StringRef EnvVarName,
1847 DarwinPlatform Result(DeploymentTargetEnv, Platform,
Value);
1848 Result.EnvVarName = EnvVarName;
1851 static DarwinPlatform createFromSDK(DarwinPlatformKind Platform,
1853 bool IsSimulator =
false) {
1854 DarwinPlatform Result(InferredFromSDK, Platform,
Value);
1856 Result.Environment = DarwinEnvironmentKind::Simulator;
1857 Result.InferSimulatorFromArch =
false;
1860 static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
1862 return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
Value);
1869 assert(
Kind == InferredFromSDK &&
"can infer SDK info only");
1870 llvm::VersionTuple Version;
1871 bool IsValid = !Version.tryParse(OSVersion);
1873 assert(IsValid &&
"invalid SDK version");
1876 VersionTuple(Version.getMajor(), 0, 99));
1880 DarwinPlatform(SourceKind
Kind, DarwinPlatformKind Platform, Arg *Argument)
1881 :
Kind(
Kind), Platform(Platform), Argument(Argument) {}
1882 DarwinPlatform(SourceKind
Kind, DarwinPlatformKind Platform, StringRef
Value,
1883 Arg *Argument =
nullptr)
1884 :
Kind(
Kind), Platform(Platform), OSVersion(
Value), Argument(Argument) {}
1886 static DarwinPlatformKind getPlatformFromOS(llvm::Triple::OSType OS) {
1888 case llvm::Triple::Darwin:
1889 case llvm::Triple::MacOSX:
1890 return DarwinPlatformKind::MacOS;
1891 case llvm::Triple::IOS:
1892 return DarwinPlatformKind::IPhoneOS;
1893 case llvm::Triple::TvOS:
1894 return DarwinPlatformKind::TvOS;
1895 case llvm::Triple::WatchOS:
1896 return DarwinPlatformKind::WatchOS;
1897 case llvm::Triple::XROS:
1898 return DarwinPlatformKind::XROS;
1899 case llvm::Triple::DriverKit:
1900 return DarwinPlatformKind::DriverKit;
1902 llvm_unreachable(
"Unable to infer Darwin variant");
1907 DarwinPlatformKind Platform;
1908 DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
1909 VersionTuple NativeTargetVersion;
1910 std::string OSVersion;
1911 bool HasOSVersion =
true, InferSimulatorFromArch =
true;
1913 StringRef EnvVarName;
1914 std::optional<llvm::Triple> TargetVariantTriple;
1919std::optional<DarwinPlatform>
1920getDeploymentTargetFromOSVersionArg(DerivedArgList &Args,
1921 const Driver &TheDriver) {
1922 Arg *macOSVersion = Args.getLastArg(options::OPT_mmacos_version_min_EQ);
1923 Arg *iOSVersion = Args.getLastArg(options::OPT_mios_version_min_EQ,
1924 options::OPT_mios_simulator_version_min_EQ);
1926 Args.getLastArg(options::OPT_mtvos_version_min_EQ,
1927 options::OPT_mtvos_simulator_version_min_EQ);
1928 Arg *WatchOSVersion =
1929 Args.getLastArg(options::OPT_mwatchos_version_min_EQ,
1930 options::OPT_mwatchos_simulator_version_min_EQ);
1932 if (iOSVersion || TvOSVersion || WatchOSVersion) {
1933 TheDriver.
Diag(diag::err_drv_argument_not_allowed_with)
1934 << macOSVersion->getAsString(Args)
1935 << (iOSVersion ? iOSVersion
1936 : TvOSVersion ? TvOSVersion : WatchOSVersion)
1939 return DarwinPlatform::createOSVersionArg(
Darwin::MacOS, macOSVersion,
1941 }
else if (iOSVersion) {
1942 if (TvOSVersion || WatchOSVersion) {
1943 TheDriver.
Diag(diag::err_drv_argument_not_allowed_with)
1944 << iOSVersion->getAsString(Args)
1945 << (TvOSVersion ? TvOSVersion : WatchOSVersion)->
getAsString(Args);
1947 return DarwinPlatform::createOSVersionArg(
1949 iOSVersion->getOption().getID() ==
1950 options::OPT_mios_simulator_version_min_EQ);
1951 }
else if (TvOSVersion) {
1952 if (WatchOSVersion) {
1953 TheDriver.
Diag(diag::err_drv_argument_not_allowed_with)
1954 << TvOSVersion->getAsString(Args)
1955 << WatchOSVersion->getAsString(Args);
1957 return DarwinPlatform::createOSVersionArg(
1959 TvOSVersion->getOption().getID() ==
1960 options::OPT_mtvos_simulator_version_min_EQ);
1961 }
else if (WatchOSVersion)
1962 return DarwinPlatform::createOSVersionArg(
1964 WatchOSVersion->getOption().getID() ==
1965 options::OPT_mwatchos_simulator_version_min_EQ);
1966 return std::nullopt;
1971std::optional<DarwinPlatform>
1972getDeploymentTargetFromEnvironmentVariables(
const Driver &TheDriver,
1973 const llvm::Triple &Triple) {
1975 const char *EnvVars[] = {
1976 "MACOSX_DEPLOYMENT_TARGET",
1977 "IPHONEOS_DEPLOYMENT_TARGET",
1978 "TVOS_DEPLOYMENT_TARGET",
1979 "WATCHOS_DEPLOYMENT_TARGET",
1980 "DRIVERKIT_DEPLOYMENT_TARGET",
1981 "XROS_DEPLOYMENT_TARGET"
1984 "Missing platform");
1986 if (
char *
Env = ::getenv(I.value()))
1987 Targets[I.index()] =
Env;
1996 if (Triple.getArch() == llvm::Triple::arm ||
1997 Triple.getArch() == llvm::Triple::aarch64 ||
1998 Triple.getArch() == llvm::Triple::thumb)
2005 unsigned FirstTarget = std::size(Targets);
2006 for (
unsigned I = 0; I != std::size(Targets); ++I) {
2007 if (Targets[I].empty())
2009 if (FirstTarget == std::size(Targets))
2012 TheDriver.
Diag(diag::err_drv_conflicting_deployment_targets)
2013 << Targets[FirstTarget] << Targets[I];
2018 if (!
Target.value().empty())
2019 return DarwinPlatform::createDeploymentTargetEnv(
2023 return std::nullopt;
2028static StringRef dropSDKNamePrefix(StringRef SDKName) {
2029 size_t PrefixPos = SDKName.find(
'.');
2030 if (PrefixPos == StringRef::npos)
2032 return SDKName.substr(PrefixPos + 1);
2038std::optional<DarwinPlatform>
2039inferDeploymentTargetFromSDK(DerivedArgList &Args,
2040 const std::optional<DarwinSDKInfo> &SDKInfo) {
2041 const Arg *A = Args.getLastArg(options::OPT_isysroot);
2043 return std::nullopt;
2044 StringRef isysroot = A->getValue();
2047 return std::nullopt;
2049 std::string Version;
2052 Version = SDKInfo->getVersion().getAsString();
2056 size_t StartVer = SDK.find_first_of(
"0123456789");
2057 size_t EndVer = SDK.find_last_of(
"0123456789");
2058 if (StartVer != StringRef::npos && EndVer > StartVer)
2059 Version = std::string(SDK.slice(StartVer, EndVer + 1));
2061 if (Version.empty())
2062 return std::nullopt;
2064 auto CreatePlatformFromSDKName =
2065 [&](StringRef SDK) -> std::optional<DarwinPlatform> {
2066 if (SDK.starts_with(
"iPhoneOS") || SDK.starts_with(
"iPhoneSimulator"))
2067 return DarwinPlatform::createFromSDK(
2069 SDK.starts_with(
"iPhoneSimulator"));
2070 else if (SDK.starts_with(
"MacOSX"))
2073 else if (SDK.starts_with(
"WatchOS") || SDK.starts_with(
"WatchSimulator"))
2074 return DarwinPlatform::createFromSDK(
2076 SDK.starts_with(
"WatchSimulator"));
2077 else if (SDK.starts_with(
"AppleTVOS") ||
2078 SDK.starts_with(
"AppleTVSimulator"))
2079 return DarwinPlatform::createFromSDK(
2081 SDK.starts_with(
"AppleTVSimulator"));
2082 else if (SDK.starts_with(
"XR"))
2083 return DarwinPlatform::createFromSDK(
2085 SDK.contains(
"Simulator"));
2086 else if (SDK.starts_with(
"DriverKit"))
2088 return std::nullopt;
2090 if (
auto Result = CreatePlatformFromSDKName(SDK))
2093 return CreatePlatformFromSDKName(dropSDKNamePrefix(SDK));
2096std::string getOSVersion(llvm::Triple::OSType OS,
const llvm::Triple &Triple,
2097 const Driver &TheDriver) {
2098 VersionTuple OsVersion;
2099 llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
2101 case llvm::Triple::Darwin:
2102 case llvm::Triple::MacOSX:
2105 if (Triple.isMacOSX() && SystemTriple.isMacOSX() &&
2106 !Triple.getOSMajorVersion())
2107 SystemTriple.getMacOSXVersion(OsVersion);
2108 else if (!Triple.getMacOSXVersion(OsVersion))
2109 TheDriver.
Diag(diag::err_drv_invalid_darwin_version)
2110 << Triple.getOSName();
2112 case llvm::Triple::IOS:
2113 if (Triple.isMacCatalystEnvironment() && !Triple.getOSMajorVersion()) {
2114 OsVersion = VersionTuple(13, 1);
2116 OsVersion = Triple.getiOSVersion();
2118 case llvm::Triple::TvOS:
2119 OsVersion = Triple.getOSVersion();
2121 case llvm::Triple::WatchOS:
2122 OsVersion = Triple.getWatchOSVersion();
2124 case llvm::Triple::XROS:
2125 OsVersion = Triple.getOSVersion();
2126 if (!OsVersion.getMajor())
2127 OsVersion = OsVersion.withMajorReplaced(1);
2129 case llvm::Triple::DriverKit:
2130 OsVersion = Triple.getDriverKitVersion();
2133 llvm_unreachable(
"Unexpected OS type");
2137 std::string OSVersion;
2138 llvm::raw_string_ostream(OSVersion)
2139 << OsVersion.getMajor() <<
'.' << OsVersion.getMinor().value_or(0) <<
'.'
2140 << OsVersion.getSubminor().value_or(0);
2145std::optional<DarwinPlatform>
2146inferDeploymentTargetFromArch(DerivedArgList &Args,
const Darwin &Toolchain,
2147 const llvm::Triple &Triple,
2148 const Driver &TheDriver) {
2149 llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS;
2152 if (MachOArchName ==
"arm64" || MachOArchName ==
"arm64e")
2153 OSTy = llvm::Triple::MacOSX;
2154 else if (MachOArchName ==
"armv7" || MachOArchName ==
"armv7s")
2155 OSTy = llvm::Triple::IOS;
2156 else if (MachOArchName ==
"armv7k" || MachOArchName ==
"arm64_32")
2157 OSTy = llvm::Triple::WatchOS;
2158 else if (MachOArchName !=
"armv6m" && MachOArchName !=
"armv7m" &&
2159 MachOArchName !=
"armv7em")
2160 OSTy = llvm::Triple::MacOSX;
2161 if (OSTy == llvm::Triple::UnknownOS)
2162 return std::nullopt;
2163 return DarwinPlatform::createFromArch(OSTy,
2164 getOSVersion(OSTy, Triple, TheDriver));
2168std::optional<DarwinPlatform> getDeploymentTargetFromTargetArg(
2169 DerivedArgList &Args,
const llvm::Triple &Triple,
const Driver &TheDriver,
2170 const std::optional<DarwinSDKInfo> &SDKInfo) {
2171 if (!Args.hasArg(options::OPT_target))
2172 return std::nullopt;
2173 if (Triple.getOS() == llvm::Triple::Darwin ||
2174 Triple.getOS() == llvm::Triple::UnknownOS)
2175 return std::nullopt;
2176 std::string OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver);
2177 std::optional<llvm::Triple> TargetVariantTriple;
2178 for (
const Arg *A : Args.filtered(options::OPT_darwin_target_variant)) {
2179 llvm::Triple TVT(A->getValue());
2181 if ((Triple.getArch() == llvm::Triple::aarch64 ||
2182 TVT.getArchName() == Triple.getArchName()) &&
2183 TVT.getArch() == Triple.getArch() &&
2184 TVT.getSubArch() == Triple.getSubArch() &&
2185 TVT.getVendor() == Triple.getVendor()) {
2186 if (TargetVariantTriple)
2191 if ((Triple.isMacOSX() && TVT.getOS() == llvm::Triple::IOS &&
2192 TVT.isMacCatalystEnvironment()) ||
2193 (TVT.isMacOSX() && Triple.getOS() == llvm::Triple::IOS &&
2194 Triple.isMacCatalystEnvironment())) {
2195 TargetVariantTriple = TVT;
2198 TheDriver.
Diag(diag::err_drv_target_variant_invalid)
2199 << A->getSpelling() << A->getValue();
2202 return DarwinPlatform::createFromTarget(Triple, OSVersion,
2203 Args.getLastArg(options::OPT_target),
2204 TargetVariantTriple, SDKInfo);
2208std::optional<DarwinPlatform> getDeploymentTargetFromMTargetOSArg(
2209 DerivedArgList &Args,
const Driver &TheDriver,
2210 const std::optional<DarwinSDKInfo> &SDKInfo) {
2211 auto *A = Args.getLastArg(options::OPT_mtargetos_EQ);
2213 return std::nullopt;
2214 llvm::Triple TT(llvm::Twine(
"unknown-apple-") + A->getValue());
2215 switch (TT.getOS()) {
2216 case llvm::Triple::MacOSX:
2217 case llvm::Triple::IOS:
2218 case llvm::Triple::TvOS:
2219 case llvm::Triple::WatchOS:
2220 case llvm::Triple::XROS:
2223 TheDriver.
Diag(diag::err_drv_invalid_os_in_arg)
2224 << TT.getOSName() << A->getAsString(Args);
2225 return std::nullopt;
2228 VersionTuple Version = TT.getOSVersion();
2229 if (!Version.getMajor()) {
2230 TheDriver.
Diag(diag::err_drv_invalid_version_number)
2231 << A->getAsString(Args);
2232 return std::nullopt;
2234 return DarwinPlatform::createFromMTargetOS(TT.getOS(), Version,
2235 TT.getEnvironment(), A, SDKInfo);
2238std::optional<DarwinSDKInfo> parseSDKSettings(llvm::vfs::FileSystem &VFS,
2239 const ArgList &Args,
2240 const Driver &TheDriver) {
2241 const Arg *A = Args.getLastArg(options::OPT_isysroot);
2243 return std::nullopt;
2244 StringRef isysroot = A->getValue();
2246 if (!SDKInfoOrErr) {
2247 llvm::consumeError(SDKInfoOrErr.takeError());
2248 TheDriver.
Diag(diag::warn_drv_darwin_sdk_invalid_settings);
2249 return std::nullopt;
2251 return *SDKInfoOrErr;
2256void Darwin::AddDeploymentTarget(DerivedArgList &Args)
const {
2262 if (
const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
2264 if (!
getVFS().exists(A->getValue()))
2265 getDriver().
Diag(clang::diag::warn_missing_sysroot) << A->getValue();
2267 if (
char *env = ::getenv(
"SDKROOT")) {
2270 if (llvm::sys::path::is_absolute(env) &&
getVFS().exists(env) &&
2271 StringRef(env) !=
"/") {
2272 Args.append(Args.MakeSeparateArg(
2273 nullptr, Opts.getOption(options::OPT_isysroot), env));
2283 std::optional<DarwinPlatform> OSTarget =
2287 if (
const auto *MTargetOSArg = Args.getLastArg(options::OPT_mtargetos_EQ)) {
2288 std::string TargetArgStr = OSTarget->getAsString(Args, Opts);
2289 std::string MTargetOSArgStr = MTargetOSArg->getAsString(Args);
2291 << TargetArgStr << MTargetOSArgStr;
2293 std::optional<DarwinPlatform> OSVersionArgTarget =
2294 getDeploymentTargetFromOSVersionArg(Args,
getDriver());
2295 if (OSVersionArgTarget) {
2296 unsigned TargetMajor, TargetMinor, TargetMicro;
2298 unsigned ArgMajor, ArgMinor, ArgMicro;
2300 if (OSTarget->getPlatform() != OSVersionArgTarget->getPlatform() ||
2302 TargetMinor, TargetMicro, TargetExtra) &&
2304 ArgMajor, ArgMinor, ArgMicro, ArgExtra) &&
2305 (VersionTuple(TargetMajor, TargetMinor, TargetMicro) !=
2306 VersionTuple(ArgMajor, ArgMinor, ArgMicro) ||
2307 TargetExtra != ArgExtra))) {
2310 if (OSTarget->getPlatform() == OSVersionArgTarget->getPlatform() &&
2311 !OSTarget->hasOSVersion()) {
2312 OSTarget->setOSVersion(OSVersionArgTarget->getOSVersion());
2316 std::string OSVersionArg =
2317 OSVersionArgTarget->getAsString(Args, Opts);
2318 std::string TargetArg = OSTarget->getAsString(Args, Opts);
2320 << OSVersionArg << TargetArg;
2324 }
else if ((OSTarget = getDeploymentTargetFromMTargetOSArg(Args,
getDriver(),
2328 std::optional<DarwinPlatform> OSVersionArgTarget =
2329 getDeploymentTargetFromOSVersionArg(Args,
getDriver());
2330 if (OSVersionArgTarget) {
2331 std::string MTargetOSArgStr = OSTarget->getAsString(Args, Opts);
2332 std::string OSVersionArgStr = OSVersionArgTarget->getAsString(Args, Opts);
2334 << MTargetOSArgStr << OSVersionArgStr;
2338 OSTarget = getDeploymentTargetFromOSVersionArg(Args,
getDriver());
2346 std::optional<DarwinPlatform> SDKTarget =
2347 inferDeploymentTargetFromSDK(Args,
SDKInfo);
2349 OSTarget->setEnvironment(SDKTarget->getEnvironment());
2356 OSTarget = inferDeploymentTargetFromSDK(Args,
SDKInfo);
2360 SDKInfo = OSTarget->inferSDKInfo();
2369 assert(OSTarget &&
"Unable to infer Darwin variant");
2370 OSTarget->addOSVersionMinArgument(Args, Opts);
2373 unsigned Major, Minor, Micro;
2376 const unsigned MajorVersionLimit = 1000;
2378 if (Platform ==
MacOS) {
2381 HadExtra || Major < 10 || Major >= MajorVersionLimit || Minor >= 100 ||
2384 << OSTarget->getAsString(Args, Opts);
2388 HadExtra || Major >= MajorVersionLimit || Minor >= 100 || Micro >= 100)
2390 << OSTarget->getAsString(Args, Opts);
2393 (Major < 13 || (Major == 13 && Minor < 1))) {
2395 << OSTarget->getAsString(Args, Opts);
2402 if (
getTriple().isArch32Bit() && Major >= 11) {
2404 if (OSTarget->isExplicitlySpecified()) {
2406 getDriver().
Diag(diag::err_invalid_macos_32bit_deployment_target);
2409 << OSTarget->getAsString(Args, Opts);
2417 }
else if (Platform ==
TvOS) {
2420 HadExtra || Major >= MajorVersionLimit || Minor >= 100 || Micro >= 100)
2422 << OSTarget->getAsString(Args, Opts);
2423 }
else if (Platform ==
WatchOS) {
2426 HadExtra || Major >= MajorVersionLimit || Minor >= 100 || Micro >= 100)
2428 << OSTarget->getAsString(Args, Opts);
2432 HadExtra || Major < 19 || Major >= MajorVersionLimit || Minor >= 100 ||
2435 << OSTarget->getAsString(Args, Opts);
2436 }
else if (Platform ==
XROS) {
2439 HadExtra || Major < 1 || Major >= MajorVersionLimit || Minor >= 100 ||
2442 << OSTarget->getAsString(Args, Opts);
2444 llvm_unreachable(
"unknown kind of Darwin platform");
2449 Platform !=
DriverKit && OSTarget->canInferSimulatorFromArch() &&
2453 VersionTuple NativeTargetVersion;
2455 NativeTargetVersion = OSTarget->getNativeTargetVersion();
2456 setTarget(Platform, Environment, Major, Minor, Micro, NativeTargetVersion);
2459 if (
const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
2461 if (SDK.size() > 0) {
2462 size_t StartVer = SDK.find_first_of(
"0123456789");
2463 StringRef SDKName = SDK.slice(0, StartVer);
2476 const llvm::Triple &
T) {
2477 if (
T.isDriverKit()) {
2478 llvm::sys::path::append(
Path,
"System",
"DriverKit");
2485DarwinClang::GetEffectiveSysroot(
const llvm::opt::ArgList &DriverArgs)
const {
2487 if (DriverArgs.hasArg(options::OPT_isysroot))
2488 Path = DriverArgs.getLastArgValue(options::OPT_isysroot);
2499 llvm::opt::ArgStringList &CC1Args)
const {
2504 bool NoStdInc = DriverArgs.hasArg(options::OPT_nostdinc);
2505 bool NoStdlibInc = DriverArgs.hasArg(options::OPT_nostdlibinc);
2506 bool NoBuiltinInc = DriverArgs.hasFlag(
2507 options::OPT_nobuiltininc, options::OPT_ibuiltininc,
false);
2508 bool ForceBuiltinInc = DriverArgs.hasFlag(
2509 options::OPT_ibuiltininc, options::OPT_nobuiltininc,
false);
2512 if (!NoStdInc && !NoStdlibInc) {
2514 llvm::sys::path::append(
P,
"usr",
"local",
"include");
2519 if (!(NoStdInc && !ForceBuiltinInc) && !NoBuiltinInc) {
2521 llvm::sys::path::append(
P,
"include");
2525 if (NoStdInc || NoStdlibInc)
2529 llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS);
2530 if (!CIncludeDirs.empty()) {
2532 CIncludeDirs.split(dirs,
":");
2533 for (llvm::StringRef dir : dirs) {
2534 llvm::StringRef Prefix =
2535 llvm::sys::path::is_absolute(dir) ?
"" : llvm::StringRef(Sysroot);
2541 llvm::sys::path::append(
P,
"usr",
"include");
2546bool DarwinClang::AddGnuCPlusPlusIncludePaths(
const llvm::opt::ArgList &DriverArgs,
2547 llvm::opt::ArgStringList &CC1Args,
2549 llvm::StringRef Version,
2550 llvm::StringRef ArchDir,
2551 llvm::StringRef BitDir)
const {
2552 llvm::sys::path::append(
Base, Version);
2560 if (!ArchDir.empty())
2561 llvm::sys::path::append(
P, ArchDir);
2562 if (!BitDir.empty())
2563 llvm::sys::path::append(
P, BitDir);
2570 llvm::sys::path::append(
P,
"backward");
2578 const llvm::opt::ArgList &DriverArgs,
2579 llvm::opt::ArgStringList &CC1Args)
const {
2587 if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
2588 options::OPT_nostdincxx))
2609 llvm::sys::path::append(InstallBin,
"..",
"include",
"c++",
"v1");
2610 if (
getVFS().exists(InstallBin)) {
2613 }
else if (DriverArgs.hasArg(options::OPT_v)) {
2614 llvm::errs() <<
"ignoring nonexistent directory \"" << InstallBin
2620 llvm::sys::path::append(SysrootUsr,
"usr",
"include",
"c++",
"v1");
2621 if (
getVFS().exists(SysrootUsr)) {
2624 }
else if (DriverArgs.hasArg(options::OPT_v)) {
2625 llvm::errs() <<
"ignoring nonexistent directory \"" << SysrootUsr
2635 llvm::sys::path::append(UsrIncludeCxx,
"usr",
"include",
"c++");
2638 bool IsBaseFound =
true;
2642 case llvm::Triple::x86:
2643 case llvm::Triple::x86_64:
2644 IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2646 "i686-apple-darwin10",
2647 arch == llvm::Triple::x86_64 ?
"x86_64" :
"");
2648 IsBaseFound |= AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2649 "4.0.0",
"i686-apple-darwin8",
2653 case llvm::Triple::arm:
2654 case llvm::Triple::thumb:
2655 IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2657 "arm-apple-darwin10",
2659 IsBaseFound |= AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2661 "arm-apple-darwin10",
2665 case llvm::Triple::aarch64:
2666 IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2668 "arm64-apple-darwin10",
2682 ArgStringList &CmdArgs)
const {
2687 CmdArgs.push_back(
"-lc++");
2688 if (Args.hasArg(options::OPT_fexperimental_library))
2689 CmdArgs.push_back(
"-lc++experimental");
2699 if (
const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
2701 llvm::sys::path::append(
P,
"usr",
"lib",
"libstdc++.dylib");
2704 llvm::sys::path::remove_filename(
P);
2705 llvm::sys::path::append(
P,
"libstdc++.6.dylib");
2707 CmdArgs.push_back(Args.MakeArgString(
P));
2716 if (!
getVFS().exists(
"/usr/lib/libstdc++.dylib") &&
2717 getVFS().exists(
"/usr/lib/libstdc++.6.dylib")) {
2718 CmdArgs.push_back(
"/usr/lib/libstdc++.6.dylib");
2723 CmdArgs.push_back(
"-lstdc++");
2729 ArgStringList &CmdArgs)
const {
2735 llvm::sys::path::append(
P,
"lib",
"darwin");
2739 llvm::sys::path::append(
P,
"libclang_rt.cc_kext_watchos.a");
2741 llvm::sys::path::append(
P,
"libclang_rt.cc_kext_tvos.a");
2743 llvm::sys::path::append(
P,
"libclang_rt.cc_kext_ios.a");
2747 llvm::sys::path::append(
2748 P, llvm::Twine(
"libclang_rt.cc_kext_") +
2749 llvm::Triple::getOSTypeName(llvm::Triple::XROS) +
".a");
2751 llvm::sys::path::append(
P,
"libclang_rt.cc_kext.a");
2757 CmdArgs.push_back(Args.MakeArgString(
P));
2761 StringRef BoundArch,
2763 DerivedArgList *DAL =
new DerivedArgList(Args.getBaseArgs());
2773 for (Arg *A : Args) {
2774 if (A->getOption().matches(options::OPT_Xarch__)) {
2777 StringRef XarchArch = A->getValue(0);
2779 (!BoundArch.empty() && XarchArch == BoundArch)))
2782 Arg *OriginalArg = A;
2790 for (
const char *
Value : A->getValues()) {
2791 DAL->AddSeparateArg(
2792 OriginalArg, Opts.getOption(options::OPT_Zlinker_input),
Value);
2806 case options::OPT_mkernel:
2807 case options::OPT_fapple_kext:
2809 DAL->AddFlagArg(A, Opts.getOption(options::OPT_static));
2812 case options::OPT_dependency_file:
2813 DAL->AddSeparateArg(A, Opts.getOption(options::OPT_MF), A->getValue());
2816 case options::OPT_gfull:
2817 DAL->AddFlagArg(A, Opts.getOption(options::OPT_g_Flag));
2819 A, Opts.getOption(options::OPT_fno_eliminate_unused_debug_symbols));
2822 case options::OPT_gused:
2823 DAL->AddFlagArg(A, Opts.getOption(options::OPT_g_Flag));
2825 A, Opts.getOption(options::OPT_feliminate_unused_debug_symbols));
2828 case options::OPT_shared:
2829 DAL->AddFlagArg(A, Opts.getOption(options::OPT_dynamiclib));
2832 case options::OPT_fconstant_cfstrings:
2833 DAL->AddFlagArg(A, Opts.getOption(options::OPT_mconstant_cfstrings));
2836 case options::OPT_fno_constant_cfstrings:
2837 DAL->AddFlagArg(A, Opts.getOption(options::OPT_mno_constant_cfstrings));
2840 case options::OPT_Wnonportable_cfstrings:
2842 Opts.getOption(options::OPT_mwarn_nonportable_cfstrings));
2845 case options::OPT_Wno_nonportable_cfstrings:
2847 A, Opts.getOption(options::OPT_mno_warn_nonportable_cfstrings));
2854 if (!BoundArch.empty()) {
2855 StringRef Name = BoundArch;
2856 const Option MCpu = Opts.getOption(options::OPT_mcpu_EQ);
2857 const Option MArch = Opts.getOption(clang::driver::options::OPT_march_EQ);
2863 else if (Name ==
"ppc601")
2864 DAL->AddJoinedArg(
nullptr, MCpu,
"601");
2865 else if (Name ==
"ppc603")
2866 DAL->AddJoinedArg(
nullptr, MCpu,
"603");
2867 else if (Name ==
"ppc604")
2868 DAL->AddJoinedArg(
nullptr, MCpu,
"604");
2869 else if (Name ==
"ppc604e")
2870 DAL->AddJoinedArg(
nullptr, MCpu,
"604e");
2871 else if (Name ==
"ppc750")
2872 DAL->AddJoinedArg(
nullptr, MCpu,
"750");
2873 else if (Name ==
"ppc7400")
2874 DAL->AddJoinedArg(
nullptr, MCpu,
"7400");
2875 else if (Name ==
"ppc7450")
2876 DAL->AddJoinedArg(
nullptr, MCpu,
"7450");
2877 else if (Name ==
"ppc970")
2878 DAL->AddJoinedArg(
nullptr, MCpu,
"970");
2880 else if (Name ==
"ppc64" || Name ==
"ppc64le")
2881 DAL->AddFlagArg(
nullptr, Opts.getOption(options::OPT_m64));
2883 else if (Name ==
"i386")
2885 else if (Name ==
"i486")
2886 DAL->AddJoinedArg(
nullptr, MArch,
"i486");
2887 else if (Name ==
"i586")
2888 DAL->AddJoinedArg(
nullptr, MArch,
"i586");
2889 else if (Name ==
"i686")
2890 DAL->AddJoinedArg(
nullptr, MArch,
"i686");
2891 else if (Name ==
"pentium")
2892 DAL->AddJoinedArg(
nullptr, MArch,
"pentium");
2893 else if (Name ==
"pentium2")
2894 DAL->AddJoinedArg(
nullptr, MArch,
"pentium2");
2895 else if (Name ==
"pentpro")
2896 DAL->AddJoinedArg(
nullptr, MArch,
"pentiumpro");
2897 else if (Name ==
"pentIIm3")
2898 DAL->AddJoinedArg(
nullptr, MArch,
"pentium2");
2900 else if (Name ==
"x86_64" || Name ==
"x86_64h")
2901 DAL->AddFlagArg(
nullptr, Opts.getOption(options::OPT_m64));
2903 else if (Name ==
"arm")
2904 DAL->AddJoinedArg(
nullptr, MArch,
"armv4t");
2905 else if (Name ==
"armv4t")
2906 DAL->AddJoinedArg(
nullptr, MArch,
"armv4t");
2907 else if (Name ==
"armv5")
2908 DAL->AddJoinedArg(
nullptr, MArch,
"armv5tej");
2909 else if (Name ==
"xscale")
2910 DAL->AddJoinedArg(
nullptr, MArch,
"xscale");
2911 else if (Name ==
"armv6")
2912 DAL->AddJoinedArg(
nullptr, MArch,
"armv6k");
2913 else if (Name ==
"armv6m")
2914 DAL->AddJoinedArg(
nullptr, MArch,
"armv6m");
2915 else if (Name ==
"armv7")
2916 DAL->AddJoinedArg(
nullptr, MArch,
"armv7a");
2917 else if (Name ==
"armv7em")
2918 DAL->AddJoinedArg(
nullptr, MArch,
"armv7em");
2919 else if (Name ==
"armv7k")
2920 DAL->AddJoinedArg(
nullptr, MArch,
"armv7k");
2921 else if (Name ==
"armv7m")
2922 DAL->AddJoinedArg(
nullptr, MArch,
"armv7m");
2923 else if (Name ==
"armv7s")
2924 DAL->AddJoinedArg(
nullptr, MArch,
"armv7s");
2931 ArgStringList &CmdArgs,
2932 bool ForceLinkBuiltinRT)
const {
2941 CompilerRT += Args.hasArg(options::OPT_fPIC) ?
"_pic" :
"_static";
2947 llvm::Triple::OSType OS;
2953 OS = llvm::Triple::MacOSX;
2956 OS = llvm::Triple::IOS;
2959 OS = llvm::Triple::TvOS;
2962 OS = llvm::Triple::WatchOS;
2976 const std::optional<DarwinSDKInfo> &SDKInfo) {
2996 VersionTuple SDKVersion = SDKInfo->getVersion();
2997 switch (TargetPlatform) {
3001 return SDKVersion >= VersionTuple(15U);
3003 switch (TargetEnvironment) {
3008 return SDKVersion >= VersionTuple(15U);
3010 return SDKVersion >= VersionTuple(18U);
3013 return SDKVersion >= VersionTuple(18U);
3015 return SDKVersion >= VersionTuple(11U);
3017 return SDKVersion >= VersionTuple(2U);
3025static inline llvm::VersionTuple
3030 case llvm::Triple::Darwin:
3031 case llvm::Triple::MacOSX:
3032 return llvm::VersionTuple(10U, 12U);
3033 case llvm::Triple::IOS:
3034 case llvm::Triple::TvOS:
3035 return llvm::VersionTuple(10U);
3036 case llvm::Triple::WatchOS:
3037 return llvm::VersionTuple(3U);
3040 llvm_unreachable(
"Unexpected OS");
3044 llvm::Triple::OSType OS;
3050 OS = llvm::Triple::MacOSX;
3053 OS = llvm::Triple::IOS;
3056 OS = llvm::Triple::TvOS;
3059 OS = llvm::Triple::WatchOS;
3071 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
3075 if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation,
3076 options::OPT_fno_aligned_allocation) &&
3078 CC1Args.push_back(
"-faligned-alloc-unavailable");
3082 if (!DriverArgs.hasArgNoClaim(options::OPT_fsized_deallocation,
3083 options::OPT_fno_sized_deallocation) &&
3085 CC1Args.push_back(
"-fno-sized-deallocation");
3091 CC1Args.push_back(
"-fcompatibility-qualified-id-block-type-checking");
3095 if (!DriverArgs.getLastArgNoClaim(
3096 options::OPT_fvisibility_inlines_hidden_static_local_var,
3097 options::OPT_fno_visibility_inlines_hidden_static_local_var))
3098 CC1Args.push_back(
"-fvisibility-inlines-hidden-static-local-var");
3112 CC1Args.push_back(
"-fbuiltin-headers-in-system-modules");
3114 if (!DriverArgs.hasArgNoClaim(options::OPT_fdefine_target_os_macros,
3115 options::OPT_fno_define_target_os_macros))
3116 CC1Args.push_back(
"-fdefine-target-os-macros");
3120 !DriverArgs.hasFlag(options::OPT_fmodulemap_allow_subdirectory_search,
3121 options::OPT_fno_modulemap_allow_subdirectory_search,
3123 bool RequiresSubdirectorySearch;
3124 VersionTuple SDKVersion =
SDKInfo->getVersion();
3127 RequiresSubdirectorySearch =
true;
3130 RequiresSubdirectorySearch = SDKVersion < VersionTuple(15, 0);
3134 RequiresSubdirectorySearch = SDKVersion < VersionTuple(18, 0);
3137 RequiresSubdirectorySearch = SDKVersion < VersionTuple(11, 0);
3140 RequiresSubdirectorySearch = SDKVersion < VersionTuple(2, 0);
3143 if (!RequiresSubdirectorySearch)
3144 CC1Args.push_back(
"-fno-modulemap-allow-subdirectory-search");
3149 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1ASArgs)
const {
3151 CC1ASArgs.push_back(
"-darwin-target-variant-triple");
3158 auto EmitTargetSDKVersionArg = [&](
const VersionTuple &
V) {
3160 llvm::raw_string_ostream OS(Arg);
3161 OS <<
"-target-sdk-version=" <<
V;
3162 CC1ASArgs.push_back(Args.MakeArgString(Arg));
3166 if (
const auto *MacOStoMacCatalystMapping =
SDKInfo->getVersionMapping(
3168 std::optional<VersionTuple> SDKVersion = MacOStoMacCatalystMapping->map(
3171 EmitTargetSDKVersionArg(
3175 EmitTargetSDKVersionArg(
SDKInfo->getVersion());
3183 llvm::raw_string_ostream OS(Arg);
3184 OS <<
"-darwin-target-variant-sdk-version=" <<
SDKInfo->getVersion();
3185 CC1ASArgs.push_back(Args.MakeArgString(Arg));
3186 }
else if (
const auto *MacOStoMacCatalystMapping =
3189 if (std::optional<VersionTuple> SDKVersion =
3190 MacOStoMacCatalystMapping->map(
3194 llvm::raw_string_ostream OS(Arg);
3195 OS <<
"-darwin-target-variant-sdk-version=" << *SDKVersion;
3196 CC1ASArgs.push_back(Args.MakeArgString(Arg));
3207 DerivedArgList *DAL =
3211 if (BoundArch.empty())
3217 AddDeploymentTarget(*DAL);
3225 for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie; ) {
3228 if (A->getOption().getID() != options::OPT_mkernel &&
3229 A->getOption().getID() != options::OPT_fapple_kext)
3231 assert(it != ie &&
"unexpected argument translation");
3233 assert(A->getOption().getID() == options::OPT_static &&
3234 "missing expected -static argument");
3241 if ((Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)) {
3242 if (Args.hasFlag(options::OPT_fomit_frame_pointer,
3243 options::OPT_fno_omit_frame_pointer,
false))
3244 getDriver().
Diag(clang::diag::warn_drv_unsupported_opt_for_target)
3245 <<
"-fomit-frame-pointer" << BoundArch;
3254 if (
getArch() == llvm::Triple::x86_64 ||
3256 Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
3258 return (
getArch() == llvm::Triple::aarch64 ||
3259 getArch() == llvm::Triple::aarch64_32)
3267 if (
const char *S = ::getenv(
"RC_DEBUG_OPTIONS"))
3268 return S[0] !=
'\0';
3273 if (
const char *S = ::getenv(
"RC_DEBUG_PREFIX_MAP"))
3282 return llvm::ExceptionHandling::None;
3286 if (Triple.isWatchABI())
3287 return llvm::ExceptionHandling::DwarfCFI;
3289 return llvm::ExceptionHandling::SjLj;
3304 return (
getArch() == llvm::Triple::x86_64 ||
3305 getArch() == llvm::Triple::aarch64);
3314 ArgStringList &CmdArgs)
const {
3317 assert(!
isTargetXROS() &&
"xrOS always uses -platform-version");
3320 CmdArgs.push_back(
"-watchos_version_min");
3322 CmdArgs.push_back(
"-watchos_simulator_version_min");
3324 CmdArgs.push_back(
"-tvos_version_min");
3326 CmdArgs.push_back(
"-tvos_simulator_version_min");
3328 CmdArgs.push_back(
"-driverkit_version_min");
3330 CmdArgs.push_back(
"-ios_simulator_version_min");
3332 CmdArgs.push_back(
"-iphoneos_version_min");
3334 CmdArgs.push_back(
"-maccatalyst_version_min");
3337 CmdArgs.push_back(
"-macosx_version_min");
3343 CmdArgs.push_back(Args.MakeArgString(
TargetVersion.getAsString()));
3346 VersionTuple VariantTargetVersion;
3348 CmdArgs.push_back(
"-macosx_version_min");
3353 "unexpected target variant triple");
3354 CmdArgs.push_back(
"-maccatalyst_version_min");
3357 VersionTuple MinTgtVers =
3359 if (MinTgtVers.getMajor() && MinTgtVers > VariantTargetVersion)
3360 VariantTargetVersion = MinTgtVers;
3361 CmdArgs.push_back(Args.MakeArgString(VariantTargetVersion.getAsString()));
3372 return "mac catalyst";
3383 llvm_unreachable(
"invalid platform");
3387 llvm::opt::ArgStringList &CmdArgs)
const {
3388 auto EmitPlatformVersionArg =
3391 const llvm::Triple &TT) {
3394 CmdArgs.push_back(
"-platform_version");
3395 std::string PlatformName =
3398 PlatformName +=
"-simulator";
3399 CmdArgs.push_back(Args.MakeArgString(PlatformName));
3408 VersionTuple MinTgtVers = TT.getMinimumSupportedOSVersion();
3411 CmdArgs.push_back(Args.MakeArgString(
TargetVersion.getAsString()));
3416 std::optional<VersionTuple> iOSSDKVersion;
3418 if (
const auto *MacOStoMacCatalystMapping =
3421 iOSSDKVersion = MacOStoMacCatalystMapping->map(
3422 SDKInfo->getVersion().withoutBuild(),
3426 CmdArgs.push_back(Args.MakeArgString(
3427 (iOSSDKVersion ? *iOSSDKVersion
3434 VersionTuple SDKVersion =
SDKInfo->getVersion().withoutBuild();
3435 if (!SDKVersion.getMinor())
3436 SDKVersion = VersionTuple(SDKVersion.getMajor(), 0);
3437 CmdArgs.push_back(Args.MakeArgString(SDKVersion.getAsString()));
3448 CmdArgs.push_back(Args.MakeArgString(
TargetVersion.getAsString()));
3457 VersionTuple TargetVariantVersion;
3465 "unexpected target variant triple");
3470 EmitPlatformVersionArg(TargetVariantVersion, Platform, Environment,
3476 ArgStringList &CmdArgs) {
3478 if (
D.isTargetIPhoneOS()) {
3479 if (
D.isIPhoneOSVersionLT(3, 1))
3480 CmdArgs.push_back(
"-ldylib1.o");
3484 if (!
D.isTargetMacOS())
3486 if (
D.isMacosxVersionLT(10, 5))
3487 CmdArgs.push_back(
"-ldylib1.o");
3488 else if (
D.isMacosxVersionLT(10, 6))
3489 CmdArgs.push_back(
"-ldylib1.10.5.o");
3494 ArgStringList &CmdArgs) {
3495 if (Args.hasArg(options::OPT_static))
3498 if ((
D.isTargetIPhoneOS() &&
D.isIPhoneOSVersionLT(3, 1)) ||
3499 (
D.isTargetMacOS() &&
D.isMacosxVersionLT(10, 6)))
3500 CmdArgs.push_back(
"-lbundle1.o");
3505 ArgStringList &CmdArgs) {
3506 if (
D.isTargetMacOS() &&
D.isMacosxVersionLT(10, 9)) {
3507 if (Args.hasArg(options::OPT_static) || Args.hasArg(options::OPT_object) ||
3508 Args.hasArg(options::OPT_preload)) {
3509 CmdArgs.push_back(
"-lgcrt0.o");
3511 CmdArgs.push_back(
"-lgcrt1.o");
3520 if (!
D.isMacosxVersionLT(10, 8))
3521 CmdArgs.push_back(
"-no_new_main");
3523 D.getDriver().Diag(diag::err_drv_clang_unsupported_opt_pg_darwin)
3524 <<
D.isTargetMacOSBased();
3529 ArgStringList &CmdArgs) {
3531 if (
D.isTargetIPhoneOS()) {
3532 if (
D.getArch() == llvm::Triple::aarch64)
3534 else if (
D.isIPhoneOSVersionLT(3, 1))
3535 CmdArgs.push_back(
"-lcrt1.o");
3536 else if (
D.isIPhoneOSVersionLT(6, 0))
3537 CmdArgs.push_back(
"-lcrt1.3.1.o");
3541 if (!
D.isTargetMacOS())
3543 if (
D.isMacosxVersionLT(10, 5))
3544 CmdArgs.push_back(
"-lcrt1.o");
3545 else if (
D.isMacosxVersionLT(10, 6))
3546 CmdArgs.push_back(
"-lcrt1.10.5.o");
3547 else if (
D.isMacosxVersionLT(10, 8))
3548 CmdArgs.push_back(
"-lcrt1.10.6.o");
3553 ArgStringList &CmdArgs)
const {
3555 if (Args.hasArg(options::OPT_dynamiclib))
3557 else if (Args.hasArg(options::OPT_bundle))
3561 else if (Args.hasArg(options::OPT_static) ||
3562 Args.hasArg(options::OPT_object) ||
3563 Args.hasArg(options::OPT_preload))
3564 CmdArgs.push_back(
"-lcrt0.o");
3568 if (
isTargetMacOS() && Args.hasArg(options::OPT_shared_libgcc) &&
3570 const char *Str = Args.MakeArgString(
GetFilePath(
"crt3.o"));
3571 CmdArgs.push_back(Str);
3583 const bool IsX86_64 =
getTriple().getArch() == llvm::Triple::x86_64;
3584 const bool IsAArch64 =
getTriple().getArch() == llvm::Triple::aarch64;
3586 Res |= SanitizerKind::Address;
3587 Res |= SanitizerKind::PointerCompare;
3588 Res |= SanitizerKind::PointerSubtract;
3589 Res |= SanitizerKind::Realtime;
3590 Res |= SanitizerKind::Leak;
3591 Res |= SanitizerKind::Fuzzer;
3592 Res |= SanitizerKind::FuzzerNoLink;
3593 Res |= SanitizerKind::ObjCCast;
3600 Res |= SanitizerKind::Vptr;
3602 if ((IsX86_64 || IsAArch64) &&
3605 Res |= SanitizerKind::Thread;
3609 Res |= SanitizerKind::Type;
3613 Res |= SanitizerKind::NumericalStability;
Defines a function that returns the minimum OS versions supporting C++17's aligned allocation functio...
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
static bool hasMultipleInvocations(const llvm::Triple &Triple, const ArgList &Args)
static bool checkRemarksOptions(const Driver &D, const ArgList &Args, const llvm::Triple &Triple)
static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple, const InputInfo &Input, const InputInfo &Output, const JobAction &JA)
static void addPgProfilingLinkArgs(const Darwin &D, const ArgList &Args, ArgStringList &CmdArgs)
static const char * ArmMachOArchName(StringRef Arch)
static bool shouldLinkerNotDedup(bool IsLinkerOnlyAction, const ArgList &Args)
Pass -no_deduplicate to ld64 under certain conditions:
static bool hasExportSymbolDirective(const ArgList &Args)
Check if the link command contains a symbol export directive.
static void addDefaultCRTLinkArgs(const Darwin &D, const ArgList &Args, ArgStringList &CmdArgs)
static void addBundleLinkArgs(const Darwin &D, const ArgList &Args, ArgStringList &CmdArgs)
static llvm::VersionTuple sizedDeallocMinVersion(llvm::Triple::OSType OS)
static VersionTuple minimumMacCatalystDeploymentTarget()
static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion)
Returns the most appropriate macOS target version for the current process.
static bool sdkSupportsBuiltinModules(const Darwin::DarwinPlatformKind &TargetPlatform, const Darwin::DarwinEnvironmentKind &TargetEnvironment, const std::optional< DarwinSDKInfo > &SDKInfo)
static void addDynamicLibLinkArgs(const Darwin &D, const ArgList &Args, ArgStringList &CmdArgs)
static void AppendPlatformPrefix(SmallString< 128 > &Path, const llvm::Triple &T)
static bool isObjCRuntimeLinked(const ArgList &Args)
Determine whether we are linking the ObjC runtime.
static const char * getPlatformName(Darwin::DarwinPlatformKind Platform, Darwin::DarwinEnvironmentKind Environment)
static const char * ArmMachOArchNameCPU(StringRef CPU)
static void addExportedSymbol(ArgStringList &CmdArgs, const char *Symbol)
Add an export directive for Symbol to the link command.
static StringRef getXcodeDeveloperPath(StringRef PathIntoXcode)
Take a path that speculatively points into Xcode and return the XCODE/Contents/Developer path if it i...
static void addSectalignToPage(const ArgList &Args, ArgStringList &CmdArgs, StringRef Segment, StringRef Section)
Add a sectalign directive for Segment and Section to the maximum expected page size for Darwin.
llvm::MachO::Target Target
Defines types useful for describing an Objective-C runtime.
The information about the darwin SDK that was used during this compilation.
The basic abstraction for the target Objective-C runtime.
bool hasNativeARC() const
Does this runtime natively provide the ARC entrypoints?
bool hasSubscripting() const
Does this runtime directly support the subscripting methods?
@ MacOSX
'macosx' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the non-fragile AB...
@ FragileMacOSX
'macosx-fragile' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the fragil...
@ iOS
'ios' is the Apple-provided NeXT-derived runtime on iOS or the iOS simulator; it is always non-fragil...
@ WatchOS
'watchos' is a variant of iOS for Apple's watchOS.
The base class of the type hierarchy.
Action - Represent an abstract compilation step to perform.
types::ID getType() const
ActionClass getKind() const
@ VerifyDebugInfoJobClass
Compilation - A set of tasks to perform for a single driver invocation.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
std::string SysRoot
sysroot, if present
DiagnosticBuilder Diag(unsigned DiagID) const
static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra)
GetReleaseVersion - Parse (([0-9]+)(.
const llvm::opt::OptTable & getOpts() const
bool needsStatsRt() const
bool linkRuntimes() const
bool needsUbsanRt() const
bool needsRtsanRt() const
bool requiresMinimalRuntime() const
bool needsSharedRt() const
bool needsTysanRt() const
bool needsStableAbi() const
const char * getTypeTempSuffix(ID Id, bool CLStyle=false)
getTypeTempSuffix - Return the suffix to use when creating a temp file of this type,...
bool willEmitRemarks(const llvm::opt::ArgList &Args)
The JSON file list parser is used to communicate input to InstallAPI.
Expected< std::optional< DarwinSDKInfo > > parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath)
Parse the SDK information from the SDKSettings.json file.
@ Result
The result type of a method or function.
llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS)
const FunctionProtoType * T
llvm::StringRef getAsString(SyncScope S)
static constexpr OSEnvPair macCatalystToMacOSPair()
Returns the os-environment mapping pair that's used to represent the Mac Catalyst -> macOS version ma...
static constexpr OSEnvPair macOStoMacCatalystPair()
Returns the os-environment mapping pair that's used to represent the macOS -> Mac Catalyst version ma...
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
static constexpr ResponseFileSupport AtFileUTF8()