003 File Manager
Current Path:
/usr/src/contrib/llvm-project/clang/lib/Driver/ToolChains
usr
/
src
/
contrib
/
llvm-project
/
clang
/
lib
/
Driver
/
ToolChains
/
📁
..
📄
AIX.cpp
(7.69 KB)
📄
AIX.h
(2.51 KB)
📄
AMDGPU.cpp
(21.42 KB)
📄
AMDGPU.h
(3.72 KB)
📄
AVR.cpp
(5.72 KB)
📄
AVR.h
(1.94 KB)
📄
Ananas.cpp
(5.21 KB)
📄
Ananas.h
(2.06 KB)
📁
Arch
📄
BareMetal.cpp
(6.4 KB)
📄
BareMetal.h
(2.96 KB)
📄
Clang.cpp
(270.02 KB)
📄
Clang.h
(7.82 KB)
📄
CloudABI.cpp
(5.05 KB)
📄
CloudABI.h
(2.3 KB)
📄
CommonArgs.cpp
(49.63 KB)
📄
CommonArgs.h
(5.95 KB)
📄
Contiki.cpp
(926 B)
📄
Contiki.h
(1.25 KB)
📄
CrossWindows.cpp
(9.44 KB)
📄
CrossWindows.h
(2.93 KB)
📄
Cuda.cpp
(36.52 KB)
📄
Cuda.h
(7.5 KB)
📄
Darwin.cpp
(103.49 KB)
📄
Darwin.h
(20.22 KB)
📄
DragonFly.cpp
(6.83 KB)
📄
DragonFly.h
(2.16 KB)
📄
Flang.cpp
(2.57 KB)
📄
Flang.h
(1.45 KB)
📄
FreeBSD.cpp
(15.99 KB)
📄
FreeBSD.h
(3.72 KB)
📄
Fuchsia.cpp
(12.4 KB)
📄
Fuchsia.h
(3.72 KB)
📄
Gnu.cpp
(118.91 KB)
📄
Gnu.h
(14.8 KB)
📄
HIP.cpp
(15.47 KB)
📄
HIP.h
(4.4 KB)
📄
Haiku.cpp
(1.28 KB)
📄
Haiku.h
(1.25 KB)
📄
Hexagon.cpp
(23.79 KB)
📄
Hexagon.h
(4.34 KB)
📄
Hurd.cpp
(7.1 KB)
📄
Hurd.h
(1.5 KB)
📄
InterfaceStubs.cpp
(2.63 KB)
📄
InterfaceStubs.h
(1.23 KB)
📄
Lanai.h
(1.31 KB)
📄
Linux.cpp
(32.88 KB)
📄
Linux.h
(2.69 KB)
📄
MSP430.cpp
(7.95 KB)
📄
MSP430.h
(2.45 KB)
📄
MSVC.cpp
(57.11 KB)
📄
MSVC.h
(6.12 KB)
📄
MSVCSetupApi.h
(19.2 KB)
📄
MinGW.cpp
(21.52 KB)
📄
MinGW.h
(3.8 KB)
📄
Minix.cpp
(3.98 KB)
📄
Minix.h
(2.05 KB)
📄
MipsLinux.cpp
(4.48 KB)
📄
MipsLinux.h
(1.98 KB)
📄
Myriad.cpp
(11.75 KB)
📄
Myriad.h
(3.73 KB)
📄
NaCl.cpp
(13.25 KB)
📄
NaCl.h
(3.01 KB)
📄
NetBSD.cpp
(16.56 KB)
📄
NetBSD.h
(2.97 KB)
📄
OpenBSD.cpp
(10.17 KB)
📄
OpenBSD.h
(3.31 KB)
📄
PPCLinux.cpp
(1.06 KB)
📄
PPCLinux.h
(1.05 KB)
📄
PS4CPU.cpp
(9.53 KB)
📄
PS4CPU.h
(3.68 KB)
📄
RISCVToolchain.cpp
(7.25 KB)
📄
RISCVToolchain.h
(2.28 KB)
📄
ROCm.h
(6.94 KB)
📄
Solaris.cpp
(10.41 KB)
📄
Solaris.h
(2.5 KB)
📄
TCE.cpp
(1.49 KB)
📄
TCE.h
(1.49 KB)
📄
VEToolchain.cpp
(4.09 KB)
📄
VEToolchain.h
(2.16 KB)
📄
WebAssembly.cpp
(13.53 KB)
📄
WebAssembly.h
(2.94 KB)
📄
XCore.cpp
(5.48 KB)
📄
XCore.h
(2.98 KB)
Editing: AVR.cpp
//===--- AVR.cpp - AVR 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 // //===----------------------------------------------------------------------===// #include "AVR.h" #include "CommonArgs.h" #include "InputInfo.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/SubtargetFeature.h" #include "llvm/Option/ArgList.h" #include "llvm/Support/FileSystem.h" using namespace clang::driver; using namespace clang::driver::toolchains; using namespace clang::driver::tools; using namespace clang; using namespace llvm::opt; namespace { // TODO: Consider merging this into the AVR device table // array in Targets/AVR.cpp. llvm::Optional<StringRef> GetMcuFamilyName(StringRef MCU) { return llvm::StringSwitch<llvm::Optional<StringRef>>(MCU) .Case("atmega328", Optional<StringRef>("avr5")) .Case("atmega328p", Optional<StringRef>("avr5")) .Default(Optional<StringRef>()); } const StringRef PossibleAVRLibcLocations[] = { "/usr/avr", "/usr/lib/avr", }; } // end anonymous namespace /// AVR Toolchain AVRToolChain::AVRToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : Generic_ELF(D, Triple, Args), LinkStdlib(false) { GCCInstallation.init(Triple, Args); // Only add default libraries if the user hasn't explicitly opted out. if (!Args.hasArg(options::OPT_nostdlib) && !Args.hasArg(options::OPT_nodefaultlibs) && !Args.hasArg(options::OPT_c /* does not apply when not linking */)) { std::string CPU = getCPUName(Args, Triple); if (CPU.empty()) { // We cannot link any standard libraries without an MCU specified. D.Diag(diag::warn_drv_avr_mcu_not_specified); } else { Optional<StringRef> FamilyName = GetMcuFamilyName(CPU); Optional<std::string> AVRLibcRoot = findAVRLibcInstallation(); if (!FamilyName.hasValue()) { // We do not have an entry for this CPU in the family // mapping table yet. D.Diag(diag::warn_drv_avr_family_linking_stdlibs_not_implemented) << CPU; } else if (!GCCInstallation.isValid()) { // No avr-gcc found and so no runtime linked. D.Diag(diag::warn_drv_avr_gcc_not_found); } else if (!AVRLibcRoot.hasValue()) { // No avr-libc found and so no runtime linked. D.Diag(diag::warn_drv_avr_libc_not_found); } else { // We have enough information to link stdlibs std::string GCCRoot = std::string(GCCInstallation.getInstallPath()); std::string LibcRoot = AVRLibcRoot.getValue(); getFilePaths().push_back(LibcRoot + std::string("/lib/") + std::string(*FamilyName)); getFilePaths().push_back(GCCRoot + std::string("/") + std::string(*FamilyName)); LinkStdlib = true; } } if (!LinkStdlib) D.Diag(diag::warn_drv_avr_stdlib_not_linked); } } Tool *AVRToolChain::buildLinker() const { return new tools::AVR::Linker(getTriple(), *this, LinkStdlib); } void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { // Compute information about the target AVR. std::string CPU = getCPUName(Args, getToolChain().getTriple()); llvm::Optional<StringRef> FamilyName = GetMcuFamilyName(CPU); std::string Linker = getToolChain().GetProgramPath(getShortName()); ArgStringList CmdArgs; AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); // Enable garbage collection of unused sections. CmdArgs.push_back("--gc-sections"); // Add library search paths before we specify libraries. Args.AddAllArgs(CmdArgs, options::OPT_L); getToolChain().AddFilePathLibArgs(Args, CmdArgs); // If the family name is known, we can link with the device-specific libgcc. // Without it, libgcc will simply not be linked. This matches avr-gcc // behavior. if (LinkStdlib) { assert(!CPU.empty() && "CPU name must be known in order to link stdlibs"); // Add the object file for the CRT. std::string CrtFileName = std::string("-l:crt") + CPU + std::string(".o"); CmdArgs.push_back(Args.MakeArgString(CrtFileName)); CmdArgs.push_back("-lgcc"); CmdArgs.push_back("-lm"); CmdArgs.push_back("-lc"); // Add the link library specific to the MCU. CmdArgs.push_back(Args.MakeArgString(std::string("-l") + CPU)); // Specify the family name as the emulation mode to use. // This is almost always required because otherwise avr-ld // will assume 'avr2' and warn about the program being larger // than the bare minimum supports. CmdArgs.push_back(Args.MakeArgString(std::string("-m") + *FamilyName)); } C.addCommand( std::make_unique<Command>(JA, *this, ResponseFileSupport::AtFileCurCP(), Args.MakeArgString(Linker), CmdArgs, Inputs)); } llvm::Optional<std::string> AVRToolChain::findAVRLibcInstallation() const { for (StringRef PossiblePath : PossibleAVRLibcLocations) { // Return the first avr-libc installation that exists. if (llvm::sys::fs::is_directory(PossiblePath)) return Optional<std::string>(std::string(PossiblePath)); } return llvm::None; }
Upload File
Create Folder