clang 19.0.0git
Functions
Darwin.cpp File Reference
#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>

Go to the source code of this file.

Functions

static VersionTuple minimumMacCatalystDeploymentTarget ()
 
static bool shouldLinkerNotDedup (bool IsLinkerOnlyAction, const ArgList &Args)
 Pass -no_deduplicate to ld64 under certain conditions:
 
static bool isObjCRuntimeLinked (const ArgList &Args)
 Determine whether we are linking the ObjC runtime.
 
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)
 
static const char * ArmMachOArchName (StringRef Arch)
 
static const char * ArmMachOArchNameCPU (StringRef CPU)
 
static StringRef getXcodeDeveloperPath (StringRef PathIntoXcode)
 Take a path that speculatively points into Xcode and return the XCODE/Contents/Developer path if it is an Xcode path, or an empty path otherwise.
 
static bool hasExportSymbolDirective (const ArgList &Args)
 Check if the link command contains a symbol export directive.
 
static void addExportedSymbol (ArgStringList &CmdArgs, const char *Symbol)
 Add an export directive for Symbol to the link command.
 
static void addSectalignToPage (const ArgList &Args, ArgStringList &CmdArgs, StringRef Segment, StringRef Section)
 Add a sectalign directive for Segment and Section to the maximum expected page size for Darwin.
 
static std::string getSystemOrSDKMacOSVersion (StringRef MacOSSDKVersion)
 Returns the most appropriate macOS target version for the current process.
 
static bool sdkSupportsBuiltinModules (const Darwin::DarwinPlatformKind &TargetPlatform, const std::optional< DarwinSDKInfo > &SDKInfo)
 
static const char * getPlatformName (Darwin::DarwinPlatformKind Platform, Darwin::DarwinEnvironmentKind Environment)
 
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)
 

Function Documentation

◆ addBundleLinkArgs()

static void addBundleLinkArgs ( const Darwin D,
const ArgList &  Args,
ArgStringList &  CmdArgs 
)
static

◆ addDefaultCRTLinkArgs()

static void addDefaultCRTLinkArgs ( const Darwin D,
const ArgList &  Args,
ArgStringList &  CmdArgs 
)
static

◆ addDynamicLibLinkArgs()

static void addDynamicLibLinkArgs ( const Darwin D,
const ArgList &  Args,
ArgStringList &  CmdArgs 
)
static

◆ addExportedSymbol()

static void addExportedSymbol ( ArgStringList &  CmdArgs,
const char *  Symbol 
)
static

Add an export directive for Symbol to the link command.

Definition at line 1383 of file Darwin.cpp.

Referenced by clang::driver::toolchains::Darwin::addProfileRTLibs().

◆ addPgProfilingLinkArgs()

static void addPgProfilingLinkArgs ( const Darwin D,
const ArgList &  Args,
ArgStringList &  CmdArgs 
)
static

◆ addSectalignToPage()

static void addSectalignToPage ( const ArgList &  Args,
ArgStringList &  CmdArgs,
StringRef  Segment,
StringRef  Section 
)
static

Add a sectalign directive for Segment and Section to the maximum expected page size for Darwin.

On iPhone 6+ the max supported page size is 16K. On macOS, the max is 4K. Use a common alignment constant (16K) for now, and reduce the alignment on macOS if it proves important.

Definition at line 1394 of file Darwin.cpp.

Referenced by clang::driver::toolchains::Darwin::addProfileRTLibs().

◆ AppendPlatformPrefix()

static void AppendPlatformPrefix ( SmallString< 128 > &  Path,
const llvm::Triple &  T 
)
static

Definition at line 2396 of file Darwin.cpp.

References clang::T.

Referenced by clang::driver::tools::darwin::Linker::ConstructJob().

◆ ArmMachOArchName()

static const char * ArmMachOArchName ( StringRef  Arch)
static

Definition at line 997 of file Darwin.cpp.

Referenced by clang::driver::toolchains::MachO::getMachOArchName().

◆ ArmMachOArchNameCPU()

static const char * ArmMachOArchNameCPU ( StringRef  CPU)
static

Definition at line 1014 of file Darwin.cpp.

Referenced by clang::driver::toolchains::MachO::getMachOArchName().

◆ checkRemarksOptions()

static bool checkRemarksOptions ( const Driver D,
const ArgList &  Args,
const llvm::Triple &  Triple 
)
static

Definition at line 491 of file Darwin.cpp.

References clang::driver::Driver::Diag(), and hasMultipleInvocations().

◆ getPlatformName()

static const char * getPlatformName ( Darwin::DarwinPlatformKind  Platform,
Darwin::DarwinEnvironmentKind  Environment 
)
static

◆ getSystemOrSDKMacOSVersion()

static std::string getSystemOrSDKMacOSVersion ( StringRef  MacOSSDKVersion)
static

Returns the most appropriate macOS target version for the current process.

If the macOS SDK version is the same or earlier than the system version, then the SDK version is returned. Otherwise the system version is returned.

Definition at line 1571 of file Darwin.cpp.

References clang::driver::Driver::GetReleaseVersion().

◆ getXcodeDeveloperPath()

static StringRef getXcodeDeveloperPath ( StringRef  PathIntoXcode)
static

Take a path that speculatively points into Xcode and return the XCODE/Contents/Developer path if it is an Xcode path, or an empty path otherwise.

Definition at line 1169 of file Darwin.cpp.

Referenced by clang::driver::toolchains::DarwinClang::AddLinkARCArgs().

◆ hasExportSymbolDirective()

static bool hasExportSymbolDirective ( const ArgList &  Args)
static

Check if the link command contains a symbol export directive.

Definition at line 1368 of file Darwin.cpp.

Referenced by clang::driver::toolchains::Darwin::addProfileRTLibs().

◆ isObjCRuntimeLinked()

static bool isObjCRuntimeLinked ( const ArgList &  Args)
static

Determine whether we are linking the ObjC runtime.

Definition at line 483 of file Darwin.cpp.

References clang::driver::tools::isObjCAutoRefCount().

Referenced by clang::driver::tools::darwin::Linker::ConstructJob().

◆ minimumMacCatalystDeploymentTarget()

static VersionTuple minimumMacCatalystDeploymentTarget ( )
static

◆ renderRemarksOptions()

static void renderRemarksOptions ( const ArgList &  Args,
ArgStringList &  CmdArgs,
const llvm::Triple &  Triple,
const InputInfo Output,
const JobAction JA 
)
static

◆ sdkSupportsBuiltinModules()

static bool sdkSupportsBuiltinModules ( const Darwin::DarwinPlatformKind TargetPlatform,
const std::optional< DarwinSDKInfo > &  SDKInfo 
)
static

◆ shouldLinkerNotDedup()

static bool shouldLinkerNotDedup ( bool  IsLinkerOnlyAction,
const ArgList &  Args 
)
static

Pass -no_deduplicate to ld64 under certain conditions:

  • Either -O0 or -O1 is explicitly specified
  • No -O option is specified and this is a compile+link (implicit -O0)

Also do not add -no_deduplicate when no -O option is specified and this is just a link (we can't imply -O0)

Definition at line 203 of file Darwin.cpp.