clang 24.0.0git
Darwin.h
Go to the documentation of this file.
1//===--- Darwin.h - Darwin 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#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H
11
18#include "clang/Driver/Tool.h"
21
22namespace clang {
23namespace driver {
24
25namespace toolchains {
26class MachO;
27} // end namespace toolchains
28
29namespace tools {
30
31namespace darwin {
32llvm::Triple::ArchType getArchTypeForMachOArchName(StringRef Str);
33void setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str,
34 const llvm::opt::ArgList &Args);
35
36class LLVM_LIBRARY_VISIBILITY MachOTool : public Tool {
37 virtual void anchor();
38
39protected:
40 void AddMachOArch(const llvm::opt::ArgList &Args,
41 llvm::opt::ArgStringList &CmdArgs) const;
42 void AddMachOArchOnly(const llvm::opt::ArgList &Args,
43 llvm::opt::ArgStringList &CmdArgs) const;
44
46 return reinterpret_cast<const toolchains::MachO &>(getToolChain());
47 }
48
49public:
50 MachOTool(const char *Name, const char *ShortName, const ToolChain &TC)
51 : Tool(Name, ShortName, TC) {}
52};
53
54class LLVM_LIBRARY_VISIBILITY Assembler : public MachOTool {
55public:
57 : MachOTool("darwin::Assembler", "assembler", TC) {}
58
59 bool hasIntegratedCPP() const override { return false; }
60
61 void ConstructJob(Compilation &C, const JobAction &JA,
62 const InputInfo &Output, const InputInfoList &Inputs,
63 const llvm::opt::ArgList &TCArgs,
64 const char *LinkingOutput) const override;
65};
66
67class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
68 bool NeedsTempPath(const InputInfoList &Inputs) const;
69 void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args,
70 llvm::opt::ArgStringList &CmdArgs,
71 const InputInfoList &Inputs, VersionTuple Version,
72 bool LinkerIsLLD, bool UsePlatformVersion) const;
73
74public:
75 Linker(const ToolChain &TC) : MachOTool("darwin::Linker", "linker", TC) {}
76
77 bool hasIntegratedCPP() const override { return false; }
78 bool isLinkJob() const override { return true; }
79
80 void ConstructJob(Compilation &C, const JobAction &JA,
81 const InputInfo &Output, const InputInfoList &Inputs,
82 const llvm::opt::ArgList &TCArgs,
83 const char *LinkingOutput) const override;
84};
85
86class LLVM_LIBRARY_VISIBILITY StaticLibTool : public MachOTool {
87public:
89 : MachOTool("darwin::StaticLibTool", "static-lib-linker", TC) {}
90
91 bool hasIntegratedCPP() const override { return false; }
92 bool isLinkJob() const override { return true; }
93
94 void ConstructJob(Compilation &C, const JobAction &JA,
95 const InputInfo &Output, const InputInfoList &Inputs,
96 const llvm::opt::ArgList &TCArgs,
97 const char *LinkingOutput) const override;
98};
99
100class LLVM_LIBRARY_VISIBILITY Lipo : public MachOTool {
101public:
102 Lipo(const ToolChain &TC) : MachOTool("darwin::Lipo", "lipo", TC) {}
103
104 bool hasIntegratedCPP() const override { return false; }
105
106 void ConstructJob(Compilation &C, const JobAction &JA,
107 const InputInfo &Output, const InputInfoList &Inputs,
108 const llvm::opt::ArgList &TCArgs,
109 const char *LinkingOutput) const override;
110};
111
112class LLVM_LIBRARY_VISIBILITY Dsymutil : public MachOTool {
113public:
115 : MachOTool("darwin::Dsymutil", "dsymutil", TC) {}
116
117 bool hasIntegratedCPP() const override { return false; }
118 bool isDsymutilJob() const override { return true; }
119
120 void ConstructJob(Compilation &C, const JobAction &JA,
121 const InputInfo &Output, const InputInfoList &Inputs,
122 const llvm::opt::ArgList &TCArgs,
123 const char *LinkingOutput) const override;
124};
125
126class LLVM_LIBRARY_VISIBILITY VerifyDebug : public MachOTool {
127public:
129 : MachOTool("darwin::VerifyDebug", "dwarfdump", TC) {}
130
131 bool hasIntegratedCPP() const override { return false; }
132
133 void ConstructJob(Compilation &C, const JobAction &JA,
134 const InputInfo &Output, const InputInfoList &Inputs,
135 const llvm::opt::ArgList &TCArgs,
136 const char *LinkingOutput) const override;
137};
138} // end namespace darwin
139} // end namespace tools
140
141namespace toolchains {
142
143class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
144protected:
145 Tool *buildAssembler() const override;
146 Tool *buildLinker() const override;
147 Tool *buildStaticLibTool() const override;
148 Tool *getTool(Action::ActionClass AC) const override;
149
150 void
151 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
152 llvm::opt::ArgStringList &CC1Args, BoundArch BA,
153 Action::OffloadKind DeviceOffloadKind) const override;
154
155private:
156 mutable std::unique_ptr<tools::darwin::Lipo> Lipo;
157 mutable std::unique_ptr<tools::darwin::Dsymutil> Dsymutil;
158 mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
159
160 /// The version of the linker known to be available in the tool chain.
161 mutable std::optional<VersionTuple> LinkerVersion;
162
163public:
164 MachO(const Driver &D, const llvm::Triple &Triple,
165 const llvm::opt::ArgList &Args);
166 ~MachO() override;
167
168 /// @name MachO specific toolchain API
169 /// {
170
171 /// Get the "MachO" arch name for a particular compiler invocation. For
172 /// example, Apple treats different ARM variations as distinct architectures.
173 StringRef getMachOArchName(const llvm::opt::ArgList &Args) const;
174
175 /// Get the version of the linker known to be available for a particular
176 /// compiler invocation (via the `-mlinker-version=` arg).
177 VersionTuple getLinkerVersion(const llvm::opt::ArgList &Args) const;
178
179 /// Add the linker arguments to link the ARC runtime library.
180 virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args,
181 llvm::opt::ArgStringList &CmdArgs) const {}
182
183 /// Add the linker arguments to link the compiler runtime library.
184 ///
185 /// FIXME: This API is intended for use with embedded libraries only, and is
186 /// misleadingly named.
187 virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
188 llvm::opt::ArgStringList &CmdArgs,
189 bool ForceLinkBuiltinRT = false) const;
190
191 virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
192 llvm::opt::ArgStringList &CmdArgs) const {
193 }
194
195 virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
196 llvm::opt::ArgStringList &CmdArgs) const {}
197
198 virtual void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
199 llvm::opt::ArgStringList &CmdArgs) const {
200 }
201
202 virtual bool HasPlatformPrefix(const llvm::Triple &T) const { return false; }
203
205 const llvm::Triple &T) const {}
206
207 /// On some iOS platforms, kernel and kernel modules were built statically. Is
208 /// this such a target?
209 virtual bool isKernelStatic() const { return false; }
210
211 /// Is the target either iOS or an iOS simulator?
212 bool isTargetIOSBased() const { return false; }
213
214 /// Options to control how a runtime library is linked.
215 enum RuntimeLinkOptions : unsigned {
216 /// Link the library in even if it can't be found in the VFS.
218
219 /// Use the embedded runtime from the macho_embedded directory.
221
222 /// Emit rpaths for @executable_path as well as the resource directory.
223 RLO_AddRPath = 1 << 2,
224 };
225
226 /// Add a runtime library to the list of items to link.
227 void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
228 llvm::opt::ArgStringList &CmdArgs, StringRef Component,
229 RuntimeLinkOptions Opts = RuntimeLinkOptions(),
230 bool IsShared = false) const;
231
232 /// Add any profiling runtime libraries that are needed. This is essentially a
233 /// MachO specific version of addProfileRT in Tools.cpp.
234 void addProfileRTLibs(const llvm::opt::ArgList &Args,
235 llvm::opt::ArgStringList &CmdArgs) const override {
236 // There aren't any profiling libs for embedded targets currently.
237 }
238
239 // Return the full path of the compiler-rt library on a non-Darwin MachO
240 // system. Those are under
241 // <resourcedir>/lib/darwin/macho_embedded/<...>(.dylib|.a).
242 std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
244 bool IsFortran = false) const override;
245
246 /// }
247 /// @name ToolChain Implementation
248 /// {
249
250 types::ID LookupTypeForExtension(StringRef Ext) const override;
251
252 bool HasNativeLLVMSupport() const override;
253
254 llvm::opt::DerivedArgList *
255 TranslateArgs(const llvm::opt::DerivedArgList &Args, BoundArch BA,
256 Action::OffloadKind DeviceOffloadKind) const override;
257
258 bool IsBlocksDefault() const override {
259 // Always allow blocks on Apple; users interested in versioning are
260 // expected to use /usr/include/Block.h.
261 return true;
262 }
263
264 bool IsMathErrnoDefault() const override { return false; }
265
266 bool IsEncodeExtendedBlockSignatureDefault() const override { return true; }
267
268 bool IsObjCNonFragileABIDefault() const override {
269 // Non-fragile ABI is default for everything but i386.
270 return getTriple().getArch() != llvm::Triple::x86;
271 }
272
273 bool UseObjCMixedDispatch() const override { return true; }
274
275 UnwindTableLevel
276 getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
277
281
282 bool isPICDefault() const override;
283 bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
284 bool isPICDefaultForced() const override;
285
286 bool SupportsProfiling() const override;
287
288 bool UseDwarfDebugFlags() const override;
289 std::string GetGlobalDebugPathRemapping() const override;
290
291 llvm::ExceptionHandling
292 GetExceptionModel(const llvm::opt::ArgList &Args) const override {
293 return llvm::ExceptionHandling::None;
294 }
295
296 virtual StringRef getOSLibraryNameSuffix(bool IgnoreSim = false) const {
297 return "";
298 }
299
300 // Darwin toolchain uses legacy thin LTO API, which is not
301 // capable of unit splitting.
302 bool canSplitThinLTOUnit() const override { return false; }
303 /// }
304};
305
306/// Apple specific MachO extensions
307class LLVM_LIBRARY_VISIBILITY AppleMachO : public MachO {
308public:
309 AppleMachO(const Driver &D, const llvm::Triple &Triple,
310 const llvm::opt::ArgList &Args);
311 ~AppleMachO() override;
312
313 /// }
314 /// @name Apple Specific ToolChain Implementation
315 /// {
316 void
317 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
318 llvm::opt::ArgStringList &CC1Args) const override;
319
320 void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
321 llvm::opt::ArgStringList &CC1Args) const override;
322 void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
323 llvm::opt::ArgStringList &CC1Args) const override;
324 void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
325 llvm::opt::ArgStringList &CC1Args) const override;
326
328 const llvm::opt::ArgList &DriverArgs,
329 llvm::opt::ArgStringList &CC1Args) const override;
330 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
331 llvm::opt::ArgStringList &CmdArgs) const override;
332
333 void printVerboseInfo(raw_ostream &OS) const override;
334 /// }
335
339
340protected:
342 GetEffectiveSysroot(const llvm::opt::ArgList &DriverArgs) const;
343
344private:
345 virtual void
346 AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
347 llvm::opt::ArgStringList &CC1Args) const;
348};
349
350/// Darwin - The base Darwin tool chain.
351class LLVM_LIBRARY_VISIBILITY Darwin : public AppleMachO {
352public:
353 /// Whether the information on the target has been initialized.
354 //
355 // FIXME: This should be eliminated. What we want to do is make this part of
356 // the "default target for arguments" selection process, once we get out of
357 // the argument translation business.
358 mutable bool TargetInitialized;
359
360 /// Whether the target was lazily initialized from the triple by
361 /// ensureTargetInitialized() rather than by AddDeploymentTarget(). Such a
362 /// target is a best-effort guess that setTarget() may overwrite.
363 mutable bool TargetInitializedLazily = false;
364
365 // TODO: Are these useful? Can we use Triple::OSType/EnvironmentType instead?
380
383
384 /// The native OS version we are targeting.
385 mutable VersionTuple TargetVersion;
386 /// The OS version we are targeting as specified in the triple.
387 mutable VersionTuple OSTargetVersion;
388
389 /// The information about the darwin SDK that was used.
390 mutable std::optional<DarwinSDKInfo> SDKInfo;
391
392 /// The target variant triple that was specified (if any).
393 mutable std::optional<llvm::Triple> TargetVariantTriple;
394
395private:
396 void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
397
398 void VerifyTripleForSDK(const llvm::opt::ArgList &Args,
399 const llvm::Triple &Triple) const;
400
401protected:
402 /// Lazily initialize the target platform from the triple when
403 /// AddDeploymentTarget has not run yet (e.g. when Darwin is used as
404 /// a host toolchain for device offloading).
405 void ensureTargetInitialized() const;
406
407public:
408 Darwin(const Driver &D, const llvm::Triple &Triple,
409 const llvm::opt::ArgList &Args);
410 ~Darwin() override;
411
412 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
413 BoundArch BA,
414 types::ID InputType) const override;
415
416 /// @name Darwin Specific Toolchain Implementation
417 /// {
418
419 void addMinVersionArgs(const llvm::opt::ArgList &Args,
420 llvm::opt::ArgStringList &CmdArgs) const override;
421
422 void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
423 llvm::opt::ArgStringList &CmdArgs) const override;
424
425 void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
426 llvm::opt::ArgStringList &CmdArgs) const override;
427
428 bool isKernelStatic() const override {
429 return (!(isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) &&
431 }
432
433 void addProfileRTLibs(const llvm::opt::ArgList &Args,
434 llvm::opt::ArgStringList &CmdArgs) const override;
435
436 // Return the full path of the compiler-rt library on a Darwin MachO system.
437 // Those are under <resourcedir>/lib/darwin/<...>(.dylib|.a).
438 std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
440 bool IsFortran = false) const override;
441
442protected:
443 /// }
444 /// @name Darwin specific Toolchain functions
445 /// {
446
447 // FIXME: Eliminate these ...Target functions and derive separate tool chains
448 // for these targets and put version in constructor.
450 unsigned Major, unsigned Minor, unsigned Micro,
451 VersionTuple NativeTargetVersion) const {
452 // FIXME: For now, allow reinitialization as long as values don't
453 // change. This will go away when we move away from argument translation.
454 if (TargetInitialized && TargetPlatform == Platform &&
455 TargetEnvironment == Environment &&
456 (Environment == MacCatalyst ? OSTargetVersion : TargetVersion) ==
457 VersionTuple(Major, Minor, Micro)) {
459 return;
460 }
461
462 // A lazily-initialized target (see ensureTargetInitialized()) is a
463 // best-effort guess from the triple alone; the authoritative
464 // initialization from AddDeploymentTarget() may overwrite it.
466 "Target already initialized!");
468 TargetInitialized = true;
469 TargetPlatform = Platform;
470 TargetEnvironment = Environment;
471 TargetVersion = VersionTuple(Major, Minor, Micro);
472 if (Environment == Simulator)
473 const_cast<Darwin *>(this)->setTripleEnvironment(llvm::Triple::Simulator);
474 else if (Environment == MacCatalyst) {
475 const_cast<Darwin *>(this)->setTripleEnvironment(llvm::Triple::MacABI);
476 TargetVersion = NativeTargetVersion;
477 OSTargetVersion = VersionTuple(Major, Minor, Micro);
478 }
479 }
480
481public:
482 bool isTargetIPhoneOS() const {
483 assert(TargetInitialized && "Target not initialized!");
484 return (TargetPlatform == IPhoneOS || TargetPlatform == TvOS) &&
486 }
487
488 bool isTargetIOSSimulator() const {
489 assert(TargetInitialized && "Target not initialized!");
490 return (TargetPlatform == IPhoneOS || TargetPlatform == TvOS) &&
492 }
493
494 bool isTargetIOSBased() const {
495 assert(TargetInitialized && "Target not initialized!");
497 }
498
502
505 }
506
507 bool isTargetXROS() const { return TargetPlatform == XROS; }
508
509 bool isTargetTvOS() const {
510 assert(TargetInitialized && "Target not initialized!");
512 }
513
515 assert(TargetInitialized && "Target not initialized!");
517 }
518
519 bool isTargetTvOSBased() const {
520 assert(TargetInitialized && "Target not initialized!");
521 return TargetPlatform == TvOS;
522 }
523
524 bool isTargetWatchOS() const {
525 assert(TargetInitialized && "Target not initialized!");
527 }
528
530 assert(TargetInitialized && "Target not initialized!");
532 }
533
534 bool isTargetWatchOSBased() const {
535 assert(TargetInitialized && "Target not initialized!");
536 return TargetPlatform == WatchOS;
537 }
538
539 bool isTargetDriverKit() const {
540 assert(TargetInitialized && "Target not initialized!");
541 return TargetPlatform == DriverKit;
542 }
543
544 bool isTargetFirmware() const { return TargetPlatform == Firmware; }
545
549
550 bool isTargetMacOS() const {
551 assert(TargetInitialized && "Target not initialized!");
552 return TargetPlatform == MacOS;
553 }
554
555 bool isTargetMacOSBased() const {
556 assert(TargetInitialized && "Target not initialized!");
558 }
559
561 assert(TargetInitialized && "Target not initialized!");
562 return isTargetMacOSBased() && getArch() == llvm::Triple::aarch64;
563 }
564
565 bool isTargetInitialized() const { return TargetInitialized; }
566
567 /// The version of the OS that's used by the OS specified in the target
568 /// triple. It might be different from the actual target OS on which the
569 /// program will run, e.g. MacCatalyst code runs on a macOS target, but its
570 /// target triple is iOS.
571 VersionTuple getTripleTargetVersion() const {
572 assert(TargetInitialized && "Target not initialized!");
574 }
575
576 bool isIPhoneOSVersionLT(unsigned V0, unsigned V1 = 0,
577 unsigned V2 = 0) const {
578 assert(isTargetIOSBased() && "Unexpected call for non iOS target!");
579 return TargetVersion < VersionTuple(V0, V1, V2);
580 }
581
582 /// Returns true if the minimum supported macOS version for the slice that's
583 /// being built is less than the specified version. If there's no minimum
584 /// supported macOS version, the deployment target version is compared to the
585 /// specifed version instead.
586 bool isMacosxVersionLT(unsigned V0, unsigned V1 = 0, unsigned V2 = 0) const {
587 assert(isTargetMacOSBased() &&
588 (getTriple().isMacOSX() || getTriple().isMacCatalystEnvironment()) &&
589 "Unexpected call for non OS X target!");
590 // The effective triple might not be initialized yet, so construct a
591 // pseudo-effective triple to get the minimum supported OS version.
592 VersionTuple MinVers =
593 llvm::Triple(getTriple().getArchName(), "apple", "macos")
594 .getMinimumSupportedOSVersion();
595 return (!MinVers.empty() && MinVers > TargetVersion
596 ? MinVers
597 : TargetVersion) < VersionTuple(V0, V1, V2);
598 }
599
600protected:
601 /// Return true if c++17 aligned allocation/deallocation functions are not
602 /// implemented in the c++ standard library of the deployment target we are
603 /// targeting.
604 bool isAlignedAllocationUnavailable() const;
605
606 /// Return true if c++14 sized deallocation functions are not implemented in
607 /// the c++ standard library of the deployment target we are targeting.
608 bool isSizedDeallocationUnavailable() const;
609
610 void
611 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
612 llvm::opt::ArgStringList &CC1Args, BoundArch BA,
613 Action::OffloadKind DeviceOffloadKind) const override;
614
615 void addClangCC1ASTargetOptions(
616 const llvm::opt::ArgList &Args,
617 llvm::opt::ArgStringList &CC1ASArgs) const override;
618
619 StringRef getOSLibraryNameSuffix(bool IgnoreSim = false) const override;
620
621public:
622 static StringRef getSDKName(StringRef isysroot);
623
624 /// }
625 /// @name ToolChain Implementation
626 /// {
627
628 // Darwin tools support multiple architecture (e.g., i386 and x86_64) and
629 // most development is done against SDKs, so compiling for a different
630 // architecture should not get any special treatment.
631 bool isCrossCompiling() const override { return false; }
632
633 llvm::opt::DerivedArgList *
634 TranslateArgs(const llvm::opt::DerivedArgList &Args, BoundArch BA,
635 Action::OffloadKind DeviceOffloadKind) const override;
636
637 CXXStdlibType GetDefaultCXXStdlibType() const override;
638 ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override;
639 bool hasBlocksRuntime() const override;
640
641 bool UseObjCMixedDispatch() const override {
642 // This is only used with the non-fragile ABI and non-legacy dispatch.
643
644 // Mixed dispatch is used everywhere except OS X before 10.6.
645 return !(isTargetMacOSBased() && isMacosxVersionLT(10, 6));
646 }
647
649 GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
650 // Stack protectors default to on for user code on 10.5,
651 // and for everything in 10.6 and beyond
653 isTargetXROS())
654 return LangOptions::SSPOn;
655 else if (isTargetMacOSBased() && !isMacosxVersionLT(10, 6))
656 return LangOptions::SSPOn;
657 else if (isTargetMacOSBased() && !isMacosxVersionLT(10, 5) && !KernelOrKext)
658 return LangOptions::SSPOn;
659
660 return LangOptions::SSPOff;
661 }
662
663 void CheckObjCARC() const override;
664
665 llvm::ExceptionHandling GetExceptionModel(
666 const llvm::opt::ArgList &Args) const override;
667
668 bool SupportsEmbeddedBitcode() const override;
669
671 getSupportedSanitizers(BoundArch BA,
672 Action::OffloadKind DeviceOffloadKind) const override;
673};
674
675/// DarwinClang - The Darwin toolchain used by Clang.
676class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
677public:
678 DarwinClang(const Driver &D, const llvm::Triple &Triple,
679 const llvm::opt::ArgList &Args);
680
681 /// @name Apple ToolChain Implementation
682 /// {
683
684 void
685 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
686 llvm::opt::ArgStringList &CC1Args) const override;
687
688 RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
689
690 void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
691 llvm::opt::ArgStringList &CmdArgs,
692 bool ForceLinkBuiltinRT = false) const override;
693
694 void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
695 llvm::opt::ArgStringList &CmdArgs) const override;
696
697 void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
698
699 void
700 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
701 llvm::opt::ArgStringList &CC1Args, BoundArch BA,
702 Action::OffloadKind DeviceOffloadKind) const override;
703
704 void AddLinkARCArgs(const llvm::opt::ArgList &Args,
705 llvm::opt::ArgStringList &CmdArgs) const override;
706
707 bool HasPlatformPrefix(const llvm::Triple &T) const override;
708
710 const llvm::Triple &T) const override;
711
712 unsigned GetDefaultDwarfVersion() const override;
713 // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
714 // Darwin defaults to standalone/full debug info.
715 bool GetDefaultStandaloneDebug() const override { return true; }
716 llvm::DebuggerKind getDefaultDebuggerTuning() const override {
717 return llvm::DebuggerKind::LLDB;
718 }
719
720 bool getDefaultDebugSimpleTemplateNames() const override;
721
722 /// }
723
724private:
725 void AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
726 llvm::opt::ArgStringList &CmdArgs,
727 StringRef Sanitizer,
728 bool shared = true) const;
729
730 void
731 AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
732 llvm::opt::ArgStringList &CC1Args) const override;
733
734 bool AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
735 llvm::opt::ArgStringList &CC1Args,
737 llvm::StringRef Version,
738 llvm::StringRef ArchDir,
739 llvm::StringRef BitDir) const;
740};
741
742} // end namespace toolchains
743} // end namespace driver
744} // end namespace clang
745
746#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H
Defines the clang::LangOptions interface.
llvm::MachO::FileType FileType
Definition MachO.h:46
static StringRef getTriple(const Command &Job)
Simple wrapper for toolchain detector with costly initialization.
The basic abstraction for the target Objective-C runtime.
Definition ObjCRuntime.h:28
The base class of the type hierarchy.
Definition TypeBase.h:1879
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:46
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition Driver.h:96
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:96
llvm::Triple::ArchType getArch() const
Definition ToolChain.h:302
ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args)
Definition ToolChain.cpp:92
void setTripleEnvironment(llvm::Triple::EnvironmentType Env)
StringRef getArchName() const
Definition ToolChain.h:303
Tool - Information on a specific compilation tool.
Definition Tool.h:32
const ToolChain & getToolChain() const
Definition Tool.h:52
Tool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition Tool.cpp:13
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
AddCXXStdlibLibArgs - Add the system specific linker arguments to use for the given C++ standard libr...
Definition Darwin.cpp:3127
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific CUDA includes.
Definition Darwin.cpp:1098
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition Darwin.cpp:1103
void printVerboseInfo(raw_ostream &OS) const override
Dispatch to the specific toolchain for verbose printing.
Definition Darwin.cpp:4133
llvm::SmallString< 128 > GetEffectiveSysroot(const llvm::opt::ArgList &DriverArgs) const
Definition Darwin.cpp:2905
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition Darwin.cpp:2918
LazyDetector< RocmInstallationDetector > RocmInstallation
Definition Darwin.h:337
LazyDetector< SYCLInstallationDetector > SYCLInstallation
Definition Darwin.h:338
void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition Darwin.cpp:3018
LazyDetector< CudaInstallationDetector > CudaInstallation
}
Definition Darwin.h:336
AppleMachO(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition Darwin.cpp:1040
void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific SYCL includes.
Definition Darwin.cpp:1108
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override
Add warning options that need to be passed to cc1 for this target.
Definition Darwin.cpp:1375
void AppendPlatformPrefix(SmallString< 128 > &Path, const llvm::Triple &T) const override
Definition Darwin.cpp:2889
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition Darwin.cpp:2967
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, BoundArch BA, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition Darwin.cpp:1399
void AddCCKextLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
AddCCKextLibArgs - Add the system specific linker arguments to use for kernel extensions (Darwin-spec...
Definition Darwin.cpp:3174
void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, bool ForceLinkBuiltinRT=false) const override
Add the linker arguments to link the compiler runtime library.
Definition Darwin.cpp:1734
RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override
Definition Darwin.cpp:1722
DarwinClang(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition Darwin.cpp:1371
llvm::DebuggerKind getDefaultDebuggerTuning() const override
Definition Darwin.h:716
void AddLinkARCArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
Add the linker arguments to link the ARC runtime library.
Definition Darwin.cpp:1418
bool HasPlatformPrefix(const llvm::Triple &T) const override
Definition Darwin.cpp:2879
unsigned GetDefaultDwarfVersion() const override
Definition Darwin.cpp:1495
bool GetDefaultStandaloneDebug() const override
Definition Darwin.h:715
VersionTuple TargetVersion
The native OS version we are targeting.
Definition Darwin.h:385
void addPlatformVersionArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
Definition Darwin.cpp:3885
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition Darwin.h:631
bool TargetInitialized
Whether the information on the target has been initialized.
Definition Darwin.h:358
bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const
Definition Darwin.h:576
bool isKernelStatic() const override
On some iOS platforms, kernel and kernel modules were built statically.
Definition Darwin.h:428
Darwin(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Darwin - Darwin tool chain for i386 and x86_64.
Definition Darwin.cpp:1046
std::optional< DarwinSDKInfo > SDKInfo
The information about the darwin SDK that was used.
Definition Darwin.h:390
void ensureTargetInitialized() const
Lazily initialize the target platform from the triple when AddDeploymentTarget has not run yet (e....
Definition Darwin.cpp:1211
bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const
Returns true if the minimum supported macOS version for the slice that's being built is less than the...
Definition Darwin.h:586
bool UseObjCMixedDispatch() const override
UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the mixed dispatch method be use...
Definition Darwin.h:641
bool isTargetAppleSiliconMac() const
Definition Darwin.h:560
LangOptions::StackProtectorMode GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain.
Definition Darwin.h:649
void setTarget(DarwinPlatformKind Platform, DarwinEnvironmentKind Environment, unsigned Major, unsigned Minor, unsigned Micro, VersionTuple NativeTargetVersion) const
Definition Darwin.h:449
bool isTargetWatchOSSimulator() const
Definition Darwin.h:529
DarwinPlatformKind TargetPlatform
Definition Darwin.h:381
void addMinVersionArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
Definition Darwin.cpp:3810
void addStartObjectFileArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
Definition Darwin.cpp:4055
std::optional< llvm::Triple > TargetVariantTriple
The target variant triple that was specified (if any).
Definition Darwin.h:393
VersionTuple getTripleTargetVersion() const
The version of the OS that's used by the OS specified in the target triple.
Definition Darwin.h:571
bool TargetInitializedLazily
Whether the target was lazily initialized from the triple by ensureTargetInitialized() rather than by...
Definition Darwin.h:363
std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, BoundArch BA, types::ID InputType) const override
ComputeEffectiveClangTriple - Return the Clang triple to use for this target, which may take into acc...
Definition Darwin.cpp:1305
VersionTuple OSTargetVersion
The OS version we are targeting as specified in the triple.
Definition Darwin.h:387
DarwinEnvironmentKind TargetEnvironment
Definition Darwin.h:382
VersionTuple getLinkerVersion(const llvm::opt::ArgList &Args) const
Get the version of the linker known to be available for a particular compiler invocation (via the -ml...
Definition Darwin.cpp:1184
bool UseObjCMixedDispatch() const override
UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the mixed dispatch method be use...
Definition Darwin.h:273
Tool * buildLinker() const override
Definition Darwin.cpp:1361
Tool * buildStaticLibTool() const override
Definition Darwin.cpp:1363
bool isTargetIOSBased() const
Is the target either iOS or an iOS simulator?
Definition Darwin.h:212
virtual void AppendPlatformPrefix(SmallString< 128 > &Path, const llvm::Triple &T) const
Definition Darwin.h:204
bool IsBlocksDefault() const override
IsBlocksDefault - Does this tool chain enable -fblocks by default.
Definition Darwin.h:258
llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const override
GetExceptionModel - Return the tool chain exception model.
Definition Darwin.h:292
bool IsEncodeExtendedBlockSignatureDefault() const override
IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable -fencode-extended-block-signature...
Definition Darwin.h:266
void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
Add any profiling runtime libraries that are needed.
Definition Darwin.h:234
Tool * getTool(Action::ActionClass AC) const override
Definition Darwin.cpp:1342
virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Add the linker arguments to link the ARC runtime library.
Definition Darwin.h:180
virtual void addMinVersionArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition Darwin.h:195
virtual bool isKernelStatic() const
On some iOS platforms, kernel and kernel modules were built statically.
Definition Darwin.h:209
virtual void addPlatformVersionArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition Darwin.h:198
virtual StringRef getOSLibraryNameSuffix(bool IgnoreSim=false) const
Definition Darwin.h:296
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, BoundArch BA, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition Darwin.cpp:3482
virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition Darwin.h:191
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition Darwin.h:278
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition Darwin.h:268
virtual bool HasPlatformPrefix(const llvm::Triple &T) const
Definition Darwin.h:202
RuntimeLinkOptions
Options to control how a runtime library is linked.
Definition Darwin.h:215
@ RLO_IsEmbedded
Use the embedded runtime from the macho_embedded directory.
Definition Darwin.h:220
@ RLO_AddRPath
Emit rpaths for @executable_path as well as the resource directory.
Definition Darwin.h:223
@ RLO_AlwaysLink
Link the library in even if it can't be found in the VFS.
Definition Darwin.h:217
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition Darwin.h:264
MachO(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition Darwin.cpp:1034
StringRef getMachOArchName(const llvm::opt::ArgList &Args) const
Get the "MachO" arch name for a particular compiler invocation.
Definition Darwin.cpp:1156
Tool * buildAssembler() const override
Definition Darwin.cpp:1367
bool canSplitThinLTOUnit() const override
Returns true when it's possible to split LTO unit to use whole program devirtualization and CFI santi...
Definition Darwin.h:302
Assembler(const ToolChain &TC)
Definition Darwin.h:56
bool hasIntegratedCPP() const override
Definition Darwin.h:59
bool isDsymutilJob() const override
Definition Darwin.h:118
bool hasIntegratedCPP() const override
Definition Darwin.h:117
Dsymutil(const ToolChain &TC)
Definition Darwin.h:114
Linker(const ToolChain &TC)
Definition Darwin.h:75
bool isLinkJob() const override
Definition Darwin.h:78
bool hasIntegratedCPP() const override
Definition Darwin.h:77
bool hasIntegratedCPP() const override
Definition Darwin.h:104
Lipo(const ToolChain &TC)
Definition Darwin.h:102
MachOTool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition Darwin.h:50
const toolchains::MachO & getMachOToolChain() const
Definition Darwin.h:45
void AddMachOArch(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition Darwin.cpp:182
void AddMachOArchOnly(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition Darwin.cpp:195
bool hasIntegratedCPP() const override
Definition Darwin.h:91
bool hasIntegratedCPP() const override
Definition Darwin.h:131
llvm::Triple::ArchType getArchTypeForMachOArchName(StringRef Str)
Definition Darwin.cpp:44
void setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str, const llvm::opt::ArgList &Args)
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:52
Top level wrappers for InstallAPI frontend operations.
const FunctionProtoType * T
Represents a bound architecture for offload / multiple architecture compilation.