clang: lib/Driver/ToolChains/CSKYToolChain.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14#include "llvm/Option/ArgList.h"
15#include "llvm/Support/FileSystem.h"
16#include "llvm/Support/Path.h"
17
21using namespace clang;
23
26 StringRef InstallPath,
29 for (const auto &Path : PathsCallback(Multilib))
31}
32
33
35 const ArgList &Args)
39 Multilibs = GCCInstallation.getMultilibs();
40 SelectedMultilibs.assign({GCCInstallation.getMultilib()});
42
48
49
50 PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
52 .str());
53 PPaths.push_back((GCCInstallation.getParentLibPath() + "/../bin").str());
56 } else {
57 getProgramPaths().push_back(D.Dir);
58 getFilePaths().push_back(computeSysRoot() + "/lib");
59 }
60}
61
65
70
75
77 llvm::opt::ArgStringList &CC1Args,
79 CC1Args.push_back("-nostdsysteminc");
80}
81
83 ArgStringList &CC1Args) const {
84 if (DriverArgs.hasArg(options::OPT_nostdinc))
85 return;
86
87 if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
89 llvm::sys::path::append(Dir, "include");
92 llvm::sys::path::append(Dir2, "sys-include");
94 }
95}
96
98 const llvm::opt::ArgList &DriverArgs,
99 llvm::opt::ArgStringList &CC1Args) const {
105 CC1Args);
106}
107
109 if (().SysRoot.empty())
111
116 llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr);
117 } else {
118
119
120 llvm::sys::path::append(SysRootDir, getDriver().Dir, "..",
122 }
123
124 if (!llvm::sys::fs::exists(SysRootDir))
125 return std::string();
126
127 return std::string(SysRootDir);
128}
129
133 const ArgList &Args,
134 const char *LinkingOutput) const {
137 ArgStringList CmdArgs;
138
140 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
141
142 CmdArgs.push_back("-m");
143 CmdArgs.push_back("cskyelf");
144
146
147 bool WantCRTs =
148 !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
149
150 const char *crtbegin, *crtend;
153 crtbegin = "crtbegin.o";
154 crtend = "crtend.o";
155 } else {
159 crtend =
161 }
162
163 if (WantCRTs) {
167 }
168
169 Args.AddAllArgs(CmdArgs, options::OPT_L);
171 Args.addAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_s,
172 options::OPT_t, options::OPT_r});
173
175
176
177
178 if (!Args.hasArg(options::OPT_nostdlib) &&
179 !Args.hasArg(options::OPT_nodefaultlibs)) {
182 CmdArgs.push_back("--start-group");
183 CmdArgs.push_back("-lc");
184 if (Args.hasArg(options::OPT_msim))
185 CmdArgs.push_back("-lsemi");
186 else
187 CmdArgs.push_back("-lnosys");
188 CmdArgs.push_back("--end-group");
190 }
191
192 if (WantCRTs) {
195 }
196
197 CmdArgs.push_back("-o");
199 C.addCommand(std::make_unique(
201 CmdArgs, Inputs, Output));
202}
203
Compilation - A set of tasks to perform for a single driver invocation.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
std::string SysRoot
sysroot, if present
InputInfo - Wrapper for information about an input source.
const char * getFilename() const
See also MultilibSetBuilder for combining multilibs into a set.
const IncludeDirsFunc & filePathsCallback() const
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag.
const std::string & includeSuffix() const
Get the include directory suffix.
SmallVector< InputInfo, 4 > InputInfoList
The JSON file list parser is used to communicate input to InstallAPI.
static constexpr ResponseFileSupport AtFileCurCP()