本文整理汇总了C++中ToolChain::getTriple方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolChain::getTriple方法的具体用法?C++ ToolChain::getTriple怎么用?C++ ToolChain::getTriple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToolChain
的用法示例。
在下文中一共展示了ToolChain::getTriple方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToolChain
CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
const ToolChain &HostTC, const ArgList &Args)
: ToolChain(D, Triple, Args), HostTC(HostTC),
CudaInstallation(D, HostTC.getTriple(), Args) {
if (CudaInstallation.isValid())
getProgramPaths().push_back(CudaInstallation.getBinPath());
}
示例2: hasAsanZeroBaseShadow
bool SanitizerArgs::hasAsanZeroBaseShadow(const ToolChain &TC) const {
if (!needsAsanRt())
return false;
if (AsanZeroBaseShadow != AZBSK_Default)
return AsanZeroBaseShadow == AZBSK_On;
// Zero-base shadow is used by default only on Android.
return TC.getTriple().getEnvironment() == llvm::Triple::Android;
}
示例3: linkSanitizerRuntimeDeps
void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
ArgStringList &CmdArgs) {
// Force linking against the system libraries sanitizers depends on
// (see PR15823 why this is necessary).
CmdArgs.push_back("--no-as-needed");
// There's no libpthread or librt on RTEMS.
if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
CmdArgs.push_back("-lpthread");
CmdArgs.push_back("-lrt");
}
CmdArgs.push_back("-lm");
// There's no libdl on FreeBSD or RTEMS.
if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
TC.getTriple().getOS() != llvm::Triple::NetBSD &&
TC.getTriple().getOS() != llvm::Triple::RTEMS)
CmdArgs.push_back("-ldl");
}
示例4: filterUnsupportedKinds
unsigned SanitizerArgs::filterUnsupportedKinds(const ToolChain &TC,
unsigned Kinds,
const llvm::opt::ArgList &Args,
const llvm::opt::Arg *A,
bool DiagnoseErrors,
unsigned &DiagnosedKinds) {
bool IsLinux = TC.getTriple().getOS() == llvm::Triple::Linux;
bool IsX86 = TC.getTriple().getArch() == llvm::Triple::x86;
bool IsX86_64 = TC.getTriple().getArch() == llvm::Triple::x86_64;
if (!(IsLinux && IsX86_64)) {
filterUnsupportedMask(TC, Kinds, Thread | Memory | DataFlow, Args, A,
DiagnoseErrors, DiagnosedKinds);
}
if (!(IsLinux && (IsX86 || IsX86_64))) {
filterUnsupportedMask(TC, Kinds, Function, Args, A, DiagnoseErrors,
DiagnosedKinds);
}
return Kinds;
}
示例5: ToolChain
CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
const ToolChain &HostTC, const ArgList &Args,
const Action::OffloadKind OK)
: ToolChain(D, Triple, Args), HostTC(HostTC),
CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
if (CudaInstallation.isValid())
getProgramPaths().push_back(CudaInstallation.getBinPath());
// Lookup binaries into the driver directory, this is used to
// discover the clang-offload-bundler executable.
getProgramPaths().push_back(getDriver().Dir);
}
示例6: addLinkSanitizerLibArgsForLinux
static void addLinkSanitizerLibArgsForLinux(const ArgList &Args,
ArgStringList &Arguments,
StringRef Sanitizer,
const ToolChain &TC) {
TC.addLinkRuntimeLib(Args, Arguments, TC.sanitizerRuntimeLibName(Sanitizer));
// Code taken from
// https://github.com/apple/swift-clang/blob/ab3cbe7/lib/Driver/Tools.cpp#L3264-L3276
// There's no libpthread or librt on RTEMS.
if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
Arguments.push_back("-lpthread");
Arguments.push_back("-lrt");
}
Arguments.push_back("-lm");
// There's no libdl on FreeBSD or RTEMS.
if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
TC.getTriple().getOS() != llvm::Triple::RTEMS)
Arguments.push_back("-ldl");
}
示例7: addIncludeLinkerOption
static void addIncludeLinkerOption(const ToolChain &TC,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
StringRef SymbolName) {
SmallString<64> LinkerOptionFlag;
LinkerOptionFlag = "--linker-option=/include:";
if (TC.getTriple().getArch() == llvm::Triple::x86) {
// Win32 mangles C function names with a '_' prefix.
LinkerOptionFlag += '_';
}
LinkerOptionFlag += SymbolName;
CmdArgs.push_back(Args.MakeArgString(LinkerOptionFlag));
}
示例8: AddRunTimeLibs
void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
ArgStringList &CmdArgs, const ArgList &Args) {
// Make use of compiler-rt if --rtlib option is used
ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(Args);
switch (RLT) {
case ToolChain::RLT_CompilerRT:
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
break;
case ToolChain::RLT_Libgcc:
// Make sure libgcc is not used under MSVC environment by default
if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
// Issue error diagnostic if libgcc is explicitly specified
// through command line as --rtlib option argument.
if (Args.hasArg(options::OPT_rtlib_EQ)) {
TC.getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
<< Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "MSVC";
}
} else
AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
break;
}
}
示例9: getArchNameForCompilerRTLib
static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
const ArgList &Args) {
const llvm::Triple &Triple = TC.getTriple();
bool IsWindows = Triple.isOSWindows();
if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86)
return "i386";
if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
? "armhf"
: "arm";
return TC.getArchName();
}
示例10: addLinkRuntimeLibForDarwin
static void
addLinkSanitizerLibArgsForDarwin(const ArgList &Args,
ArgStringList &Arguments,
StringRef Sanitizer, const ToolChain &TC) {
// Sanitizer runtime libraries requires C++.
Arguments.push_back("-lc++");
// Add explicit dependency on -lc++abi, as -lc++ doesn't re-export
// all RTTI-related symbols that are used.
Arguments.push_back("-lc++abi");
addLinkRuntimeLibForDarwin(Args, Arguments,
(Twine("libclang_rt.") + Sanitizer + "_" +
getDarwinLibraryNameSuffixForTriple(TC.getTriple()) +
"_dynamic.dylib").str(),
/*AddRPath*/ true, TC);
}
示例11: getArchNameForCompilerRTLib
static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
const ArgList &Args) {
const llvm::Triple &Triple = TC.getTriple();
bool IsWindows = Triple.isOSWindows();
if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
? "armhf"
: "arm";
// For historic reasons, Android library is using i686 instead of i386.
if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid())
return "i686";
return llvm::Triple::getArchTypeName(TC.getArch());
}
示例12: getRuntimeLibraryPath
/// Get the runtime library link path, which is platform-specific and found
/// relative to the compiler.
static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
const llvm::opt::ArgList &args,
const ToolChain &TC) {
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime
// library link path and the standard library module import path don't
// need to be the same.
if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) {
StringRef value = A->getValue();
runtimeLibPath.append(value.begin(), value.end());
} else {
auto programPath = TC.getDriver().getSwiftProgramPath();
runtimeLibPath.append(programPath.begin(), programPath.end());
llvm::sys::path::remove_filename(runtimeLibPath); // remove /swift
llvm::sys::path::remove_filename(runtimeLibPath); // remove /bin
llvm::sys::path::append(runtimeLibPath, "lib", "swift");
}
llvm::sys::path::append(runtimeLibPath,
getPlatformNameForTriple(TC.getTriple()));
}
示例13: filterUnsupportedMask
void SanitizerArgs::filterUnsupportedMask(const ToolChain &TC, unsigned &Kinds,
unsigned Mask,
const llvm::opt::ArgList &Args,
const llvm::opt::Arg *A,
bool DiagnoseErrors,
unsigned &DiagnosedKinds) {
unsigned MaskedKinds = Kinds & Mask;
if (!MaskedKinds)
return;
Kinds &= ~Mask;
// Do we have new kinds to diagnose?
if (DiagnoseErrors && (DiagnosedKinds & MaskedKinds) != MaskedKinds) {
// Only diagnose the new kinds.
std::string Desc =
describeSanitizeArg(Args, A, MaskedKinds & ~DiagnosedKinds);
TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
<< Desc << TC.getTriple().str();
DiagnosedKinds |= MaskedKinds;
}
}
示例14: addArgs
void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {
if (!Kind)
return;
const Driver &D = TC.getDriver();
SmallString<256> SanitizeOpt("-fsanitize=");
#define SANITIZER(NAME, ID) \
if (Kind & ID) \
SanitizeOpt += NAME ",";
#include "clang/Basic/Sanitizers.def"
SanitizeOpt.pop_back();
CmdArgs.push_back(Args.MakeArgString(SanitizeOpt));
if (!BlacklistFile.empty()) {
SmallString<64> BlacklistOpt("-fsanitize-blacklist=");
BlacklistOpt += BlacklistFile;
CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
}
if (MsanTrackOrigins)
CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-track-origins"));
if (needsAsanRt()) {
if (hasAsanZeroBaseShadow(TC)) {
CmdArgs.push_back(
Args.MakeArgString("-fsanitize-address-zero-base-shadow"));
} else if (TC.getTriple().getEnvironment() == llvm::Triple::Android) {
// Zero-base shadow is a requirement on Android.
D.Diag(diag::err_drv_argument_not_allowed_with)
<< "-fno-sanitize-address-zero-base-shadow"
<< lastArgumentForKind(D, Args, Address);
}
}
// Workaround for PR16386.
if (needsMsanRt())
CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
}
示例15: addCommonFrontendArgs
/// Handle arguments common to all invocations of the frontend (compilation,
/// module-merging, LLDB's REPL, etc).
static void addCommonFrontendArgs(const ToolChain &TC,
const OutputInfo &OI,
const CommandOutput &output,
const ArgList &inputArgs,
ArgStringList &arguments) {
arguments.push_back("-target");
arguments.push_back(inputArgs.MakeArgString(TC.getTriple().str()));
const llvm::Triple &Triple = TC.getTriple();
// Enable address top-byte ignored in the ARM64 backend.
if (Triple.getArch() == llvm::Triple::aarch64) {
arguments.push_back("-Xllvm");
arguments.push_back("-aarch64-use-tbi");
}
// Enable or disable ObjC interop appropriately for the platform
if (Triple.isOSDarwin()) {
arguments.push_back("-enable-objc-interop");
} else {
arguments.push_back("-disable-objc-interop");
}
// Handle the CPU and its preferences.
if (auto arg = inputArgs.getLastArg(options::OPT_target_cpu))
arg->render(inputArgs, arguments);
if (!OI.SDKPath.empty()) {
arguments.push_back("-sdk");
arguments.push_back(inputArgs.MakeArgString(OI.SDKPath));
}
inputArgs.AddAllArgs(arguments, options::OPT_I);
inputArgs.AddAllArgs(arguments, options::OPT_F);
inputArgs.AddLastArg(arguments, options::OPT_AssertConfig);
inputArgs.AddLastArg(arguments, options::OPT_autolink_force_load);
inputArgs.AddLastArg(arguments, options::OPT_color_diagnostics);
inputArgs.AddLastArg(arguments, options::OPT_fixit_all);
inputArgs.AddLastArg(arguments, options::OPT_enable_app_extension);
inputArgs.AddLastArg(arguments, options::OPT_enable_testing);
inputArgs.AddLastArg(arguments, options::OPT_g_Group);
inputArgs.AddLastArg(arguments, options::OPT_import_objc_header);
inputArgs.AddLastArg(arguments, options::OPT_import_underlying_module);
inputArgs.AddLastArg(arguments, options::OPT_module_cache_path);
inputArgs.AddLastArg(arguments, options::OPT_module_link_name);
inputArgs.AddLastArg(arguments, options::OPT_nostdimport);
inputArgs.AddLastArg(arguments, options::OPT_parse_stdlib);
inputArgs.AddLastArg(arguments, options::OPT_resource_dir);
inputArgs.AddLastArg(arguments, options::OPT_solver_memory_threshold);
inputArgs.AddLastArg(arguments, options::OPT_suppress_warnings);
inputArgs.AddLastArg(arguments, options::OPT_profile_generate);
inputArgs.AddLastArg(arguments, options::OPT_profile_coverage_mapping);
inputArgs.AddLastArg(arguments, options::OPT_warnings_as_errors);
inputArgs.AddLastArg(arguments, options::OPT_sanitize_EQ);
// Pass on any build config options
inputArgs.AddAllArgs(arguments, options::OPT_D);
// Pass through the values passed to -Xfrontend.
inputArgs.AddAllArgValues(arguments, options::OPT_Xfrontend);
// Pass through any subsystem flags.
inputArgs.AddAllArgs(arguments, options::OPT_Xllvm);
inputArgs.AddAllArgs(arguments, options::OPT_Xcc);
const std::string &moduleDocOutputPath =
output.getAdditionalOutputForType(types::TY_SwiftModuleDocFile);
if (!moduleDocOutputPath.empty()) {
arguments.push_back("-emit-module-doc-path");
arguments.push_back(moduleDocOutputPath.c_str());
}
if (llvm::sys::Process::StandardErrHasColors())
arguments.push_back("-color-diagnostics");
}