#include "Darwin.h"
#include "Arch/AArch64.h"
#include "Arch/ARM.h"
#include "CommonArgs.h"
#include "clang/Basic/AlignedAllocation.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Config/config.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/TargetParser.h"
#include "llvm/TargetParser/Triple.h"
#include <cstdlib>
usingnamespaceclang::driver;
usingnamespaceclang::driver::tools;
usingnamespaceclang::driver::toolchains;
usingnamespaceclang;
usingnamespacellvm::opt;
static VersionTuple minimumMacCatalystDeploymentTarget() { … }
llvm::Triple::ArchType darwin::getArchTypeForMachOArchName(StringRef Str) { … }
void darwin::setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str,
const ArgList &Args) { … }
void darwin::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }
void darwin::MachOTool::anchor() { … }
void darwin::MachOTool::AddMachOArch(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
bool darwin::Linker::NeedsTempPath(const InputInfoList &Inputs) const { … }
static bool shouldLinkerNotDedup(bool IsLinkerOnlyAction, const ArgList &Args) { … }
void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args,
ArgStringList &CmdArgs,
const InputInfoList &Inputs,
VersionTuple Version, bool LinkerIsLLD,
bool UsePlatformVersion) const { … }
static bool isObjCRuntimeLinked(const ArgList &Args) { … }
static bool checkRemarksOptions(const Driver &D, const ArgList &Args,
const llvm::Triple &Triple) { … }
static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
const llvm::Triple &Triple,
const InputInfo &Output, const JobAction &JA) { … }
static void AppendPlatformPrefix(SmallString<128> &Path, const llvm::Triple &T);
void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }
void darwin::StaticLibTool::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }
void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }
void darwin::Dsymutil::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }
void darwin::VerifyDebug::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }
MachO::MachO(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
: … { … }
Darwin::Darwin(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
: … { … }
types::ID MachO::LookupTypeForExtension(StringRef Ext) const { … }
bool MachO::HasNativeLLVMSupport() const { … }
ToolChain::CXXStdlibType Darwin::GetDefaultCXXStdlibType() const { … }
ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const { … }
bool Darwin::hasBlocksRuntime() const { … }
void Darwin::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const { … }
void Darwin::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const { … }
static const char *ArmMachOArchName(StringRef Arch) { … }
static const char *ArmMachOArchNameCPU(StringRef CPU) { … }
StringRef MachO::getMachOArchName(const ArgList &Args) const { … }
VersionTuple MachO::getLinkerVersion(const llvm::opt::ArgList &Args) const { … }
Darwin::~Darwin() { … }
MachO::~MachO() { … }
std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
types::ID InputType) const { … }
Tool *MachO::getTool(Action::ActionClass AC) const { … }
Tool *MachO::buildLinker() const { … }
Tool *MachO::buildStaticLibTool() const { … }
Tool *MachO::buildAssembler() const { … }
DarwinClang::DarwinClang(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: … { … }
void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const { … }
static StringRef getXcodeDeveloperPath(StringRef PathIntoXcode) { … }
void DarwinClang::AddLinkARCArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
unsigned DarwinClang::GetDefaultDwarfVersion() const { … }
void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,
StringRef Component, RuntimeLinkOptions Opts,
bool IsShared) const { … }
std::string MachO::getCompilerRT(const ArgList &, StringRef Component,
FileType Type) const { … }
std::string Darwin::getCompilerRT(const ArgList &, StringRef Component,
FileType Type) const { … }
StringRef Darwin::getPlatformFamily() const { … }
StringRef Darwin::getSDKName(StringRef isysroot) { … }
StringRef Darwin::getOSLibraryNameSuffix(bool IgnoreSim) const { … }
static bool hasExportSymbolDirective(const ArgList &Args) { … }
static void addExportedSymbol(ArgStringList &CmdArgs, const char *Symbol) { … }
static void addSectalignToPage(const ArgList &Args, ArgStringList &CmdArgs,
StringRef Segment, StringRef Section) { … }
void Darwin::addProfileRTLibs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args,
ArgStringList &CmdArgs,
StringRef Sanitizer,
bool Shared) const { … }
ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType(
const ArgList &Args) const { … }
void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
ArgStringList &CmdArgs,
bool ForceLinkBuiltinRT) const { … }
static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) { … }
namespace {
struct DarwinPlatform { … };
std::optional<DarwinPlatform>
getDeploymentTargetFromOSVersionArg(DerivedArgList &Args,
const Driver &TheDriver) { … }
std::optional<DarwinPlatform>
getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
const llvm::Triple &Triple) { … }
static StringRef dropSDKNamePrefix(StringRef SDKName) { … }
std::optional<DarwinPlatform>
inferDeploymentTargetFromSDK(DerivedArgList &Args,
const std::optional<DarwinSDKInfo> &SDKInfo) { … }
std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
const Driver &TheDriver) { … }
std::optional<DarwinPlatform>
inferDeploymentTargetFromArch(DerivedArgList &Args, const Darwin &Toolchain,
const llvm::Triple &Triple,
const Driver &TheDriver) { … }
std::optional<DarwinPlatform> getDeploymentTargetFromTargetArg(
DerivedArgList &Args, const llvm::Triple &Triple, const Driver &TheDriver,
const std::optional<DarwinSDKInfo> &SDKInfo) { … }
std::optional<DarwinPlatform> getDeploymentTargetFromMTargetOSArg(
DerivedArgList &Args, const Driver &TheDriver,
const std::optional<DarwinSDKInfo> &SDKInfo) { … }
std::optional<DarwinSDKInfo> parseSDKSettings(llvm::vfs::FileSystem &VFS,
const ArgList &Args,
const Driver &TheDriver) { … }
}
void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { … }
static void AppendPlatformPrefix(SmallString<128> &Path,
const llvm::Triple &T) { … }
llvm::SmallString<128>
DarwinClang::GetEffectiveSysroot(const llvm::opt::ArgList &DriverArgs) const { … }
void DarwinClang::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const { … }
bool DarwinClang::AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
llvm::SmallString<128> Base,
llvm::StringRef Version,
llvm::StringRef ArchDir,
llvm::StringRef BitDir) const { … }
void DarwinClang::AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const { … }
void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void DarwinClang::AddCCKextLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
DerivedArgList *MachO::TranslateArgs(const DerivedArgList &Args,
StringRef BoundArch,
Action::OffloadKind) const { … }
void MachO::AddLinkRuntimeLibArgs(const ArgList &Args,
ArgStringList &CmdArgs,
bool ForceLinkBuiltinRT) const { … }
bool Darwin::isAlignedAllocationUnavailable() const { … }
static bool sdkSupportsBuiltinModules(
const Darwin::DarwinPlatformKind &TargetPlatform,
const Darwin::DarwinEnvironmentKind &TargetEnvironment,
const std::optional<DarwinSDKInfo> &SDKInfo) { … }
static inline llvm::VersionTuple
sizedDeallocMinVersion(llvm::Triple::OSType OS) { … }
bool Darwin::isSizedDeallocationUnavailable() const { … }
void Darwin::addClangTargetOptions(
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const { … }
void Darwin::addClangCC1ASTargetOptions(
const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1ASArgs) const { … }
DerivedArgList *
Darwin::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const { … }
ToolChain::UnwindTableLevel MachO::getDefaultUnwindTableLevel(const ArgList &Args) const { … }
bool MachO::UseDwarfDebugFlags() const { … }
std::string MachO::GetGlobalDebugPathRemapping() const { … }
llvm::ExceptionHandling Darwin::GetExceptionModel(const ArgList &Args) const { … }
bool Darwin::SupportsEmbeddedBitcode() const { … }
bool MachO::isPICDefault() const { … }
bool MachO::isPIEDefault(const llvm::opt::ArgList &Args) const { … }
bool MachO::isPICDefaultForced() const { … }
bool MachO::SupportsProfiling() const { … }
void Darwin::addMinVersionArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
static const char *getPlatformName(Darwin::DarwinPlatformKind Platform,
Darwin::DarwinEnvironmentKind Environment) { … }
void Darwin::addPlatformVersionArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const { … }
static void addDynamicLibLinkArgs(const Darwin &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static void addBundleLinkArgs(const Darwin &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static void addPgProfilingLinkArgs(const Darwin &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static void addDefaultCRTLinkArgs(const Darwin &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
void Darwin::addStartObjectFileArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Darwin::CheckObjCARC() const { … }
SanitizerMask Darwin::getSupportedSanitizers() const { … }
void Darwin::printVerboseInfo(raw_ostream &OS) const { … }