try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / tools / crosstools / cfe-3.8.0.src-aros.diff
blob3a69d550f3a56f4071462d4463c341e5491a20d9
1 diff -ruN cfe-3.8.0.src/include/clang/Driver/Options.td cfe-3.8.0.src.aros/include/clang/Driver/Options.td
2 --- cfe-3.8.0.src/include/clang/Driver/Options.td 2016-01-06 21:27:42.000000000 +0000
3 +++ cfe-3.8.0.src.aros/include/clang/Driver/Options.td 2016-04-09 05:41:44.164577499 +0100
4 @@ -388,6 +388,7 @@
5 HelpText<"Filename to write DOT-formatted header dependencies to">;
6 def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
7 Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">;
8 +def detach : Flag<["-"], "detach">, Flags<[DriverOption,NoArgumentUnused]>;
9 def dumpmachine : Flag<["-"], "dumpmachine">;
10 def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
11 def dumpversion : Flag<["-"], "dumpversion">;
12 @@ -1625,11 +1626,15 @@
13 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
14 def multiply__defined : Separate<["-"], "multiply_defined">;
15 def mwarn_nonportable_cfstrings : Flag<["-"], "mwarn-nonportable-cfstrings">, Group<m_Group>;
16 +def nix : Flag<["-"], "nix">, Flags<[DriverOption,NoArgumentUnused]>;
17 def no_canonical_prefixes : Flag<["-"], "no-canonical-prefixes">, Flags<[HelpHidden]>,
18 HelpText<"Use relative instead of canonical paths">;
19 def no_cpp_precomp : Flag<["-"], "no-cpp-precomp">, Group<clang_ignored_f_Group>;
20 def no_integrated_cpp : Flag<["-", "--"], "no-integrated-cpp">, Flags<[DriverOption]>;
21 def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group<pedantic_Group>;
22 +def no_posixc : Flag<["-"], "no-posixc">, Flags<[DriverOption,NoArgumentUnused]>;
23 +def no_stdc : Flag<["-"], "no-stdc">, Flags<[DriverOption,NoArgumentUnused]>;
24 +def no_sysbase : Flag<["-"], "no_sysbase">, Flags<[DriverOption,NoArgumentUnused]>;
25 def no__dead__strip__inits__and__terms : Flag<["-"], "no_dead_strip_inits_and_terms">;
26 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option]>,
27 HelpText<"Disable builtin #include directories">;
28 @@ -1640,14 +1645,17 @@
29 def nolibc : Flag<["-"], "nolibc">;
30 def nomultidefs : Flag<["-"], "nomultidefs">;
31 def nopie : Flag<["-"], "nopie">;
32 +def noposixc : Flag<["-"], "noposixc">, Alias<no_posixc>;
33 def noprebind : Flag<["-"], "noprebind">;
34 def noseglinkedit : Flag<["-"], "noseglinkedit">;
35 def nostartfiles : Flag<["-"], "nostartfiles">;
36 +def nostdc : Flag<["-"], "nostdc">, Alias<no_stdc>;
37 def nostdinc : Flag<["-"], "nostdinc">;
38 def nostdlibinc : Flag<["-"], "nostdlibinc">;
39 def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>,
40 HelpText<"Disable standard #include directories for the C++ standard library">;
41 def nostdlib : Flag<["-"], "nostdlib">;
42 +def nosysbase : Flag<["-"], "nosysbase">, Alias<no_sysbase>;
43 def object : Flag<["-"], "object">;
44 def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, CC1Option, CC1AsOption]>,
45 HelpText<"Write output to <file>">, MetaVarName<"<file>">;
46 @@ -1660,6 +1668,7 @@
47 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>;
48 def pipe : Flag<["-", "--"], "pipe">,
49 HelpText<"Use pipes between commands, when possible">;
50 +def posixc : Flag<["-"], "posixc">, Flags<[DriverOption,NoArgumentUnused]>;
51 def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">;
52 def prebind : Flag<["-"], "prebind">;
53 def preload : Flag<["-"], "preload">;
54 @@ -1728,6 +1737,7 @@
55 def static_libgcc : Flag<["-"], "static-libgcc">;
56 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
57 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
58 +def stdc : Flag<["-"], "stdc">, Flags<[DriverOption,NoArgumentUnused]>;
59 def std_default_EQ : Joined<["-"], "std-default=">;
60 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
61 Group<CompileOnly_Group>, HelpText<"Language standard to compile for">;
62 diff -ruN cfe-3.8.0.src/lib/Driver/AROSToolChain.cpp cfe-3.8.0.src.aros/lib/Driver/AROSToolChain.cpp
63 --- cfe-3.8.0.src/lib/Driver/AROSToolChain.cpp 1970-01-01 01:00:00.000000000 +0100
64 +++ cfe-3.8.0.src.aros/lib/Driver/AROSToolChain.cpp 2016-04-09 07:41:03.281079459 +0100
65 @@ -0,0 +1,153 @@
66 +//===--- AROSToolChain.cpp - AROS Tool Chain -------------===//
67 +//
68 +// The LLVM Compiler Infrastructure
69 +//
70 +// This file is distributed under the University of Illinois Open Source
71 +// License. See LICENSE.TXT for details.
72 +//
73 +//===----------------------------------------------------------------------===//
75 +#include "ToolChains.h"
76 +#include "clang/Driver/Driver.h"
77 +#include "clang/Driver/Options.h"
78 +#include "llvm/Option/ArgList.h"
80 +using namespace clang::driver;
81 +using namespace clang::driver::toolchains;
83 +AROSToolChain::AROSToolChain(const Driver &D,
84 + const llvm::Triple &T,
85 + const llvm::opt::ArgList &Args)
86 + : Generic_GCC(D, T, Args) {
87 + if (GetCXXStdlibType(Args) == ToolChain::CST_Libstdcxx) {
89 + }
91 + // Use LLD by default.
92 + DefaultLinker = "lld";
95 +#if (0)
96 +bool AROSToolChain::IsUnwindTablesDefault() const {
97 + // FIXME: all non-x86 targets need unwind tables, however, LLVM currently does
98 + // not know how to emit them.
99 + return getArch() == llvm::Triple::x86_64;
102 +bool AROSToolChain::isPICDefault() const {
103 + return getArch() == llvm::Triple::x86_64;
106 +bool AROSToolChain::isPIEDefault() const {
107 + return getArch() == llvm::Triple::x86_64;
110 +bool AROSToolChain::isPICDefaultForced() const {
111 + return getArch() == llvm::Triple::x86_64;
113 +#endif
115 +void AROSToolChain::
116 +AddAROSSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
117 + llvm::opt::ArgStringList &CC1Args) const {
118 + const Driver &D = getDriver();
119 + const std::string &SysRoot = D.SysRoot;
121 + if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
122 + addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
123 + if (!DriverArgs.hasArg(options::OPT_no_posixc)) {
124 + SmallString<128> ResourceDir(SysRoot);
125 + llvm::sys::path::append(ResourceDir, "include/aros/posixc");
126 + addSystemInclude(DriverArgs, CC1Args, ResourceDir);
128 + if (!DriverArgs.hasArg(options::OPT_no_stdc)) {
129 + SmallString<128> ResourceDir(SysRoot);
130 + llvm::sys::path::append(ResourceDir, "include/aros/stdc");
131 + addSystemInclude(DriverArgs, CC1Args, ResourceDir);
136 +void AROSToolChain::
137 +AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
138 + llvm::opt::ArgStringList &CC1Args) const {
139 + if (DriverArgs.hasArg(options::OPT_nostdlibinc))
140 + return;
142 + AddAROSSystemIncludeArgs(DriverArgs, CC1Args);
145 +void AROSToolChain::
146 +addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
147 + llvm::opt::ArgStringList &CC1Args) const {
148 + CC1Args.push_back("-D__AROS__");
149 + CC1Args.push_back("-D__AROS");
150 + CC1Args.push_back("-DAROS");
151 + CC1Args.push_back("-D__AMIGA__");
152 + CC1Args.push_back("-D_AMIGA");
153 + CC1Args.push_back("-DAMIGA");
154 + CC1Args.push_back("-D__ELF__");
155 + CC1Args.push_back("-Dsystem=posix");
159 +void AROSToolChain::
160 +AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
161 + llvm::opt::ArgStringList &CC1Args) const {
162 + if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
163 + DriverArgs.hasArg(options::OPT_nostdincxx))
164 + return;
166 + switch (GetCXXStdlibType(DriverArgs)) {
167 + case ToolChain::CST_Libcxx:
168 + AddAROSSystemIncludeArgs(DriverArgs, CC1Args);
169 + break;
171 + case ToolChain::CST_Libstdcxx:
172 + AddAROSSystemIncludeArgs(DriverArgs, CC1Args);
173 + break;
177 +void AROSToolChain::
178 +AddCXXStdlibLibArgs(const llvm::opt::ArgList &DriverArgs,
179 + llvm::opt::ArgStringList &CC1Args) const {
180 + switch (GetCXXStdlibType(DriverArgs)) {
181 + case ToolChain::CST_Libcxx:
182 + CC1Args.push_back("-lc++");
183 + break;
184 + case ToolChain::CST_Libstdcxx:
185 + CC1Args.push_back("-lstdc++");
186 + break;
190 +void AROSToolChain::
191 +addStartObjectFileArgs(const llvm::opt::ArgList &Args,
192 + llvm::opt::ArgStringList &CmdArgs) const {
193 + if (Args.hasArg(options::OPT_nostartfiles))
194 + return;
196 + const Driver &D = getDriver();
197 + const std::string &SysRoot = D.SysRoot;
198 + SmallString<128> LibPath(SysRoot);
199 + llvm::sys::path::append(LibPath, "lib/");
201 + // Derived from startfile spec.
202 + CmdArgs.push_back(Args.MakeArgString(LibPath + "startup.o"));
203 + if (Args.hasArg(options::OPT_detach)) {
204 + CmdArgs.push_back(Args.MakeArgString(LibPath + "detach.o"));
206 + if (Args.hasArg(options::OPT_nix)) {
207 + CmdArgs.push_back(Args.MakeArgString(LibPath + "nixmain.o"));
212 +Tool *AROSToolChain::buildAssembler() const {
213 + return new tools::AROS::Assembler(*this);
216 +Tool *AROSToolChain::buildLinker() const {
217 + return new tools::AROS::Linker(*this);
219 diff -ruN cfe-3.8.0.src/lib/Driver/CMakeLists.txt cfe-3.8.0.src.aros/lib/Driver/CMakeLists.txt
220 --- cfe-3.8.0.src/lib/Driver/CMakeLists.txt 2015-07-02 05:45:27.000000000 +0100
221 +++ cfe-3.8.0.src.aros/lib/Driver/CMakeLists.txt 2016-03-30 04:30:00.448186485 +0100
222 @@ -5,6 +5,7 @@
224 add_clang_library(clangDriver
225 Action.cpp
226 + AROSToolChain.cpp
227 Compilation.cpp
228 CrossWindowsToolChain.cpp
229 Driver.cpp
230 diff -ruN cfe-3.8.0.src/lib/Driver/Driver.cpp cfe-3.8.0.src.aros/lib/Driver/Driver.cpp
231 --- cfe-3.8.0.src/lib/Driver/Driver.cpp 2016-01-11 23:27:13.000000000 +0000
232 +++ cfe-3.8.0.src.aros/lib/Driver/Driver.cpp 2016-03-30 04:30:00.449186497 +0100
233 @@ -2206,6 +2206,9 @@
234 ToolChain *&TC = ToolChains[Target.str()];
235 if (!TC) {
236 switch (Target.getOS()) {
237 + case llvm::Triple::AROS:
238 + TC = new toolchains::AROSToolChain(*this, Target, Args);
239 + break;
240 case llvm::Triple::CloudABI:
241 TC = new toolchains::CloudABI(*this, Target, Args);
242 break;
243 diff -ruN cfe-3.8.0.src/lib/Driver/ToolChains.h cfe-3.8.0.src.aros/lib/Driver/ToolChains.h
244 --- cfe-3.8.0.src/lib/Driver/ToolChains.h 2016-02-16 19:56:48.000000000 +0000
245 +++ cfe-3.8.0.src.aros/lib/Driver/ToolChains.h 2016-04-09 05:26:47.644569258 +0100
246 @@ -350,6 +350,37 @@
247 /// }
250 +/// AROS - The base AROS tool chain.
251 +class LLVM_LIBRARY_VISIBILITY AROSToolChain : public Generic_GCC {
252 +public:
253 + AROSToolChain(const Driver &D, const llvm::Triple &T,
254 + const llvm::opt::ArgList &Args);
256 + void
257 + AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
258 + llvm::opt::ArgStringList &CC1Args) const override;
259 + void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
260 + llvm::opt::ArgStringList &CC1Args) const override;
261 + void AddClangCXXStdlibIncludeArgs(
262 + const llvm::opt::ArgList &DriverArgs,
263 + llvm::opt::ArgStringList &CC1Args) const override;
264 + void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
265 + llvm::opt::ArgStringList &CmdArgs) const override;
267 + void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
268 + llvm::opt::ArgStringList &CmdArgs) const;
270 +private:
271 + void
272 + AddAROSSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
273 + llvm::opt::ArgStringList &CC1Args) const;
275 +protected:
276 + Tool *buildAssembler() const override;
277 + Tool *buildLinker() const override;
281 /// Darwin - The base Darwin tool chain.
282 class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
283 public:
284 diff -ruN cfe-3.8.0.src/lib/Driver/Tools.cpp cfe-3.8.0.src.aros/lib/Driver/Tools.cpp
285 --- cfe-3.8.0.src/lib/Driver/Tools.cpp 2016-02-12 22:51:41.000000000 +0000
286 +++ cfe-3.8.0.src.aros/lib/Driver/Tools.cpp 2016-04-09 06:37:10.743164748 +0100
287 @@ -6814,6 +6814,132 @@
288 return Args.MakeArgString(Res + ".d");
291 +void AROS::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
292 + const InputInfo &Output,
293 + const InputInfoList &Inputs,
294 + const ArgList &Args,
295 + const char *LinkingOutput) const {
296 + claimNoWarnArgs(Args);
297 + ArgStringList CmdArgs;
299 + CmdArgs.push_back("-o");
300 + CmdArgs.push_back(Output.getFilename());
302 + for (const auto &II : Inputs)
303 + CmdArgs.push_back(II.getFilename());
305 + const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
306 + C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
309 +void AROS::Linker::ConstructJob(Compilation &C, const JobAction &JA,
310 + const InputInfo &Output,
311 + const InputInfoList &Inputs,
312 + const ArgList &Args,
313 + const char *LinkingOutput) const {
314 + const toolchains::AROSToolChain &AROSTC = static_cast<const toolchains::AROSToolChain &>(getToolChain());
315 + const char *Exec = Args.MakeArgString(AROSTC.GetLinkerPath());
316 + const Driver &D = AROSTC.getDriver();
317 + const std::string &SysRoot = D.SysRoot;
318 + ArgStringList CmdArgs;
320 + if (llvm::sys::path::filename(Exec) == "lld") {
321 + CmdArgs.push_back("-flavor");
322 + CmdArgs.push_back("gnu");
323 + if (!D.SysRoot.empty())
324 + CmdArgs.push_back(Args.MakeArgString("--sysroot=" + SysRoot));
327 + // When building 32-bit code on AROS/pc64, we have to explicitly
328 + // instruct ld in the base system to link 32-bit code.
329 + if (AROSTC.getArch() == llvm::Triple::x86) {
330 + CmdArgs.push_back("-m");
331 + CmdArgs.push_back("elf_i386");
334 + if (Output.isFilename()) {
335 + CmdArgs.push_back("-o");
336 + CmdArgs.push_back(Output.getFilename());
337 + } else {
338 + assert(Output.isNothing() && "Invalid output.");
341 + AROSTC.addStartObjectFileArgs(Args, CmdArgs);
343 + Args.AddAllArgs(CmdArgs,
344 + {options::OPT_L, options::OPT_T_Group, options::OPT_e});
346 + AddLinkerInputs(AROSTC, Inputs, Args, CmdArgs);
348 + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
349 + SmallString<128> LibPath(SysRoot);
350 + llvm::sys::path::append(LibPath, "lib");
351 + CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
353 + if (D.CCCIsCXX()) {
354 + AROSTC.AddCXXStdlibLibArgs(Args, CmdArgs);
355 + CmdArgs.push_back("-lpthread");
358 + CmdArgs.push_back("--start-group");
359 + CmdArgs.push_back("-lmui");
360 + CmdArgs.push_back("-larossupport");
361 + CmdArgs.push_back("-lamiga");
362 + if (!Args.hasArg(options::OPT_nostartfiles)) {
363 + if (!Args.hasArg(options::OPT_static)) {
364 + if (!Args.hasArg(options::OPT_no_stdc)) {
365 + if (!Args.hasArg(options::OPT_no_posixc)) {
366 + CmdArgs.push_back("-lposixc");
368 + CmdArgs.push_back("-lstdcio");
369 + CmdArgs.push_back("-lstdc");
372 + else
374 + if (!Args.hasArg(options::OPT_no_stdc)) {
375 + CmdArgs.push_back("-lstdc.static");
379 + CmdArgs.push_back("-lcodesets");
380 + CmdArgs.push_back("-lkeymap");
381 + CmdArgs.push_back("-lexpansion");
382 + CmdArgs.push_back("-lcommodities");
383 + CmdArgs.push_back("-ldiskfont");
384 + CmdArgs.push_back("-lasl");
385 + CmdArgs.push_back("-lmuimaster");
386 + CmdArgs.push_back("-ldatatypes");
387 + CmdArgs.push_back("-lcybergraphics");
388 + CmdArgs.push_back("-lworkbench");
389 + CmdArgs.push_back("-licon");
390 + CmdArgs.push_back("-lintuition");
391 + CmdArgs.push_back("-lgadtools");
392 + CmdArgs.push_back("-llayers");
393 + CmdArgs.push_back("-laros");
394 + CmdArgs.push_back("-lpartition");
395 + CmdArgs.push_back("-liffparse");
396 + CmdArgs.push_back("-lgraphics");
397 + CmdArgs.push_back("-llocale");
398 + CmdArgs.push_back("-ldos");
399 + CmdArgs.push_back("-lutility");
400 + CmdArgs.push_back("-loop");
401 + if (!Args.hasArg(options::OPT_nosysbase)) {
402 + CmdArgs.push_back("-lexec");
404 + CmdArgs.push_back("-lautoinit");
405 + CmdArgs.push_back("-llibinit");
406 + if (!Args.hasArg(options::OPT_nostartfiles)) {
407 + if (!Args.hasArg(options::OPT_static)) {
408 + CmdArgs.push_back("-lstdc.static");
411 + CmdArgs.push_back("--end-group");
414 + C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
417 void cloudabi::Linker::ConstructJob(Compilation &C, const JobAction &JA,
418 const InputInfo &Output,
419 const InputInfoList &Inputs,
420 diff -ruN cfe-3.8.0.src/lib/Driver/Tools.h cfe-3.8.0.src.aros/lib/Driver/Tools.h
421 --- cfe-3.8.0.src/lib/Driver/Tools.h 2016-01-08 15:14:31.000000000 +0000
422 +++ cfe-3.8.0.src.aros/lib/Driver/Tools.h 2016-04-09 05:25:04.263234238 +0100
423 @@ -27,6 +27,7 @@
424 class Driver;
426 namespace toolchains {
427 +class AROSToolChain;
428 class MachO;
431 @@ -308,6 +309,36 @@
432 bool hasPPCAbiArg(const llvm::opt::ArgList &Args, const char *Value);
433 } // end namespace ppc
436 +/// AROS --
437 +namespace AROS {
438 +class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
439 +public:
440 + Assembler(const ToolChain &TC)
441 + : GnuTool("AROS::Assembler", "assembler", TC) {}
443 + bool hasIntegratedCPP() const override { return false; }
445 + void ConstructJob(Compilation &C, const JobAction &JA,
446 + const InputInfo &Output, const InputInfoList &Inputs,
447 + const llvm::opt::ArgList &TCArgs,
448 + const char *LinkingOutput) const override;
451 +class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
452 +public:
453 + Linker(const ToolChain &TC) : GnuTool("AROS::Linker", "linker", TC) {}
455 + bool hasIntegratedCPP() const override { return false; }
456 + bool isLinkJob() const override { return true; }
458 + void ConstructJob(Compilation &C, const JobAction &JA,
459 + const InputInfo &Output, const InputInfoList &Inputs,
460 + const llvm::opt::ArgList &TCArgs,
461 + const char *LinkingOutput) const override;
463 +} // end namespace AROS
465 /// cloudabi -- Directly call GNU Binutils linker
466 namespace cloudabi {
467 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
468 diff -ruN cfe-3.8.0.src/lib/Frontend/InitHeaderSearch.cpp cfe-3.8.0.src.aros/lib/Frontend/InitHeaderSearch.cpp
469 --- cfe-3.8.0.src/lib/Frontend/InitHeaderSearch.cpp 2015-12-30 03:40:23.000000000 +0000
470 +++ cfe-3.8.0.src.aros/lib/Frontend/InitHeaderSearch.cpp 2016-03-30 04:30:00.450186509 +0100
471 @@ -210,6 +210,7 @@
473 if (HSOpts.UseStandardSystemIncludes) {
474 switch (os) {
475 + case llvm::Triple::AROS:
476 case llvm::Triple::CloudABI:
477 case llvm::Triple::FreeBSD:
478 case llvm::Triple::NetBSD:
479 @@ -317,6 +318,7 @@
482 switch (os) {
483 + case llvm::Triple::AROS:
484 case llvm::Triple::CloudABI:
485 case llvm::Triple::RTEMS:
486 case llvm::Triple::NaCl: