add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / tools / crosstools / llvm / cfe-7.0.0.src-aros.diff
blob8cd7c93333eb14bf9ee14291e75b5e752da3b232
1 diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
2 index 809b28b9dd..b001f31e36 100644
3 --- a/include/clang/Driver/Options.td
4 +++ b/include/clang/Driver/Options.td
5 @@ -610,6 +610,7 @@ def dependency_dot : Separate<["-"], "dependency-dot">, Flags<[CC1Option]>,
6 HelpText<"Filename to write DOT-formatted header dependencies to">;
7 def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
8 Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">;
9 +def detach : Flag<["-"], "detach">, Flags<[DriverOption,NoArgumentUnused]>;
10 def dumpmachine : Flag<["-"], "dumpmachine">;
11 def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
12 def dumpversion : Flag<["-"], "dumpversion">;
13 @@ -2412,11 +2413,15 @@ def multi__module : Flag<["-"], "multi_module">;
14 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
15 def multiply__defined : Separate<["-"], "multiply_defined">;
16 def mwarn_nonportable_cfstrings : Flag<["-"], "mwarn-nonportable-cfstrings">, Group<m_Group>;
17 +def nix : Flag<["-"], "nix">, Flags<[DriverOption,NoArgumentUnused]>;
18 def no_canonical_prefixes : Flag<["-"], "no-canonical-prefixes">, Flags<[HelpHidden, CoreOption]>,
19 HelpText<"Use relative instead of canonical paths">;
20 def no_cpp_precomp : Flag<["-"], "no-cpp-precomp">, Group<clang_ignored_f_Group>;
21 def no_integrated_cpp : Flag<["-", "--"], "no-integrated-cpp">, Flags<[DriverOption]>;
22 def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group<pedantic_Group>;
23 +def no_posixc : Flag<["-"], "no-posixc">, Flags<[DriverOption,NoArgumentUnused]>;
24 +def no_stdc : Flag<["-"], "no-stdc">, Flags<[DriverOption,NoArgumentUnused]>;
25 +def no_sysbase : Flag<["-"], "no_sysbase">, Flags<[DriverOption,NoArgumentUnused]>;
26 def no__dead__strip__inits__and__terms : Flag<["-"], "no_dead_strip_inits_and_terms">;
27 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
28 HelpText<"Disable builtin #include directories">;
29 @@ -2428,15 +2433,18 @@ def nolibc : Flag<["-"], "nolibc">;
30 def nomultidefs : Flag<["-"], "nomultidefs">;
31 def nopie : Flag<["-"], "nopie">;
32 def no_pie : Flag<["-"], "no-pie">, Alias<nopie>;
33 +def noposixc : Flag<["-"], "noposixc">, Alias<no_posixc>;
34 def noprebind : Flag<["-"], "noprebind">;
35 def noseglinkedit : Flag<["-"], "noseglinkedit">;
36 def nostartfiles : Flag<["-"], "nostartfiles">;
37 +def nostdc : Flag<["-"], "nostdc">, Alias<no_stdc>;
38 def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>;
39 def nostdlibinc : Flag<["-"], "nostdlibinc">;
40 def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>,
41 HelpText<"Disable standard #include directories for the C++ standard library">;
42 def nostdlib : Flag<["-"], "nostdlib">;
43 def nostdlibxx : Flag<["-"], "nostdlib++">;
44 +def nosysbase : Flag<["-"], "nosysbase">, Alias<no_sysbase>;
45 def object : Flag<["-"], "object">;
46 def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, CC1Option, CC1AsOption]>,
47 HelpText<"Write output to <file>">, MetaVarName<"<file>">;
48 @@ -2447,6 +2455,7 @@ def pedantic : Flag<["-", "--"], "pedantic">, Group<pedantic_Group>, Flags<[CC1O
49 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>;
50 def pipe : Flag<["-", "--"], "pipe">,
51 HelpText<"Use pipes between commands, when possible">;
52 +def posixc : Flag<["-"], "posixc">, Flags<[DriverOption,NoArgumentUnused]>;
53 def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">;
54 def prebind : Flag<["-"], "prebind">;
55 def preload : Flag<["-"], "preload">;
56 @@ -2533,6 +2542,7 @@ def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
57 def static_libgcc : Flag<["-"], "static-libgcc">;
58 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
59 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
60 +def stdc : Flag<["-"], "stdc">, Flags<[DriverOption,NoArgumentUnused]>;
61 def std_default_EQ : Joined<["-"], "std-default=">;
62 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
63 Group<CompileOnly_Group>, HelpText<"Language standard to compile for">,
64 diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
65 index f79da4e576..45064b071d 100644
66 --- a/lib/Basic/Targets.cpp
67 +++ b/lib/Basic/Targets.cpp
68 @@ -140,8 +140,13 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
69 case llvm::Triple::aarch64:
70 if (Triple.isOSDarwin())
71 return new DarwinAArch64TargetInfo(Triple, Opts);
73 switch (os) {
74 + // FIXME:
75 + // Needs to be tested before inclusion!!!
76 + // New Target AROS AArch64
77 + // case llvm::Triple::AROS:
78 + // return new AROSTargetInfo<AArch64leTargetInfo>(Triple, Opts);
80 case llvm::Triple::CloudABI:
81 return new CloudABITargetInfo<AArch64leTargetInfo>(Triple, Opts);
82 case llvm::Triple::FreeBSD:
83 @@ -184,8 +189,13 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
84 case llvm::Triple::thumb:
85 if (Triple.isOSBinFormatMachO())
86 return new DarwinARMTargetInfo(Triple, Opts);
88 switch (os) {
89 + // FIXME:
90 + // Needs to be tested before inclusion!!!
91 + // New Target AROS ARMle
92 + // case llvm::Triple::AROS:
93 + // return new AROSTargetInfo<ARMleTargetInfo>(Triple, Opts);
95 case llvm::Triple::CloudABI:
96 return new CloudABITargetInfo<ARMleTargetInfo>(Triple, Opts);
97 case llvm::Triple::Linux:
98 @@ -220,8 +230,13 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
99 case llvm::Triple::thumbeb:
100 if (Triple.isOSDarwin())
101 return new DarwinARMTargetInfo(Triple, Opts);
103 switch (os) {
104 + // FIXME:
105 + // Needs to be tested before inclusion!!!
106 + // New Target AROS ARMbe
107 + // case llvm::Triple::AROS:
108 + // return new AROSTargetInfo<ARMbeTargetInfo>(Triple, Opts);
110 case llvm::Triple::Linux:
111 return new LinuxTargetInfo<ARMbeTargetInfo>(Triple, Opts);
112 case llvm::Triple::FreeBSD:
113 @@ -326,7 +341,14 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
114 case llvm::Triple::ppc:
115 if (Triple.isOSDarwin())
116 return new DarwinPPC32TargetInfo(Triple, Opts);
118 switch (os) {
119 + // FIXME:
120 + // Needs to be tested before inclusion!!!
121 + // New Target AROS PPC32
122 + // case llvm::Triple::AROS:
123 + // return new AROSTargetInfo<PPC32TargetInfo>(Triple, Opts);
125 case llvm::Triple::Linux:
126 return new LinuxTargetInfo<PPC32TargetInfo>(Triple, Opts);
127 case llvm::Triple::FreeBSD:
128 @@ -344,7 +366,14 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
129 case llvm::Triple::ppc64:
130 if (Triple.isOSDarwin())
131 return new DarwinPPC64TargetInfo(Triple, Opts);
133 switch (os) {
134 + // FIXME:
135 + // Needs to be tested before inclusion!!!
136 + // New Target AROS PPC64
137 + // case llvm::Triple::AROS:
138 + // return new AROSTargetInfo<PPC64TargetInfo>(Triple, Opts);
140 case llvm::Triple::Linux:
141 return new LinuxTargetInfo<PPC64TargetInfo>(Triple, Opts);
142 case llvm::Triple::Lv2:
143 @@ -455,6 +484,12 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
144 switch (os) {
145 case llvm::Triple::Ananas:
146 return new AnanasTargetInfo<X86_32TargetInfo>(Triple, Opts);
147 + // FIXME:
148 + // Needs to be tested!!!
149 + // New Target AROS X86_32
150 + case llvm::Triple::AROS:
151 + return new AROSTargetInfo<X86_32TargetInfo>(Triple, Opts);
153 case llvm::Triple::CloudABI:
154 return new CloudABITargetInfo<X86_32TargetInfo>(Triple, Opts);
155 case llvm::Triple::Linux: {
156 @@ -512,6 +547,12 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
157 switch (os) {
158 case llvm::Triple::Ananas:
159 return new AnanasTargetInfo<X86_64TargetInfo>(Triple, Opts);
160 + // FIXME:
161 + // Needs to be tested!!!
162 + // New Target AROS X86_64
163 + case llvm::Triple::AROS:
164 + return new AROSTargetInfo<X86_64TargetInfo>(Triple, Opts);
166 case llvm::Triple::CloudABI:
167 return new CloudABITargetInfo<X86_64TargetInfo>(Triple, Opts);
168 case llvm::Triple::Linux: {
169 diff --git a/lib/Basic/Targets/OSTargets.h b/lib/Basic/Targets/OSTargets.h
170 index 42ce89669f..1d1c9d41d2 100644
171 --- a/lib/Basic/Targets/OSTargets.h
172 +++ b/lib/Basic/Targets/OSTargets.h
173 @@ -71,6 +71,26 @@ public:
174 AnanasTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
175 : OSTargetInfo<Target>(Triple, Opts) {}
177 +// AROS target
178 +template <typename Target>
179 +class LLVM_LIBRARY_VISIBILITY AROSTargetInfo : public OSTargetInfo<Target> {
180 +protected:
181 + void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
182 + MacroBuilder &Builder) const override {
183 + // FIXME:
184 + // Are these Macros correct ???
185 + // AROS defines
186 + Builder.defineMacro("__AROS__");
187 + Builder.defineMacro("__ELF__");
190 +public:
191 + // FIXME:
192 + // Is this correct ???
193 + AROSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
194 + : OSTargetInfo<Target>(Triple, Opts) {}
198 void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
199 const llvm::Triple &Triple, StringRef &PlatformName,
200 diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt
201 index 084176b524..e893a1857b 100644
202 --- a/lib/Driver/CMakeLists.txt
203 +++ b/lib/Driver/CMakeLists.txt
204 @@ -32,6 +32,7 @@ add_clang_library(clangDriver
205 ToolChains/Arch/X86.cpp
206 ToolChains/Ananas.cpp
207 ToolChains/AMDGPU.cpp
208 + ToolChains/AROS.cpp
209 ToolChains/AVR.cpp
210 ToolChains/BareMetal.cpp
211 ToolChains/Clang.cpp
212 diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
213 index dfc0faac7b..4630bc94ed 100644
214 --- a/lib/Driver/Driver.cpp
215 +++ b/lib/Driver/Driver.cpp
216 @@ -10,6 +10,7 @@
217 #include "clang/Driver/Driver.h"
218 #include "InputInfo.h"
219 #include "ToolChains/AMDGPU.h"
220 +#include "ToolChains/AROS.h"
221 #include "ToolChains/AVR.h"
222 #include "ToolChains/Ananas.h"
223 #include "ToolChains/BareMetal.h"
224 @@ -4497,6 +4498,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
225 case llvm::Triple::Ananas:
226 TC = llvm::make_unique<toolchains::Ananas>(*this, Target, Args);
227 break;
228 + case llvm::Triple::AROS:
229 + TC = llvm::make_unique<toolchains::AROSToolChain>(*this, Target, Args);
230 + break;
231 case llvm::Triple::CloudABI:
232 TC = llvm::make_unique<toolchains::CloudABI>(*this, Target, Args);
233 break;
234 diff --git a/lib/Driver/ToolChains/AROS.cpp b/lib/Driver/ToolChains/AROS.cpp
235 new file mode 100644
236 index 0000000000..57cdd8fb33
237 --- /dev/null
238 +++ b/lib/Driver/ToolChains/AROS.cpp
239 @@ -0,0 +1,325 @@
240 +//===--- AROS.cpp - AROS Tool Chain -------------===//
242 +// The LLVM Compiler Infrastructure
244 +// This file is distributed under the University of Illinois Open Source
245 +// License. See LICENSE.TXT for details.
247 +//===----------------------------------------------------------------------===//
249 +#include "AROS.h"
250 +#include "InputInfo.h"
251 +#include "CommonArgs.h"
252 +#include "clang/Config/config.h"
253 +#include "clang/Driver/Compilation.h"
254 +#include "clang/Driver/Driver.h"
255 +#include "clang/Driver/DriverDiagnostic.h"
256 +#include "clang/Driver/Options.h"
257 +#include "llvm/Option/ArgList.h"
258 +#include "llvm/Support/FileSystem.h"
259 +#include "llvm/Support/Path.h"
261 +using namespace clang::driver;
262 +using namespace clang::driver::tools;
263 +using namespace clang::driver::toolchains;
264 +using namespace clang;
265 +using namespace llvm::opt;
268 +void
269 +AROS::Assembler::ConstructJob(Compilation &C,
270 + const JobAction &JA,
271 + const InputInfo &Output,
272 + const InputInfoList &Inputs,
273 + const ArgList &Args,
274 + const char *LinkingOutput) const {
275 + claimNoWarnArgs(Args);
276 + ArgStringList CmdArgs;
278 + Args.AddAllArgValues(CmdArgs,
279 + options::OPT_Wa_COMMA,
280 + options::OPT_Xassembler);
282 + CmdArgs.push_back("-o");
283 + CmdArgs.push_back(Output.getFilename());
285 + for (const auto &II : Inputs)
286 + CmdArgs.push_back(II.getFilename());
288 + const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
289 + C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
292 +void
293 +AROS::Linker::ConstructJob(Compilation &C,
294 + const JobAction &JA,
295 + const InputInfo &Output,
296 + const InputInfoList &Inputs,
297 + const ArgList &Args,
298 + const char *LinkingOutput) const {
299 + const toolchains::AROSToolChain &AROSTC =
300 + static_cast<const toolchains::AROSToolChain &>(getToolChain());
301 + const char *Exec = Args.MakeArgString(AROSTC.GetLinkerPath());
302 + const Driver &D = AROSTC.getDriver();
303 + const std::string &SysRoot = D.SysRoot;
304 + ArgStringList CmdArgs;
306 + if (llvm::sys::path::filename(Exec) == "lld") {
307 + CmdArgs.push_back("-flavor");
308 + CmdArgs.push_back("gnu");
309 + if (!D.SysRoot.empty())
310 + CmdArgs.push_back(Args.MakeArgString("--sysroot=" + SysRoot));
313 + // When building 32-bit code on AROS/pc64,
314 + // we have to explicitly instruct ld in
315 + // the base system to link 32-bit code.
316 + if (AROSTC.getArch() == llvm::Triple::x86) {
317 + CmdArgs.push_back("-m");
318 + CmdArgs.push_back("elf_i386");
321 + if (Output.isFilename()) {
322 + CmdArgs.push_back("-o");
323 + CmdArgs.push_back(Output.getFilename());
324 + } else {
325 + assert(Output.isNothing() && "Invalid output.");
328 + AROSTC.addStartObjectFileArgs(Args, CmdArgs);
330 + Args.AddAllArgs(CmdArgs,
331 + {options::OPT_L,
332 + options::OPT_T_Group,
333 + options::OPT_e});
335 + AddLinkerInputs(AROSTC, Inputs, Args, CmdArgs, JA);
337 + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
338 + SmallString<128> LibPath(SysRoot);
339 + llvm::sys::path::append(LibPath, "lib");
340 + CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
342 + if (D.CCCIsCXX()) {
343 + AROSTC.AddCXXStdlibLibArgs(Args, CmdArgs);
344 + CmdArgs.push_back("-lpthread");
346 + CmdArgs.push_back("--start-group");
347 + CmdArgs.push_back("-lmui");
348 + CmdArgs.push_back("-larossupport");
349 + CmdArgs.push_back("-lamiga");
350 + if (!Args.hasArg(options::OPT_nostartfiles)) {
351 + if (!Args.hasArg(options::OPT_static)) {
352 + if (!Args.hasArg(options::OPT_no_stdc)) {
353 + if (!Args.hasArg(options::OPT_no_posixc)) {
354 + CmdArgs.push_back("-lposixc");
357 + CmdArgs.push_back("-lstdcio");
358 + CmdArgs.push_back("-lstdc");
359 + }// OPT_no_stdc endif
360 + } else {
361 + if (!Args.hasArg(options::OPT_no_stdc)) {
362 + CmdArgs.push_back("-lstdc.static");
364 + }// OPT_static endif
365 + }// OPT_nostartfiles endif
366 + CmdArgs.push_back("-lcodesets");
367 + CmdArgs.push_back("-lkeymap");
368 + CmdArgs.push_back("-lexpansion");
369 + CmdArgs.push_back("-lcommodities");
370 + CmdArgs.push_back("-ldiskfont");
371 + CmdArgs.push_back("-lasl");
372 + CmdArgs.push_back("-lmuimaster");
373 + CmdArgs.push_back("-ldatatypes");
374 + CmdArgs.push_back("-lcybergraphics");
375 + CmdArgs.push_back("-lworkbench");
376 + CmdArgs.push_back("-licon");
377 + CmdArgs.push_back("-lintuition");
378 + CmdArgs.push_back("-lgadtools");
379 + CmdArgs.push_back("-llayers");
380 + CmdArgs.push_back("-laros");
381 + CmdArgs.push_back("-lpartition");
382 + CmdArgs.push_back("-liffparse");
383 + CmdArgs.push_back("-lgraphics");
384 + CmdArgs.push_back("-llocale");
385 + CmdArgs.push_back("-ldos");
386 + CmdArgs.push_back("-lutility");
387 + CmdArgs.push_back("-loop");
388 + if (!Args.hasArg(options::OPT_nosysbase)) {
389 + CmdArgs.push_back("-lexec");
391 + CmdArgs.push_back("-lautoinit");
392 + CmdArgs.push_back("-llibinit");
393 + if (!Args.hasArg(options::OPT_nostartfiles)) {
394 + if (!Args.hasArg(options::OPT_static)) {
395 + CmdArgs.push_back("-lstdc.static");
397 + }// 2nd OPT_nostartfiles endif
398 + CmdArgs.push_back("--end-group");
401 + C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
405 +//------------------------------------------------------------------------------------------------------//
408 +AROSToolChain::AROSToolChain(const Driver &D,
409 + const llvm::Triple &Triple,
410 + const llvm::opt::ArgList &Args)
411 + : Generic_ELF(D, Triple, Args) {
412 + if (GetCXXStdlibType(Args) == ToolChain::CST_Libstdcxx) {
416 + // FIXME:
417 + // Now declared in AROS.h with the function getDefaultLinker() ???
418 + // Is this the correct way to implement this ???
419 + // This is an unused variable in clang 7 Driver. Delete this ???
420 + // Use LLD by default.
421 + // DefaultLinker = "collect-aros";
426 +#if (0)
427 +bool AROSToolChain::IsUnwindTablesDefault() const {
428 + // FIXME:
430 + // all non-x86 targets need unwind tables, however,
431 + // LLVM currently does not know how to emit them.
433 + // FIXME:
434 + // Is this the correct implementation of this function ???
435 +// bool AROSToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
436 + //// Unwind tables are not emitted if -fno-exceptions
437 + //// is supplied (except when targeting x86_64).
438 + //return getArch() == llvm::Triple::x86_64 ||
439 + // (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
440 + // Args.hasFlag(options::OPT_fexceptions,
441 + // options::OPT_fno_exceptions,
442 + // true));
444 + return getArch() == llvm::Triple::x86_64;
447 +bool AROSToolChain::isPICDefault() const {
448 + return getArch() == llvm::Triple::x86_64;
451 +bool AROSToolChain::isPIEDefault() const {
452 + return getArch() == llvm::Triple::x86_64;
455 +bool AROSToolChain::isPICDefaultForced() const {
456 + return getArch() == llvm::Triple::x86_64;
458 +#endif
460 +void AROSToolChain::
461 +AddAROSSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
462 + llvm::opt::ArgStringList &CC1Args) const {
463 + const Driver &D = getDriver();
464 + const std::string &SysRoot = D.SysRoot;
466 + if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
467 + addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
468 + if (!DriverArgs.hasArg(options::OPT_no_posixc)) {
469 + SmallString<128> ResourceDir(SysRoot);
470 + llvm::sys::path::append(ResourceDir, "include/aros/posixc");
471 + addSystemInclude(DriverArgs, CC1Args, ResourceDir);
472 + }// OPT_no_posixc endif
473 + if (!DriverArgs.hasArg(options::OPT_no_stdc)) {
474 + SmallString<128> ResourceDir(SysRoot);
475 + llvm::sys::path::append(ResourceDir, "include/aros/stdc");
476 + addSystemInclude(DriverArgs, CC1Args, ResourceDir);
477 + }// OPT_no_stdc endif
478 + }// OPT_nobuiltininc endif
481 +void AROSToolChain::
482 +AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
483 + llvm::opt::ArgStringList &CC1Args) const {
484 + if (DriverArgs.hasArg(options::OPT_nostdlibinc))
485 + return;
487 + AddAROSSystemIncludeArgs(DriverArgs, CC1Args);
490 +void AROSToolChain::
491 +addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
492 + llvm::opt::ArgStringList &CC1Args,
493 + Action::OffloadKind DeviceOffloadingKind) const {
494 + CC1Args.push_back("-D__AROS__");
495 + CC1Args.push_back("-D__AROS");
496 + CC1Args.push_back("-DAROS");
497 + CC1Args.push_back("-D__AMIGA__");
498 + CC1Args.push_back("-D_AMIGA");
499 + CC1Args.push_back("-DAMIGA");
500 + CC1Args.push_back("-D__ELF__");
501 + CC1Args.push_back("-Dsystem=posix");
505 +void AROSToolChain::
506 +AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
507 + llvm::opt::ArgStringList &CC1Args) const {
508 + if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
509 + DriverArgs.hasArg(options::OPT_nostdincxx))
510 + return;
512 + switch (GetCXXStdlibType(DriverArgs)) {
513 + case ToolChain::CST_Libcxx:
514 + AddAROSSystemIncludeArgs(DriverArgs, CC1Args);
515 + break;
517 + case ToolChain::CST_Libstdcxx:
518 + AddAROSSystemIncludeArgs(DriverArgs, CC1Args);
519 + break;
523 +void AROSToolChain::
524 +AddCXXStdlibLibArgs(const llvm::opt::ArgList &DriverArgs,
525 + llvm::opt::ArgStringList &CC1Args) const {
526 + switch (GetCXXStdlibType(DriverArgs)) {
527 + case ToolChain::CST_Libcxx:
528 + CC1Args.push_back("-lc++");
529 + break;
530 + case ToolChain::CST_Libstdcxx:
531 + CC1Args.push_back("-lstdc++");
532 + break;
536 +void AROSToolChain::
537 +addStartObjectFileArgs(const llvm::opt::ArgList &Args,
538 + llvm::opt::ArgStringList &CmdArgs) const {
539 + if (Args.hasArg(options::OPT_nostartfiles))
540 + return;
542 + const Driver &D = getDriver();
543 + const std::string &SysRoot = D.SysRoot;
544 + SmallString<128> LibPath(SysRoot);
545 + llvm::sys::path::append(LibPath, "lib/");
547 + // Derived from startfile spec.
548 + CmdArgs.push_back(Args.MakeArgString(LibPath + "startup.o"));
549 + if (Args.hasArg(options::OPT_detach)) {
550 + CmdArgs.push_back(Args.MakeArgString(LibPath + "detach.o"));
552 + if (Args.hasArg(options::OPT_nix)) {
553 + CmdArgs.push_back(Args.MakeArgString(LibPath + "nixmain.o"));
558 +Tool *AROSToolChain::buildAssembler() const {
559 + return new tools::AROS::Assembler(*this);
562 +Tool *AROSToolChain::buildLinker() const {
563 + return new tools::AROS::Linker(*this);
565 diff --git a/lib/Driver/ToolChains/AROS.h b/lib/Driver/ToolChains/AROS.h
566 new file mode 100644
567 index 0000000000..c6f894635f
568 --- /dev/null
569 +++ b/lib/Driver/ToolChains/AROS.h
570 @@ -0,0 +1,98 @@
571 +//===--- AROS.h - AROS ToolChain Implementations ----------*- C -*-===//
573 +// The LLVM Compiler Infrastructure
575 +// This file is distributed under the University of Illinois Open Source
576 +// License. See LICENSE.TXT for details.
578 +//===----------------------------------------------------------------------===//
580 +#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AROS_H
581 +#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AROS_H
583 +#include "Gnu.h"
584 +#include "clang/Driver/Tool.h"
585 +#include "clang/Driver/ToolChain.h"
587 +namespace clang {
588 +namespace driver {
589 +namespace tools {
591 +/// AROS -- Directly call GNU Binutils assembler and linker
592 +namespace AROS {
593 +class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
594 +public:
595 + Assembler(const ToolChain &TC)
596 + : GnuTool("AROS::Assembler", "assembler", TC) {}
598 + bool hasIntegratedCPP() const override { return false; }
600 + void ConstructJob(Compilation &C, const JobAction &JA,
601 + const InputInfo &Output, const InputInfoList &Inputs,
602 + const llvm::opt::ArgList &TCArgs,
603 + const char *LinkingOutput) const override;
606 +class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
607 +public:
608 + Linker(const ToolChain &TC)
609 + : GnuTool("AROS::Linker", "linker", TC) {}
611 + bool hasIntegratedCPP() const override { return false; }
612 + bool isLinkJob() const override { return true; }
614 + void ConstructJob(Compilation &C, const JobAction &JA,
615 + const InputInfo &Output, const InputInfoList &Inputs,
616 + const llvm::opt::ArgList &TCArgs,
617 + const char *LinkingOutput) const override;
619 +} // end namespace AROS
620 +} // end namespace tools
622 +namespace toolchains {
623 +// FIXME:
624 +// AROS - The base AROS tool chain. I changed it from => (Generic_ELF)
625 +// Should it be changed back to => Generic_GCC ???
626 +class LLVM_LIBRARY_VISIBILITY AROSToolChain : public Generic_ELF {
627 +public:
628 + AROSToolChain(const Driver &D,
629 + const llvm::Triple &Triple,
630 + const llvm::opt::ArgList &Args);
632 + void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
633 + llvm::opt::ArgStringList &CC1Args) const override;
635 + void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
636 + llvm::opt::ArgStringList &CC1Args,
637 + Action::OffloadKind DeviceOffloadKind) const override;
639 + void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
640 + llvm::opt::ArgStringList &CC1Args) const override;
642 + void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
643 + llvm::opt::ArgStringList &CmdArgs) const override;
645 + void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
646 + llvm::opt::ArgStringList &CmdArgs) const;
647 + // FIXME:
648 + // Is this the correct use of this function in this header?
649 + // Moved from AROS.cpp as it was an unused variable "DefaultLinker=collect-aros"
650 + // Should "ld.lld" be declare here ???
651 + // Use LLD by default.? "ld.lld" ???
652 + const char *getDefaultLinker() const override { return "collect-aros"; }
654 +private:
655 + void AddAROSSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
656 + llvm::opt::ArgStringList &CC1Args) const;
658 +protected:
659 + Tool *buildAssembler() const override;
660 + Tool *buildLinker() const override;
664 +} // end namespace toolchains
665 +} // end namespace driver
666 +} // end namespace clang
668 +#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AROS_H
669 diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
670 index ac3bb713dd..fa1dd4ad09 100644
671 --- a/lib/Frontend/InitHeaderSearch.cpp
672 +++ b/lib/Frontend/InitHeaderSearch.cpp
673 @@ -210,9 +210,9 @@ void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base,
674 void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
675 const HeaderSearchOptions &HSOpts) {
676 llvm::Triple::OSType os = triple.getOS();
678 if (HSOpts.UseStandardSystemIncludes) {
679 switch (os) {
680 + case llvm::Triple::AROS:
681 case llvm::Triple::CloudABI:
682 case llvm::Triple::FreeBSD:
683 case llvm::Triple::NetBSD:
684 @@ -322,8 +322,8 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
685 default:
686 break;
689 switch (os) {
690 + case llvm::Triple::AROS:
691 case llvm::Triple::CloudABI:
692 case llvm::Triple::RTEMS:
693 case llvm::Triple::NaCl: