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