1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
|
//===--- Darwin.h - Darwin ToolChain Implementations ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H
#include "Cuda.h"
#include "LazyDetector.h"
#include "ROCm.h"
#include "SYCL.h"
#include "clang/Basic/DarwinSDKInfo.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/XRayArgs.h"
namespace clang {
namespace driver {
namespace toolchains {
class MachO;
} // end namespace toolchains
namespace tools {
namespace darwin {
llvm::Triple::ArchType getArchTypeForMachOArchName(StringRef Str);
void setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str,
const llvm::opt::ArgList &Args);
class LLVM_LIBRARY_VISIBILITY MachOTool : public Tool {
virtual void anchor();
protected:
void AddMachOArch(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;
const toolchains::MachO &getMachOToolChain() const {
return reinterpret_cast<const toolchains::MachO &>(getToolChain());
}
public:
MachOTool(const char *Name, const char *ShortName, const ToolChain &TC)
: Tool(Name, ShortName, TC) {}
};
class LLVM_LIBRARY_VISIBILITY Assembler : public MachOTool {
public:
Assembler(const ToolChain &TC)
: MachOTool("darwin::Assembler", "assembler", TC) {}
bool hasIntegratedCPP() const override { return false; }
void ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
bool NeedsTempPath(const InputInfoList &Inputs) const;
void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const InputInfoList &Inputs, VersionTuple Version,
bool LinkerIsLLD, bool UsePlatformVersion) const;
public:
Linker(const ToolChain &TC) : MachOTool("darwin::Linker", "linker", TC) {}
bool hasIntegratedCPP() const override { return false; }
bool isLinkJob() const override { return true; }
void ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
class LLVM_LIBRARY_VISIBILITY StaticLibTool : public MachOTool {
public:
StaticLibTool(const ToolChain &TC)
: MachOTool("darwin::StaticLibTool", "static-lib-linker", TC) {}
bool hasIntegratedCPP() const override { return false; }
bool isLinkJob() const override { return true; }
void ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
class LLVM_LIBRARY_VISIBILITY Lipo : public MachOTool {
public:
Lipo(const ToolChain &TC) : MachOTool("darwin::Lipo", "lipo", TC) {}
bool hasIntegratedCPP() const override { return false; }
void ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
class LLVM_LIBRARY_VISIBILITY Dsymutil : public MachOTool {
public:
Dsymutil(const ToolChain &TC)
: MachOTool("darwin::Dsymutil", "dsymutil", TC) {}
bool hasIntegratedCPP() const override { return false; }
bool isDsymutilJob() const override { return true; }
void ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
class LLVM_LIBRARY_VISIBILITY VerifyDebug : public MachOTool {
public:
VerifyDebug(const ToolChain &TC)
: MachOTool("darwin::VerifyDebug", "dwarfdump", TC) {}
bool hasIntegratedCPP() const override { return false; }
void ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
} // end namespace darwin
} // end namespace tools
namespace toolchains {
class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
Tool *buildStaticLibTool() const override;
Tool *getTool(Action::ActionClass AC) const override;
private:
mutable std::unique_ptr<tools::darwin::Lipo> Lipo;
mutable std::unique_ptr<tools::darwin::Dsymutil> Dsymutil;
mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
/// The version of the linker known to be available in the tool chain.
mutable std::optional<VersionTuple> LinkerVersion;
public:
MachO(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
~MachO() override;
/// @name MachO specific toolchain API
/// {
/// Get the "MachO" arch name for a particular compiler invocation. For
/// example, Apple treats different ARM variations as distinct architectures.
StringRef getMachOArchName(const llvm::opt::ArgList &Args) const;
/// Get the version of the linker known to be available for a particular
/// compiler invocation (via the `-mlinker-version=` arg).
VersionTuple getLinkerVersion(const llvm::opt::ArgList &Args) const;
/// Add the linker arguments to link the ARC runtime library.
virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {}
/// Add the linker arguments to link the compiler runtime library.
///
/// FIXME: This API is intended for use with embedded libraries only, and is
/// misleadingly named.
virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
bool ForceLinkBuiltinRT = false) const;
virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {
}
virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {}
virtual void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {
}
/// On some iOS platforms, kernel and kernel modules were built statically. Is
/// this such a target?
virtual bool isKernelStatic() const { return false; }
/// Is the target either iOS or an iOS simulator?
bool isTargetIOSBased() const { return false; }
/// Options to control how a runtime library is linked.
enum RuntimeLinkOptions : unsigned {
/// Link the library in even if it can't be found in the VFS.
RLO_AlwaysLink = 1 << 0,
/// Use the embedded runtime from the macho_embedded directory.
RLO_IsEmbedded = 1 << 1,
/// Emit rpaths for @executable_path as well as the resource directory.
RLO_AddRPath = 1 << 2,
};
/// Add a runtime library to the list of items to link.
void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, StringRef Component,
RuntimeLinkOptions Opts = RuntimeLinkOptions(),
bool IsShared = false) const;
/// Add any profiling runtime libraries that are needed. This is essentially a
/// MachO specific version of addProfileRT in Tools.cpp.
void addProfileRTLibs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override {
// There aren't any profiling libs for embedded targets currently.
}
// Return the full path of the compiler-rt library on a non-Darwin MachO
// system. Those are under
// <resourcedir>/lib/darwin/macho_embedded/<...>(.dylib|.a).
std::string
getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
FileType Type = ToolChain::FT_Static) const override;
/// }
/// @name ToolChain Implementation
/// {
types::ID LookupTypeForExtension(StringRef Ext) const override;
bool HasNativeLLVMSupport() const override;
llvm::opt::DerivedArgList *
TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const override;
bool IsBlocksDefault() const override {
// Always allow blocks on Apple; users interested in versioning are
// expected to use /usr/include/Block.h.
return true;
}
bool IsMathErrnoDefault() const override { return false; }
bool IsEncodeExtendedBlockSignatureDefault() const override { return true; }
bool IsObjCNonFragileABIDefault() const override {
// Non-fragile ABI is default for everything but i386.
return getTriple().getArch() != llvm::Triple::x86;
}
bool UseObjCMixedDispatch() const override { return true; }
UnwindTableLevel
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
RuntimeLibType GetDefaultRuntimeLibType() const override {
return ToolChain::RLT_CompilerRT;
}
bool isPICDefault() const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
bool isPICDefaultForced() const override;
bool SupportsProfiling() const override;
bool UseDwarfDebugFlags() const override;
std::string GetGlobalDebugPathRemapping() const override;
llvm::ExceptionHandling
GetExceptionModel(const llvm::opt::ArgList &Args) const override {
return llvm::ExceptionHandling::None;
}
virtual StringRef getOSLibraryNameSuffix(bool IgnoreSim = false) const {
return "";
}
// Darwin toolchain uses legacy thin LTO API, which is not
// capable of unit splitting.
bool canSplitThinLTOUnit() const override { return false; }
/// }
};
/// Apple specific MachO extensions
class LLVM_LIBRARY_VISIBILITY AppleMachO : public MachO {
public:
AppleMachO(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
~AppleMachO() override;
/// }
/// @name Apple Specific ToolChain Implementation
/// {
void
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
void printVerboseInfo(raw_ostream &OS) const override;
/// }
LazyDetector<CudaInstallationDetector> CudaInstallation;
LazyDetector<RocmInstallationDetector> RocmInstallation;
LazyDetector<SYCLInstallationDetector> SYCLInstallation;
protected:
llvm::SmallString<128>
GetEffectiveSysroot(const llvm::opt::ArgList &DriverArgs) const;
private:
virtual void
AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
};
/// Darwin - The base Darwin tool chain.
class LLVM_LIBRARY_VISIBILITY Darwin : public AppleMachO {
public:
/// Whether the information on the target has been initialized.
//
// FIXME: This should be eliminated. What we want to do is make this part of
// the "default target for arguments" selection process, once we get out of
// the argument translation business.
mutable bool TargetInitialized;
enum DarwinPlatformKind {
MacOS,
IPhoneOS,
TvOS,
WatchOS,
DriverKit,
XROS,
LastDarwinPlatform = XROS
};
enum DarwinEnvironmentKind {
NativeEnvironment,
Simulator,
MacCatalyst,
};
mutable DarwinPlatformKind TargetPlatform;
mutable DarwinEnvironmentKind TargetEnvironment;
/// The native OS version we are targeting.
mutable VersionTuple TargetVersion;
/// The OS version we are targeting as specified in the triple.
mutable VersionTuple OSTargetVersion;
/// The information about the darwin SDK that was used.
mutable std::optional<DarwinSDKInfo> SDKInfo;
/// The target variant triple that was specified (if any).
mutable std::optional<llvm::Triple> TargetVariantTriple;
private:
void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
public:
Darwin(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
~Darwin() override;
std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
types::ID InputType) const override;
/// @name Darwin Specific Toolchain Implementation
/// {
void addMinVersionArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
bool isKernelStatic() const override {
return (!(isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) &&
!isTargetWatchOS() && !isTargetDriverKit());
}
void addProfileRTLibs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
// Return the full path of the compiler-rt library on a Darwin MachO system.
// Those are under <resourcedir>/lib/darwin/<...>(.dylib|.a).
std::string
getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
FileType Type = ToolChain::FT_Static) const override;
protected:
/// }
/// @name Darwin specific Toolchain functions
/// {
// FIXME: Eliminate these ...Target functions and derive separate tool chains
// for these targets and put version in constructor.
void setTarget(DarwinPlatformKind Platform, DarwinEnvironmentKind Environment,
unsigned Major, unsigned Minor, unsigned Micro,
VersionTuple NativeTargetVersion) const {
// FIXME: For now, allow reinitialization as long as values don't
// change. This will go away when we move away from argument translation.
if (TargetInitialized && TargetPlatform == Platform &&
TargetEnvironment == Environment &&
(Environment == MacCatalyst ? OSTargetVersion : TargetVersion) ==
VersionTuple(Major, Minor, Micro))
return;
assert(!TargetInitialized && "Target already initialized!");
TargetInitialized = true;
TargetPlatform = Platform;
TargetEnvironment = Environment;
TargetVersion = VersionTuple(Major, Minor, Micro);
if (Environment == Simulator)
const_cast<Darwin *>(this)->setTripleEnvironment(llvm::Triple::Simulator);
else if (Environment == MacCatalyst) {
const_cast<Darwin *>(this)->setTripleEnvironment(llvm::Triple::MacABI);
TargetVersion = NativeTargetVersion;
OSTargetVersion = VersionTuple(Major, Minor, Micro);
}
}
public:
bool isTargetIPhoneOS() const {
assert(TargetInitialized && "Target not initialized!");
return (TargetPlatform == IPhoneOS || TargetPlatform == TvOS) &&
TargetEnvironment == NativeEnvironment;
}
bool isTargetIOSSimulator() const {
assert(TargetInitialized && "Target not initialized!");
return (TargetPlatform == IPhoneOS || TargetPlatform == TvOS) &&
TargetEnvironment == Simulator;
}
bool isTargetIOSBased() const {
assert(TargetInitialized && "Target not initialized!");
return isTargetIPhoneOS() || isTargetIOSSimulator();
}
bool isTargetXROSDevice() const {
return TargetPlatform == XROS && TargetEnvironment == NativeEnvironment;
}
bool isTargetXROSSimulator() const {
return TargetPlatform == XROS && TargetEnvironment == Simulator;
}
bool isTargetXROS() const { return TargetPlatform == XROS; }
bool isTargetTvOS() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == TvOS && TargetEnvironment == NativeEnvironment;
}
bool isTargetTvOSSimulator() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == TvOS && TargetEnvironment == Simulator;
}
bool isTargetTvOSBased() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == TvOS;
}
bool isTargetWatchOS() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == WatchOS && TargetEnvironment == NativeEnvironment;
}
bool isTargetWatchOSSimulator() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == WatchOS && TargetEnvironment == Simulator;
}
bool isTargetWatchOSBased() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == WatchOS;
}
bool isTargetDriverKit() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == DriverKit;
}
bool isTargetMacCatalyst() const {
return TargetPlatform == IPhoneOS && TargetEnvironment == MacCatalyst;
}
bool isTargetMacOS() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == MacOS;
}
bool isTargetMacOSBased() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == MacOS || isTargetMacCatalyst();
}
bool isTargetAppleSiliconMac() const {
assert(TargetInitialized && "Target not initialized!");
return isTargetMacOSBased() && getArch() == llvm::Triple::aarch64;
}
bool isTargetInitialized() const { return TargetInitialized; }
/// The version of the OS that's used by the OS specified in the target
/// triple. It might be different from the actual target OS on which the
/// program will run, e.g. MacCatalyst code runs on a macOS target, but its
/// target triple is iOS.
VersionTuple getTripleTargetVersion() const {
assert(TargetInitialized && "Target not initialized!");
return isTargetMacCatalyst() ? OSTargetVersion : TargetVersion;
}
bool isIPhoneOSVersionLT(unsigned V0, unsigned V1 = 0,
unsigned V2 = 0) const {
assert(isTargetIOSBased() && "Unexpected call for non iOS target!");
return TargetVersion < VersionTuple(V0, V1, V2);
}
/// Returns true if the minimum supported macOS version for the slice that's
/// being built is less than the specified version. If there's no minimum
/// supported macOS version, the deployment target version is compared to the
/// specifed version instead.
bool isMacosxVersionLT(unsigned V0, unsigned V1 = 0, unsigned V2 = 0) const {
assert(isTargetMacOSBased() &&
(getTriple().isMacOSX() || getTriple().isMacCatalystEnvironment()) &&
"Unexpected call for non OS X target!");
// The effective triple might not be initialized yet, so construct a
// pseudo-effective triple to get the minimum supported OS version.
VersionTuple MinVers =
llvm::Triple(getTriple().getArchName(), "apple", "macos")
.getMinimumSupportedOSVersion();
return (!MinVers.empty() && MinVers > TargetVersion
? MinVers
: TargetVersion) < VersionTuple(V0, V1, V2);
}
protected:
/// Return true if c++17 aligned allocation/deallocation functions are not
/// implemented in the c++ standard library of the deployment target we are
/// targeting.
bool isAlignedAllocationUnavailable() const;
/// Return true if c++14 sized deallocation functions are not implemented in
/// the c++ standard library of the deployment target we are targeting.
bool isSizedDeallocationUnavailable() const;
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const override;
void addClangCC1ASTargetOptions(
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CC1ASArgs) const override;
StringRef getPlatformFamily() const;
StringRef getOSLibraryNameSuffix(bool IgnoreSim = false) const override;
public:
static StringRef getSDKName(StringRef isysroot);
/// }
/// @name ToolChain Implementation
/// {
// Darwin tools support multiple architecture (e.g., i386 and x86_64) and
// most development is done against SDKs, so compiling for a different
// architecture should not get any special treatment.
bool isCrossCompiling() const override { return false; }
llvm::opt::DerivedArgList *
TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const override;
CXXStdlibType GetDefaultCXXStdlibType() const override;
ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override;
bool hasBlocksRuntime() const override;
bool UseObjCMixedDispatch() const override {
// This is only used with the non-fragile ABI and non-legacy dispatch.
// Mixed dispatch is used everywhere except OS X before 10.6.
return !(isTargetMacOSBased() && isMacosxVersionLT(10, 6));
}
LangOptions::StackProtectorMode
GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
// Stack protectors default to on for user code on 10.5,
// and for everything in 10.6 and beyond
if (isTargetIOSBased() || isTargetWatchOSBased() || isTargetDriverKit() ||
isTargetXROS())
return LangOptions::SSPOn;
else if (isTargetMacOSBased() && !isMacosxVersionLT(10, 6))
return LangOptions::SSPOn;
else if (isTargetMacOSBased() && !isMacosxVersionLT(10, 5) && !KernelOrKext)
return LangOptions::SSPOn;
return LangOptions::SSPOff;
}
void CheckObjCARC() const override;
llvm::ExceptionHandling GetExceptionModel(
const llvm::opt::ArgList &Args) const override;
bool SupportsEmbeddedBitcode() const override;
SanitizerMask getSupportedSanitizers() const override;
};
/// DarwinClang - The Darwin toolchain used by Clang.
class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
public:
DarwinClang(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
/// @name Apple ToolChain Implementation
/// {
RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
bool ForceLinkBuiltinRT = false) const override;
void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
void AddLinkARCArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
unsigned GetDefaultDwarfVersion() const override;
// Until dtrace (via CTF) and LLDB can deal with distributed debug info,
// Darwin defaults to standalone/full debug info.
bool GetDefaultStandaloneDebug() const override { return true; }
llvm::DebuggerKind getDefaultDebuggerTuning() const override {
return llvm::DebuggerKind::LLDB;
}
/// }
private:
void AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
StringRef Sanitizer,
bool shared = true) const;
void
AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
bool AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
llvm::SmallString<128> Base,
llvm::StringRef Version,
llvm::StringRef ArchDir,
llvm::StringRef BitDir) const;
};
} // end namespace toolchains
} // end namespace driver
} // end namespace clang
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H
|