authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-28 09:27:07-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-28 09:27:07-05:00
logea73b8e2b83a2b178d476aff6902ef3c95458e24
treeb47746236967a4411233d8e0449435000782cdfc
parent2dcf1a239250e60ec9d8865e16528049074ec4b0
signature Commit is signed but in an unrecognized format.

update clang driver code to 8.0.0rc3


3 files changed, 32 insertions(+), 7 deletions(-)

src/zig_clang_cc1_main.cpp+4-3
...@@ -13,10 +13,9 @@...@@ -13,10 +13,9 @@
13//13//
14//===----------------------------------------------------------------------===//14//===----------------------------------------------------------------------===//
1515
16#include "llvm/Option/Arg.h"16#include "clang/Basic/Stack.h"
17#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"17#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
18#include "clang/Config/config.h"18#include "clang/Config/config.h"
19#include "clang/Basic/Stack.h"
20#include "clang/Driver/DriverDiagnostic.h"19#include "clang/Driver/DriverDiagnostic.h"
21#include "clang/Driver/Options.h"20#include "clang/Driver/Options.h"
22#include "clang/Frontend/CompilerInstance.h"21#include "clang/Frontend/CompilerInstance.h"
...@@ -29,8 +28,10 @@...@@ -29,8 +28,10 @@
29#include "llvm/ADT/Statistic.h"28#include "llvm/ADT/Statistic.h"
30#include "llvm/Config/llvm-config.h"29#include "llvm/Config/llvm-config.h"
31#include "llvm/LinkAllPasses.h"30#include "llvm/LinkAllPasses.h"
31#include "llvm/Option/Arg.h"
32#include "llvm/Option/ArgList.h"32#include "llvm/Option/ArgList.h"
33#include "llvm/Option/OptTable.h"33#include "llvm/Option/OptTable.h"
34#include "llvm/Support/BuryPointer.h"
34#include "llvm/Support/Compiler.h"35#include "llvm/Support/Compiler.h"
35#include "llvm/Support/ErrorHandling.h"36#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/ManagedStatic.h"37#include "llvm/Support/ManagedStatic.h"
...@@ -217,7 +218,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {...@@ -217,7 +218,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
217218
218 // When running with -disable-free, don't do any destruction or shutdown.219 // When running with -disable-free, don't do any destruction or shutdown.
219 if (Clang->getFrontendOpts().DisableFree) {220 if (Clang->getFrontendOpts().DisableFree) {
220 BuryPointer(std::move(Clang));221 llvm::BuryPointer(std::move(Clang));
221 return !Success;222 return !Success;
222 }223 }
223224
src/zig_clang_cc1as_main.cpp+25-1
...@@ -33,6 +33,7 @@...@@ -33,6 +33,7 @@
33#include "llvm/MC/MCParser/MCAsmParser.h"33#include "llvm/MC/MCParser/MCAsmParser.h"
34#include "llvm/MC/MCParser/MCTargetAsmParser.h"34#include "llvm/MC/MCParser/MCTargetAsmParser.h"
35#include "llvm/MC/MCRegisterInfo.h"35#include "llvm/MC/MCRegisterInfo.h"
36#include "llvm/MC/MCSectionMachO.h"
36#include "llvm/MC/MCStreamer.h"37#include "llvm/MC/MCStreamer.h"
37#include "llvm/MC/MCSubtargetInfo.h"38#include "llvm/MC/MCSubtargetInfo.h"
38#include "llvm/MC/MCTargetOptions.h"39#include "llvm/MC/MCTargetOptions.h"
...@@ -132,6 +133,7 @@ struct AssemblerInvocation {...@@ -132,6 +133,7 @@ struct AssemblerInvocation {
132 unsigned NoExecStack : 1;133 unsigned NoExecStack : 1;
133 unsigned FatalWarnings : 1;134 unsigned FatalWarnings : 1;
134 unsigned IncrementalLinkerCompatible : 1;135 unsigned IncrementalLinkerCompatible : 1;
136 unsigned EmbedBitcode : 1;
135137
136 /// The name of the relocation model to use.138 /// The name of the relocation model to use.
137 std::string RelocationModel;139 std::string RelocationModel;
...@@ -153,6 +155,7 @@ public:...@@ -153,6 +155,7 @@ public:
153 FatalWarnings = 0;155 FatalWarnings = 0;
154 IncrementalLinkerCompatible = 0;156 IncrementalLinkerCompatible = 0;
155 DwarfVersion = 0;157 DwarfVersion = 0;
158 EmbedBitcode = 0;
156 }159 }
157160
158 static bool CreateFromArgs(AssemblerInvocation &Res,161 static bool CreateFromArgs(AssemblerInvocation &Res,
...@@ -284,6 +287,16 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,...@@ -284,6 +287,16 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
284 Args.hasArg(OPT_mincremental_linker_compatible);287 Args.hasArg(OPT_mincremental_linker_compatible);
285 Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);288 Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
286289
290 // EmbedBitcode Option. If -fembed-bitcode is enabled, set the flag.
291 // EmbedBitcode behaves the same for all embed options for assembly files.
292 if (auto *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
293 Opts.EmbedBitcode = llvm::StringSwitch<unsigned>(A->getValue())
294 .Case("all", 1)
295 .Case("bitcode", 1)
296 .Case("marker", 1)
297 .Default(0);
298 }
299
287 return Success;300 return Success;
288}301}
289302
...@@ -449,6 +462,16 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,...@@ -449,6 +462,16 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
449 Str.get()->InitSections(Opts.NoExecStack);462 Str.get()->InitSections(Opts.NoExecStack);
450 }463 }
451464
465 // When -fembed-bitcode is passed to clang_as, a 1-byte marker
466 // is emitted in __LLVM,__asm section if the object file is MachO format.
467 if (Opts.EmbedBitcode && Ctx.getObjectFileInfo()->getObjectFileType() ==
468 MCObjectFileInfo::IsMachO) {
469 MCSection *AsmLabel = Ctx.getMachOSection(
470 "__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly());
471 Str.get()->SwitchSection(AsmLabel);
472 Str.get()->EmitZeros(1);
473 }
474
452 // Assembly to object compilation should leverage assembly info.475 // Assembly to object compilation should leverage assembly info.
453 Str->setUseAssemblerInfoForParsing(true);476 Str->setUseAssemblerInfoForParsing(true);
454477
...@@ -534,7 +557,8 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {...@@ -534,7 +557,8 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
534557
535 if (Asm.ShowHelp) {558 if (Asm.ShowHelp) {
536 std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());559 std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());
537 Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",560 Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
561 "Clang Integrated Assembler",
538 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,562 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
539 /*ShowAllAliases=*/false);563 /*ShowAllAliases=*/false);
540 return 0;564 return 0;
src/zig_clang_driver.cpp+3-3
...@@ -258,9 +258,9 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,...@@ -258,9 +258,9 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
258 const std::string &Path) {258 const std::string &Path) {
259 // If the clang binary happens to be named cl.exe for compatibility reasons,259 // If the clang binary happens to be named cl.exe for compatibility reasons,
260 // use clang-cl.exe as the prefix to avoid confusion between clang and MSVC.260 // use clang-cl.exe as the prefix to avoid confusion between clang and MSVC.
261 StringRef ExeBasename(llvm::sys::path::filename(Path));261 StringRef ExeBasename(llvm::sys::path::stem(Path));
262 if (ExeBasename.equals_lower("cl.exe"))262 if (ExeBasename.equals_lower("cl"))
263 ExeBasename = "clang-cl.exe";263 ExeBasename = "clang-cl";
264 DiagClient->setPrefix(ExeBasename);264 DiagClient->setPrefix(ExeBasename);
265}265}
266266