authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-03 13:43:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-03 13:43:51-07:00
log3479294b6e7cae323f2e2f05dbc173e2b1a4b9e1
tree1427cfac72a0bc1e7036a04395dca876d910d02a
parent308f72701af0a44bdb2cb2893f3175b7d37f657b

update llvm and clang tools to release/14.x

upstream commit 91632c8ac97fa3daffe4ff8f1391735b5d6805e6

4 files changed, 62 insertions(+), 78 deletions(-)

src/zig_clang_cc1_main.cpp+5-3
...@@ -28,6 +28,7 @@...@@ -28,6 +28,7 @@
28#include "llvm/ADT/Statistic.h"28#include "llvm/ADT/Statistic.h"
29#include "llvm/Config/llvm-config.h"29#include "llvm/Config/llvm-config.h"
30#include "llvm/LinkAllPasses.h"30#include "llvm/LinkAllPasses.h"
31#include "llvm/MC/TargetRegistry.h"
31#include "llvm/Option/Arg.h"32#include "llvm/Option/Arg.h"
32#include "llvm/Option/ArgList.h"33#include "llvm/Option/ArgList.h"
33#include "llvm/Option/OptTable.h"34#include "llvm/Option/OptTable.h"
...@@ -38,7 +39,6 @@...@@ -38,7 +39,6 @@
38#include "llvm/Support/Path.h"39#include "llvm/Support/Path.h"
39#include "llvm/Support/Process.h"40#include "llvm/Support/Process.h"
40#include "llvm/Support/Signals.h"41#include "llvm/Support/Signals.h"
41#include "llvm/Support/TargetRegistry.h"
42#include "llvm/Support/TargetSelect.h"42#include "llvm/Support/TargetSelect.h"
43#include "llvm/Support/TimeProfiler.h"43#include "llvm/Support/TimeProfiler.h"
44#include "llvm/Support/Timer.h"44#include "llvm/Support/Timer.h"
...@@ -57,7 +57,7 @@ using namespace llvm::opt;...@@ -57,7 +57,7 @@ using namespace llvm::opt;
57// Main driver57// Main driver
58//===----------------------------------------------------------------------===//58//===----------------------------------------------------------------------===//
5959
60static void LLVMErrorHandler(void *UserData, const std::string &Message,60static void LLVMErrorHandler(void *UserData, const char *Message,
61 bool GenCrashDiag) {61 bool GenCrashDiag) {
62 DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);62 DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);
6363
...@@ -237,8 +237,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {...@@ -237,8 +237,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
237 static_cast<void*>(&Clang->getDiagnostics()));237 static_cast<void*>(&Clang->getDiagnostics()));
238238
239 DiagsBuffer->FlushDiagnostics(Clang->getDiagnostics());239 DiagsBuffer->FlushDiagnostics(Clang->getDiagnostics());
240 if (!Success)240 if (!Success) {
241 Clang->getDiagnosticClient().finish();
241 return 1;242 return 1;
243 }
242244
243 // Execute the frontend actions.245 // Execute the frontend actions.
244 {246 {
src/zig_clang_cc1as_main.cpp+3-4
...@@ -36,6 +36,7 @@...@@ -36,6 +36,7 @@
36#include "llvm/MC/MCStreamer.h"36#include "llvm/MC/MCStreamer.h"
37#include "llvm/MC/MCSubtargetInfo.h"37#include "llvm/MC/MCSubtargetInfo.h"
38#include "llvm/MC/MCTargetOptions.h"38#include "llvm/MC/MCTargetOptions.h"
39#include "llvm/MC/TargetRegistry.h"
39#include "llvm/Option/Arg.h"40#include "llvm/Option/Arg.h"
40#include "llvm/Option/ArgList.h"41#include "llvm/Option/ArgList.h"
41#include "llvm/Option/OptTable.h"42#include "llvm/Option/OptTable.h"
...@@ -49,7 +50,6 @@...@@ -49,7 +50,6 @@
49#include "llvm/Support/Process.h"50#include "llvm/Support/Process.h"
50#include "llvm/Support/Signals.h"51#include "llvm/Support/Signals.h"
51#include "llvm/Support/SourceMgr.h"52#include "llvm/Support/SourceMgr.h"
52#include "llvm/Support/TargetRegistry.h"
53#include "llvm/Support/TargetSelect.h"53#include "llvm/Support/TargetSelect.h"
54#include "llvm/Support/Timer.h"54#include "llvm/Support/Timer.h"
55#include "llvm/Support/raw_ostream.h"55#include "llvm/Support/raw_ostream.h"
...@@ -228,7 +228,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,...@@ -228,7 +228,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
228 llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())228 llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
229 .Case("none", llvm::DebugCompressionType::None)229 .Case("none", llvm::DebugCompressionType::None)
230 .Case("zlib", llvm::DebugCompressionType::Z)230 .Case("zlib", llvm::DebugCompressionType::Z)
231 .Case("zlib-gnu", llvm::DebugCompressionType::GNU)
232 .Default(llvm::DebugCompressionType::None);231 .Default(llvm::DebugCompressionType::None);
233 }232 }
234233
...@@ -490,7 +489,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,...@@ -490,7 +489,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
490 T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,489 T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
491 Opts.RelaxAll, Opts.IncrementalLinkerCompatible,490 Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
492 /*DWARFMustBeAtTheEnd*/ true));491 /*DWARFMustBeAtTheEnd*/ true));
493 Str.get()->InitSections(Opts.NoExecStack);492 Str.get()->initSections(Opts.NoExecStack, *STI);
494 }493 }
495494
496 // When -fembed-bitcode is passed to clang_as, a 1-byte marker495 // When -fembed-bitcode is passed to clang_as, a 1-byte marker
...@@ -550,7 +549,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,...@@ -550,7 +549,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
550 return Failed;549 return Failed;
551}550}
552551
553static void LLVMErrorHandler(void *UserData, const std::string &Message,552static void LLVMErrorHandler(void *UserData, const char *Message,
554 bool GenCrashDiag) {553 bool GenCrashDiag) {
555 DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);554 DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);
556555
src/zig_clang_driver.cpp+22-44
...@@ -120,7 +120,7 @@ static void ApplyOneQAOverride(raw_ostream &OS,...@@ -120,7 +120,7 @@ static void ApplyOneQAOverride(raw_ostream &OS,
120 OS << "### Adding argument " << Str << " at end\n";120 OS << "### Adding argument " << Str << " at end\n";
121 Args.push_back(Str);121 Args.push_back(Str);
122 } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") &&122 } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") &&
123 Edit.slice(2, Edit.size()-1).find('/') != StringRef::npos) {123 Edit.slice(2, Edit.size() - 1).contains('/')) {
124 StringRef MatchPattern = Edit.substr(2).split('/').first;124 StringRef MatchPattern = Edit.substr(2).split('/').first;
125 StringRef ReplPattern = Edit.substr(2).split('/').second;125 StringRef ReplPattern = Edit.substr(2).split('/').second;
126 ReplPattern = ReplPattern.slice(0, ReplPattern.size()-1);126 ReplPattern = ReplPattern.slice(0, ReplPattern.size()-1);
...@@ -207,6 +207,8 @@ extern int cc1_main(ArrayRef<const char *> Argv, const char *Argv0,...@@ -207,6 +207,8 @@ extern int cc1_main(ArrayRef<const char *> Argv, const char *Argv0,
207 void *MainAddr);207 void *MainAddr);
208extern int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0,208extern int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0,
209 void *MainAddr);209 void *MainAddr);
210extern int cc1gen_reproducer_main(ArrayRef<const char *> Argv,
211 const char *Argv0, void *MainAddr);
210212
211static void insertTargetAndModeArgs(const ParsedClangName &NameParts,213static void insertTargetAndModeArgs(const ParsedClangName &NameParts,
212 SmallVectorImpl<const char *> &ArgVector,214 SmallVectorImpl<const char *> &ArgVector,
...@@ -276,27 +278,6 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,...@@ -276,27 +278,6 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
276 DiagClient->setPrefix(std::string(ExeBasename));278 DiagClient->setPrefix(std::string(ExeBasename));
277}279}
278280
279// This lets us create the DiagnosticsEngine with a properly-filled-out
280// DiagnosticOptions instance.
281static DiagnosticOptions *
282CreateAndPopulateDiagOpts(ArrayRef<const char *> argv, bool &UseNewCC1Process) {
283 auto *DiagOpts = new DiagnosticOptions;
284 unsigned MissingArgIndex, MissingArgCount;
285 InputArgList Args = getDriverOptTable().ParseArgs(
286 argv.slice(1), MissingArgIndex, MissingArgCount);
287 // We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
288 // Any errors that would be diagnosed here will also be diagnosed later,
289 // when the DiagnosticsEngine actually exists.
290 (void)ParseDiagnosticArgs(*DiagOpts, Args);
291
292 UseNewCC1Process =
293 Args.hasFlag(clang::driver::options::OPT_fno_integrated_cc1,
294 clang::driver::options::OPT_fintegrated_cc1,
295 /*Default=*/CLANG_SPAWN_CC1);
296
297 return DiagOpts;
298}
299
300static void SetInstallDir(SmallVectorImpl<const char *> &argv,281static void SetInstallDir(SmallVectorImpl<const char *> &argv,
301 Driver &TheDriver, bool CanonicalPrefixes) {282 Driver &TheDriver, bool CanonicalPrefixes) {
302 // Attempt to find the original path used to invoke the driver, to determine283 // Attempt to find the original path used to invoke the driver, to determine
...@@ -337,28 +318,22 @@ static int ExecuteCC1Tool(SmallVectorImpl<const char *> &ArgV) {...@@ -337,28 +318,22 @@ static int ExecuteCC1Tool(SmallVectorImpl<const char *> &ArgV) {
337 if (Tool == "-cc1as")318 if (Tool == "-cc1as")
338 return cc1as_main(makeArrayRef(ArgV).slice(2), ArgV[0],319 return cc1as_main(makeArrayRef(ArgV).slice(2), ArgV[0],
339 GetExecutablePathVP);320 GetExecutablePathVP);
321 if (Tool == "-cc1gen-reproducer")
322 return cc1gen_reproducer_main(makeArrayRef(ArgV).slice(2), ArgV[0],
323 GetExecutablePathVP);
340 // Reject unknown tools.324 // Reject unknown tools.
341 llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "325 llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "
342 << "Valid tools include '-cc1' and '-cc1as'.\n";326 << "Valid tools include '-cc1' and '-cc1as'.\n";
343 return 1;327 return 1;
344}328}
345329
346extern "C" int ZigClang_main(int Argc, const char **Argv);330int main(int Argc, const char **Argv) {
347int ZigClang_main(int Argc, const char **Argv) {
348 noteBottomOfStack();331 noteBottomOfStack();
349 // ZIG PATCH: On Windows, InitLLVM calls GetCommandLineW(),332 llvm::InitLLVM X(Argc, Argv);
350 // and overwrites the args. We don't want it to do that,
351 // and we also don't need the signal handlers it installs
352 // (we have our own already), so we just use llvm_shutdown_obj
353 // instead.
354 // llvm::InitLLVM X(Argc, Argv);
355 llvm::llvm_shutdown_obj X;
356
357 llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL333 llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL
358 " and include the crash backtrace, preprocessed "334 " and include the crash backtrace, preprocessed "
359 "source, and associated run script.\n");335 "source, and associated run script.\n");
360 size_t argv_offset = (strcmp(Argv[1], "-cc1") == 0 || strcmp(Argv[1], "-cc1as") == 0) ? 0 : 1;336 SmallVector<const char *, 256> Args(Argv, Argv + Argc);
361 SmallVector<const char *, 256> Args(Argv + argv_offset, Argv + Argc);
362337
363 if (llvm::sys::Process::FixupStandardFileDescriptors())338 if (llvm::sys::Process::FixupStandardFileDescriptors())
364 return 1;339 return 1;
...@@ -402,8 +377,8 @@ int ZigClang_main(int Argc, const char **Argv) {...@@ -402,8 +377,8 @@ int ZigClang_main(int Argc, const char **Argv) {
402377
403 // Handle -cc1 integrated tools, even if -cc1 was expanded from a response378 // Handle -cc1 integrated tools, even if -cc1 was expanded from a response
404 // file.379 // file.
405 auto FirstArg = std::find_if(Args.begin() + 1, Args.end(),380 auto FirstArg = llvm::find_if(llvm::drop_begin(Args),
406 [](const char *A) { return A != nullptr; });381 [](const char *A) { return A != nullptr; });
407 if (FirstArg != Args.end() && StringRef(*FirstArg).startswith("-cc1")) {382 if (FirstArg != Args.end() && StringRef(*FirstArg).startswith("-cc1")) {
408 // If -cc1 came from a response file, remove the EOL sentinels.383 // If -cc1 came from a response file, remove the EOL sentinels.
409 if (MarkEOLs) {384 if (MarkEOLs) {
...@@ -420,10 +395,10 @@ int ZigClang_main(int Argc, const char **Argv) {...@@ -420,10 +395,10 @@ int ZigClang_main(int Argc, const char **Argv) {
420 // Skip end-of-line response file markers395 // Skip end-of-line response file markers
421 if (Args[i] == nullptr)396 if (Args[i] == nullptr)
422 continue;397 continue;
423 if (StringRef(Args[i]) == "-no-canonical-prefixes") {398 if (StringRef(Args[i]) == "-canonical-prefixes")
399 CanonicalPrefixes = true;
400 else if (StringRef(Args[i]) == "-no-canonical-prefixes")
424 CanonicalPrefixes = false;401 CanonicalPrefixes = false;
425 break;
426 }
427 }402 }
428403
429 // Handle CL and _CL_ which permits additional command line options to be404 // Handle CL and _CL_ which permits additional command line options to be
...@@ -457,18 +432,21 @@ int ZigClang_main(int Argc, const char **Argv) {...@@ -457,18 +432,21 @@ int ZigClang_main(int Argc, const char **Argv) {
457 ApplyQAOverride(Args, OverrideStr, SavedStrings);432 ApplyQAOverride(Args, OverrideStr, SavedStrings);
458 }433 }
459434
460 // Pass local param `Argv[0]` as fallback.435 std::string Path = GetExecutablePath(Args[0], CanonicalPrefixes);
461 // See https://github.com/ziglang/zig/pull/3292 .
462 std::string Path = GetExecutablePath(Argv[0], CanonicalPrefixes);
463436
464 // Whether the cc1 tool should be called inside the current process, or if we437 // Whether the cc1 tool should be called inside the current process, or if we
465 // should spawn a new clang subprocess (old behavior).438 // should spawn a new clang subprocess (old behavior).
466 // Not having an additional process saves some execution time of Windows,439 // Not having an additional process saves some execution time of Windows,
467 // and makes debugging and profiling easier.440 // and makes debugging and profiling easier.
468 bool UseNewCC1Process;441 bool UseNewCC1Process = CLANG_SPAWN_CC1;
442 for (const char *Arg : Args)
443 UseNewCC1Process = llvm::StringSwitch<bool>(Arg)
444 .Case("-fno-integrated-cc1", true)
445 .Case("-fintegrated-cc1", false)
446 .Default(UseNewCC1Process);
469447
470 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts =448 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts =
471 CreateAndPopulateDiagOpts(Args, UseNewCC1Process);449 CreateAndPopulateDiagOpts(Args);
472450
473 TextDiagnosticPrinter *DiagClient451 TextDiagnosticPrinter *DiagClient
474 = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);452 = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
src/zig_llvm-ar.cpp+32-27
...@@ -90,17 +90,18 @@ OPTIONS:...@@ -90,17 +90,18 @@ OPTIONS:
90 --rsp-quoting - quoting style for response files90 --rsp-quoting - quoting style for response files
91 =posix - posix91 =posix - posix
92 =windows - windows92 =windows - windows
93 --thin - create a thin archive
93 --version - print the version and exit94 --version - print the version and exit
94 @<file> - read options from <file>95 @<file> - read options from <file>
9596
96OPERATIONS:97OPERATIONS:
97 d - delete [files] from the archive98 d - delete [files] from the archive
98 m - move [files] in the archive99 m - move [files] in the archive
99 p - print [files] found in the archive100 p - print contents of [files] found in the archive
100 q - quick append [files] to the archive101 q - quick append [files] to the archive
101 r - replace or insert [files] into the archive102 r - replace or insert [files] into the archive
102 s - act as ranlib103 s - act as ranlib
103 t - display contents of archive104 t - display list of files in archive
104 x - extract [files] from the archive105 x - extract [files] from the archive
105106
106MODIFIERS:107MODIFIERS:
...@@ -118,7 +119,7 @@ MODIFIERS:...@@ -118,7 +119,7 @@ MODIFIERS:
118 [P] - use full names when matching (implied for thin archives)119 [P] - use full names when matching (implied for thin archives)
119 [s] - create an archive index (cf. ranlib)120 [s] - create an archive index (cf. ranlib)
120 [S] - do not build a symbol table121 [S] - do not build a symbol table
121 [T] - create a thin archive122 [T] - deprecated, use --thin instead
122 [u] - update only [files] newer than archive contents123 [u] - update only [files] newer than archive contents
123 [U] - use actual timestamps and uids/gids124 [U] - use actual timestamps and uids/gids
124 [v] - be verbose about actions taken125 [v] - be verbose about actions taken
...@@ -136,14 +137,14 @@ static unsigned MRILineNumber;...@@ -136,14 +137,14 @@ static unsigned MRILineNumber;
136static bool ParsingMRIScript;137static bool ParsingMRIScript;
137138
138// Show the error plus the usage message, and exit.139// Show the error plus the usage message, and exit.
139LLVM_ATTRIBUTE_NORETURN static void badUsage(Twine Error) {140[[noreturn]] static void badUsage(Twine Error) {
140 WithColor::error(errs(), ToolName) << Error << "\n";141 WithColor::error(errs(), ToolName) << Error << "\n";
141 printHelpMessage();142 printHelpMessage();
142 exit(1);143 exit(1);
143}144}
144145
145// Show the error message and exit.146// Show the error message and exit.
146LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) {147[[noreturn]] static void fail(Twine Error) {
147 if (ParsingMRIScript) {148 if (ParsingMRIScript) {
148 WithColor::error(errs(), ToolName)149 WithColor::error(errs(), ToolName)
149 << "script line " << MRILineNumber << ": " << Error << "\n";150 << "script line " << MRILineNumber << ": " << Error << "\n";
...@@ -232,7 +233,7 @@ static std::string ArchiveName;...@@ -232,7 +233,7 @@ static std::string ArchiveName;
232static std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;233static std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;
233static std::vector<std::unique_ptr<object::Archive>> Archives;234static std::vector<std::unique_ptr<object::Archive>> Archives;
234235
235// This variable holds the list of member files to process, as given236// This variable holds the list of member files to proecess, as given
236// on the command line.237// on the command line.
237static std::vector<StringRef> Members;238static std::vector<StringRef> Members;
238239
...@@ -390,8 +391,6 @@ static ArchiveOperation parseCommandLine() {...@@ -390,8 +391,6 @@ static ArchiveOperation parseCommandLine() {
390 break;391 break;
391 case 'T':392 case 'T':
392 Thin = true;393 Thin = true;
393 // Thin archives store path names, so P should be forced.
394 CompareFullPath = true;
395 break;394 break;
396 case 'L':395 case 'L':
397 AddLibrary = true;396 AddLibrary = true;
...@@ -407,6 +406,10 @@ static ArchiveOperation parseCommandLine() {...@@ -407,6 +406,10 @@ static ArchiveOperation parseCommandLine() {
407 }406 }
408 }407 }
409408
409 // Thin archives store path names, so P should be forced.
410 if (Thin)
411 CompareFullPath = true;
412
410 // At this point, the next thing on the command line must be413 // At this point, the next thing on the command line must be
411 // the archive name.414 // the archive name.
412 getArchive();415 getArchive();
...@@ -965,6 +968,8 @@ static void createSymbolTable(object::Archive *OldArchive) {...@@ -965,6 +968,8 @@ static void createSymbolTable(object::Archive *OldArchive) {
965 if (OldArchive->hasSymbolTable())968 if (OldArchive->hasSymbolTable())
966 return;969 return;
967970
971 if (OldArchive->isThin())
972 Thin = true;
968 performWriteOperation(CreateSymTab, OldArchive, nullptr, nullptr);973 performWriteOperation(CreateSymTab, OldArchive, nullptr, nullptr);
969}974}
970975
...@@ -1003,12 +1008,17 @@ static int performOperation(ArchiveOperation Operation,...@@ -1003,12 +1008,17 @@ static int performOperation(ArchiveOperation Operation,
1003 fail("unable to open '" + ArchiveName + "': " + EC.message());1008 fail("unable to open '" + ArchiveName + "': " + EC.message());
10041009
1005 if (!EC) {1010 if (!EC) {
1006 Error Err = Error::success();1011 Expected<std::unique_ptr<object::Archive>> ArchiveOrError =
1007 object::Archive Archive(Buf.get()->getMemBufferRef(), Err);1012 object::Archive::create(Buf.get()->getMemBufferRef());
1008 failIfError(std::move(Err), "unable to load '" + ArchiveName + "'");1013 if (!ArchiveOrError)
1009 if (Archive.isThin())1014 failIfError(ArchiveOrError.takeError(),
1015 "unable to load '" + ArchiveName + "'");
1016
1017 std::unique_ptr<object::Archive> Archive = std::move(ArchiveOrError.get());
1018 if (Archive->isThin())
1010 CompareFullPath = true;1019 CompareFullPath = true;
1011 performOperation(Operation, &Archive, std::move(Buf.get()), NewMembers);1020 performOperation(Operation, Archive.get(), std::move(Buf.get()),
1021 NewMembers);
1012 return 0;1022 return 0;
1013 }1023 }
10141024
...@@ -1111,11 +1121,11 @@ static void runMRIScript() {...@@ -1111,11 +1121,11 @@ static void runMRIScript() {
1111}1121}
11121122
1113static bool handleGenericOption(StringRef arg) {1123static bool handleGenericOption(StringRef arg) {
1114 if (arg == "-help" || arg == "--help" || arg == "-h") {1124 if (arg == "--help" || arg == "-h") {
1115 printHelpMessage();1125 printHelpMessage();
1116 return true;1126 return true;
1117 }1127 }
1118 if (arg == "-version" || arg == "--version") {1128 if (arg == "--version") {
1119 cl::PrintVersionMessage();1129 cl::PrintVersionMessage();
1120 return true;1130 return true;
1121 }1131 }
...@@ -1129,8 +1139,6 @@ static const char *matchFlagWithArg(StringRef Expected,...@@ -1129,8 +1139,6 @@ static const char *matchFlagWithArg(StringRef Expected,
11291139
1130 if (Arg.startswith("--"))1140 if (Arg.startswith("--"))
1131 Arg = Arg.substr(2);1141 Arg = Arg.substr(2);
1132 else if (Arg.startswith("-"))
1133 Arg = Arg.substr(1);
11341142
1135 size_t len = Expected.size();1143 size_t len = Expected.size();
1136 if (Arg == Expected) {1144 if (Arg == Expected) {
...@@ -1199,6 +1207,11 @@ static int ar_main(int argc, char **argv) {...@@ -1199,6 +1207,11 @@ static int ar_main(int argc, char **argv) {
1199 continue;1207 continue;
1200 }1208 }
12011209
1210 if (strcmp(*ArgIt, "--thin") == 0) {
1211 Thin = true;
1212 continue;
1213 }
1214
1202 Match = matchFlagWithArg("format", ArgIt, Argv);1215 Match = matchFlagWithArg("format", ArgIt, Argv);
1203 if (Match) {1216 if (Match) {
1204 FormatType = StringSwitch<Format>(Match)1217 FormatType = StringSwitch<Format>(Match)
...@@ -1261,16 +1274,8 @@ static int ranlib_main(int argc, char **argv) {...@@ -1261,16 +1274,8 @@ static int ranlib_main(int argc, char **argv) {
1261 return performOperation(CreateSymTab, nullptr);1274 return performOperation(CreateSymTab, nullptr);
1262}1275}
12631276
1264extern "C" int ZigLlvmAr_main(int argc, char **argv);1277int main(int argc, char **argv) {
1265int ZigLlvmAr_main(int argc, char **argv) {1278 InitLLVM X(argc, argv);
1266 // ZIG PATCH: On Windows, InitLLVM calls GetCommandLineW(),
1267 // and overwrites the args. We don't want it to do that,
1268 // and we also don't need the signal handlers it installs
1269 // (we have our own already), so we just use llvm_shutdown_obj
1270 // instead.
1271 // InitLLVM X(argc, argv);
1272 llvm::llvm_shutdown_obj X;
1273
1274 ToolName = argv[0];1279 ToolName = argv[0];
12751280
1276 llvm::InitializeAllTargetInfos();1281 llvm::InitializeAllTargetInfos();