| author | |
| committer | |
| log | de72860de6e920a371806eaf5a65d28a4b606641 |
| tree | ef46a0302e6afc6b407a4784a08fe34b9daacfec |
| parent | 3ac8d37182504da72e151ac93da26a0f01782f95 |
4 files changed, 150 insertions(+), 54 deletions(-)
src/zig_clang_cc1_main.cpp+45| ... | ... | @@ -28,6 +28,7 @@ |
| 28 | 28 | #include "llvm/ADT/Statistic.h" |
| 29 | 29 | #include "llvm/Config/llvm-config.h" |
| 30 | 30 | #include "llvm/LinkAllPasses.h" |
| 31 | #include "llvm/MC/MCSubtargetInfo.h" | |
| 31 | 32 | #include "llvm/MC/TargetRegistry.h" |
| 32 | 33 | #include "llvm/Option/Arg.h" |
| 33 | 34 | #include "llvm/Option/ArgList.h" |
| ... | ... | @@ -38,12 +39,15 @@ |
| 38 | 39 | #include "llvm/Support/ManagedStatic.h" |
| 39 | 40 | #include "llvm/Support/Path.h" |
| 40 | 41 | #include "llvm/Support/Process.h" |
| 42 | #include "llvm/Support/RISCVISAInfo.h" | |
| 41 | 43 | #include "llvm/Support/Signals.h" |
| 42 | 44 | #include "llvm/Support/TargetSelect.h" |
| 43 | 45 | #include "llvm/Support/TimeProfiler.h" |
| 44 | 46 | #include "llvm/Support/Timer.h" |
| 45 | 47 | #include "llvm/Support/raw_ostream.h" |
| 46 | 48 | #include "llvm/Target/TargetMachine.h" |
| 49 | #include "llvm/TargetParser/AArch64TargetParser.h" | |
| 50 | #include "llvm/TargetParser/ARMTargetParser.h" | |
| 47 | 51 | #include <cstdio> |
| 48 | 52 | |
| 49 | 53 | #ifdef CLANG_HAVE_RLIMITS |
| ... | ... | @@ -182,6 +186,43 @@ static int PrintSupportedCPUs(std::string TargetStr) { |
| 182 | 186 | return 0; |
| 183 | 187 | } |
| 184 | 188 | |
| 189 | static int PrintSupportedExtensions(std::string TargetStr) { | |
| 190 | std::string Error; | |
| 191 | const llvm::Target *TheTarget = | |
| 192 | llvm::TargetRegistry::lookupTarget(TargetStr, Error); | |
| 193 | if (!TheTarget) { | |
| 194 | llvm::errs() << Error; | |
| 195 | return 1; | |
| 196 | } | |
| 197 | ||
| 198 | llvm::TargetOptions Options; | |
| 199 | std::unique_ptr<llvm::TargetMachine> TheTargetMachine( | |
| 200 | TheTarget->createTargetMachine(TargetStr, "", "", Options, std::nullopt)); | |
| 201 | const llvm::Triple &MachineTriple = TheTargetMachine->getTargetTriple(); | |
| 202 | const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo(); | |
| 203 | const llvm::ArrayRef<llvm::SubtargetFeatureKV> Features = | |
| 204 | MCInfo->getAllProcessorFeatures(); | |
| 205 | ||
| 206 | llvm::StringMap<llvm::StringRef> DescMap; | |
| 207 | for (const llvm::SubtargetFeatureKV &feature : Features) | |
| 208 | DescMap.insert({feature.Key, feature.Desc}); | |
| 209 | ||
| 210 | if (MachineTriple.isRISCV()) | |
| 211 | llvm::riscvExtensionsHelp(DescMap); | |
| 212 | else if (MachineTriple.isAArch64()) | |
| 213 | llvm::AArch64::PrintSupportedExtensions(DescMap); | |
| 214 | else if (MachineTriple.isARM()) | |
| 215 | llvm::ARM::PrintSupportedExtensions(DescMap); | |
| 216 | else { | |
| 217 | // The option was already checked in Driver::HandleImmediateArgs, | |
| 218 | // so we do not expect to get here if we are not a supported architecture. | |
| 219 | assert(0 && "Unhandled triple for --print-supported-extensions option."); | |
| 220 | return 1; | |
| 221 | } | |
| 222 | ||
| 223 | return 0; | |
| 224 | } | |
| 225 | ||
| 185 | 226 | int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { |
| 186 | 227 | ensureSufficientStack(); |
| 187 | 228 | |
| ... | ... | @@ -221,6 +262,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { |
| 221 | 262 | if (Clang->getFrontendOpts().PrintSupportedCPUs) |
| 222 | 263 | return PrintSupportedCPUs(Clang->getTargetOpts().Triple); |
| 223 | 264 | |
| 265 | // --print-supported-extensions takes priority over the actual compilation. | |
| 266 | if (Clang->getFrontendOpts().PrintSupportedExtensions) | |
| 267 | return PrintSupportedExtensions(Clang->getTargetOpts().Triple); | |
| 268 | ||
| 224 | 269 | // Infer the builtin include path if unspecified. |
| 225 | 270 | if (Clang->getHeaderSearchOpts().UseBuiltinIncludes && |
| 226 | 271 | Clang->getHeaderSearchOpts().ResourceDir.empty()) |
src/zig_clang_cc1as_main.cpp+8-7| ... | ... | @@ -204,10 +204,10 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, |
| 204 | 204 | // Parse the arguments. |
| 205 | 205 | const OptTable &OptTbl = getDriverOptTable(); |
| 206 | 206 | |
| 207 | const unsigned IncludedFlagsBitmask = options::CC1AsOption; | |
| 207 | llvm::opt::Visibility VisibilityMask(options::CC1AsOption); | |
| 208 | 208 | unsigned MissingArgIndex, MissingArgCount; |
| 209 | InputArgList Args = OptTbl.ParseArgs(Argv, MissingArgIndex, MissingArgCount, | |
| 210 | IncludedFlagsBitmask); | |
| 209 | InputArgList Args = | |
| 210 | OptTbl.ParseArgs(Argv, MissingArgIndex, MissingArgCount, VisibilityMask); | |
| 211 | 211 | |
| 212 | 212 | // Check for missing argument error. |
| 213 | 213 | if (MissingArgCount) { |
| ... | ... | @@ -220,7 +220,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, |
| 220 | 220 | for (const Arg *A : Args.filtered(OPT_UNKNOWN)) { |
| 221 | 221 | auto ArgString = A->getAsString(Args); |
| 222 | 222 | std::string Nearest; |
| 223 | if (OptTbl.findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1) | |
| 223 | if (OptTbl.findNearest(ArgString, Nearest, VisibilityMask) > 1) | |
| 224 | 224 | Diags.Report(diag::err_drv_unknown_argument) << ArgString; |
| 225 | 225 | else |
| 226 | 226 | Diags.Report(diag::err_drv_unknown_argument_with_suggestion) |
| ... | ... | @@ -643,9 +643,10 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { |
| 643 | 643 | if (Asm.ShowHelp) { |
| 644 | 644 | getDriverOptTable().printHelp( |
| 645 | 645 | llvm::outs(), "clang -cc1as [options] file...", |
| 646 | "Clang Integrated Assembler", | |
| 647 | /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0, | |
| 648 | /*ShowAllAliases=*/false); | |
| 646 | "Clang Integrated Assembler", /*ShowHidden=*/false, | |
| 647 | /*ShowAllAliases=*/false, | |
| 648 | llvm::opt::Visibility(driver::options::CC1AsOption)); | |
| 649 | ||
| 649 | 650 | return 0; |
| 650 | 651 | } |
| 651 | 652 |
src/zig_clang_driver.cpp+14-23| ... | ... | @@ -36,7 +36,6 @@ |
| 36 | 36 | #include "llvm/Support/CrashRecoveryContext.h" |
| 37 | 37 | #include "llvm/Support/ErrorHandling.h" |
| 38 | 38 | #include "llvm/Support/FileSystem.h" |
| 39 | #include "llvm/Support/InitLLVM.h" | |
| 40 | 39 | #include "llvm/Support/LLVMDriver.h" |
| 41 | 40 | #include "llvm/Support/Path.h" |
| 42 | 41 | #include "llvm/Support/PrettyStackTrace.h" |
| ... | ... | @@ -65,7 +64,7 @@ std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) { |
| 65 | 64 | if (llvm::ErrorOr<std::string> P = |
| 66 | 65 | llvm::sys::findProgramByName(ExecutablePath)) |
| 67 | 66 | ExecutablePath = *P; |
| 68 | return std::string(ExecutablePath.str()); | |
| 67 | return std::string(ExecutablePath); | |
| 69 | 68 | } |
| 70 | 69 | |
| 71 | 70 | // This just needs to be some symbol in the binary; C++ doesn't |
| ... | ... | @@ -79,9 +78,9 @@ static const char *GetStableCStr(std::set<std::string> &SavedStrings, |
| 79 | 78 | return SavedStrings.insert(std::string(S)).first->c_str(); |
| 80 | 79 | } |
| 81 | 80 | |
| 82 | /// ApplyQAOverride - Apply a list of edits to the input argument lists. | |
| 81 | /// ApplyOneQAOverride - Apply a list of edits to the input argument lists. | |
| 83 | 82 | /// |
| 84 | /// The input string is a space separate list of edits to perform, | |
| 83 | /// The input string is a space separated list of edits to perform, | |
| 85 | 84 | /// they are applied in order to the input argument lists. Edits |
| 86 | 85 | /// should be one of the following forms: |
| 87 | 86 | /// |
| ... | ... | @@ -122,7 +121,7 @@ static void ApplyOneQAOverride(raw_ostream &OS, |
| 122 | 121 | GetStableCStr(SavedStrings, Edit.substr(1)); |
| 123 | 122 | OS << "### Adding argument " << Str << " at end\n"; |
| 124 | 123 | Args.push_back(Str); |
| 125 | } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") && | |
| 124 | } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.ends_with("/") && | |
| 126 | 125 | Edit.slice(2, Edit.size() - 1).contains('/')) { |
| 127 | 126 | StringRef MatchPattern = Edit.substr(2).split('/').first; |
| 128 | 127 | StringRef ReplPattern = Edit.substr(2).split('/').second; |
| ... | ... | @@ -177,7 +176,7 @@ static void ApplyOneQAOverride(raw_ostream &OS, |
| 177 | 176 | } |
| 178 | 177 | } |
| 179 | 178 | |
| 180 | /// ApplyQAOverride - Apply a comma separate list of edits to the | |
| 179 | /// ApplyQAOverride - Apply a space separated list of edits to the | |
| 181 | 180 | /// input argument lists. See ApplyOneQAOverride. |
| 182 | 181 | static void ApplyQAOverride(SmallVectorImpl<const char*> &Args, |
| 183 | 182 | const char *OverrideStr, |
| ... | ... | @@ -210,6 +209,9 @@ extern int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, |
| 210 | 209 | void *MainAddr); |
| 211 | 210 | extern int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, |
| 212 | 211 | void *MainAddr); |
| 212 | extern int cc1gen_reproducer_main(ArrayRef<const char *> Argv, | |
| 213 | const char *Argv0, void *MainAddr, | |
| 214 | const llvm::ToolContext &); | |
| 213 | 215 | |
| 214 | 216 | static void insertTargetAndModeArgs(const ParsedClangName &NameParts, |
| 215 | 217 | SmallVectorImpl<const char *> &ArgVector, |
| ... | ... | @@ -363,27 +365,21 @@ static int ExecuteCC1Tool(SmallVectorImpl<const char *> &ArgV, |
| 363 | 365 | return cc1_main(ArrayRef(ArgV).slice(1), ArgV[0], GetExecutablePathVP); |
| 364 | 366 | if (Tool == "-cc1as") |
| 365 | 367 | return cc1as_main(ArrayRef(ArgV).slice(2), ArgV[0], GetExecutablePathVP); |
| 368 | if (Tool == "-cc1gen-reproducer") | |
| 369 | return cc1gen_reproducer_main(ArrayRef(ArgV).slice(2), ArgV[0], | |
| 370 | GetExecutablePathVP, ToolContext); | |
| 366 | 371 | // Reject unknown tools. |
| 367 | 372 | llvm::errs() << "error: unknown integrated tool '" << Tool << "'. " |
| 368 | 373 | << "Valid tools include '-cc1' and '-cc1as'.\n"; |
| 369 | 374 | return 1; |
| 370 | 375 | } |
| 371 | 376 | |
| 372 | static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { | |
| 377 | int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { | |
| 373 | 378 | noteBottomOfStack(); |
| 374 | // ZIG PATCH: On Windows, InitLLVM calls GetCommandLineW(), | |
| 375 | // and overwrites the args. We don't want it to do that, | |
| 376 | // and we also don't need the signal handlers it installs | |
| 377 | // (we have our own already), so we just use llvm_shutdown_obj | |
| 378 | // instead. | |
| 379 | // llvm::InitLLVM X(Argc, Argv); | |
| 380 | llvm::llvm_shutdown_obj X; | |
| 381 | ||
| 382 | 379 | llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL |
| 383 | 380 | " and include the crash backtrace, preprocessed " |
| 384 | 381 | "source, and associated run script.\n"); |
| 385 | size_t argv_offset = (strcmp(Argv[1], "-cc1") == 0 || strcmp(Argv[1], "-cc1as") == 0) ? 0 : 1; | |
| 386 | SmallVector<const char *, 256> Args(Argv + argv_offset, Argv + Argc); | |
| 382 | SmallVector<const char *, 256> Args(Argv, Argv + Argc); | |
| 387 | 383 | |
| 388 | 384 | if (llvm::sys::Process::FixupStandardFileDescriptors()) |
| 389 | 385 | return 1; |
| ... | ... | @@ -405,7 +401,7 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex |
| 405 | 401 | } |
| 406 | 402 | |
| 407 | 403 | // Handle -cc1 integrated tools. |
| 408 | if (Args.size() >= 2 && StringRef(Args[1]).startswith("-cc1")) | |
| 404 | if (Args.size() >= 2 && StringRef(Args[1]).starts_with("-cc1")) | |
| 409 | 405 | return ExecuteCC1Tool(Args, ToolContext); |
| 410 | 406 | |
| 411 | 407 | // Handle options that need handling before the real command line parsing in |
| ... | ... | @@ -605,8 +601,3 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex |
| 605 | 601 | // failing command. |
| 606 | 602 | return Res; |
| 607 | 603 | } |
| 608 | ||
| 609 | extern "C" int ZigClang_main(int, char **); | |
| 610 | int ZigClang_main(int argc, char **argv) { | |
| 611 | return clang_main(argc, argv, {argv[0], nullptr, false}); | |
| 612 | } |
src/zig_llvm-ar.cpp+83-24| ... | ... | @@ -25,7 +25,6 @@ |
| 25 | 25 | #include "llvm/Support/FileSystem.h" |
| 26 | 26 | #include "llvm/Support/Format.h" |
| 27 | 27 | #include "llvm/Support/FormatVariadic.h" |
| 28 | #include "llvm/Support/InitLLVM.h" | |
| 29 | 28 | #include "llvm/Support/LLVMDriver.h" |
| 30 | 29 | #include "llvm/Support/LineIterator.h" |
| 31 | 30 | #include "llvm/Support/MemoryBuffer.h" |
| ... | ... | @@ -69,7 +68,9 @@ static void printRanLibHelp(StringRef ToolName) { |
| 69 | 68 | << " -v --version - Display the version of this program\n" |
| 70 | 69 | << " -D - Use zero for timestamps and uids/gids " |
| 71 | 70 | "(default)\n" |
| 72 | << " -U - Use actual timestamps and uids/gids\n"; | |
| 71 | << " -U - Use actual timestamps and uids/gids\n" | |
| 72 | << " -X{32|64|32_64|any} - Specify which archive symbol tables " | |
| 73 | "should be generated if they do not already exist (AIX OS only)\n"; | |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | 76 | static void printArHelp(StringRef ToolName) { |
| ... | ... | @@ -225,7 +226,8 @@ static bool DisplayMemberOffsets = false; ///< 'O' modifier |
| 225 | 226 | static bool CompareFullPath = false; ///< 'P' modifier |
| 226 | 227 | static bool OnlyUpdate = false; ///< 'u' modifier |
| 227 | 228 | static bool Verbose = false; ///< 'v' modifier |
| 228 | static bool Symtab = true; ///< 's' modifier | |
| 229 | static SymtabWritingMode Symtab = | |
| 230 | SymtabWritingMode::NormalSymtab; ///< 's' modifier | |
| 229 | 231 | static bool Deterministic = true; ///< 'D' and 'U' modifiers |
| 230 | 232 | static bool Thin = false; ///< 'T' modifier |
| 231 | 233 | static bool AddLibrary = false; ///< 'L' modifier |
| ... | ... | @@ -371,11 +373,11 @@ static ArchiveOperation parseCommandLine() { |
| 371 | 373 | CompareFullPath = true; |
| 372 | 374 | break; |
| 373 | 375 | case 's': |
| 374 | Symtab = true; | |
| 376 | Symtab = SymtabWritingMode::NormalSymtab; | |
| 375 | 377 | MaybeJustCreateSymTab = true; |
| 376 | 378 | break; |
| 377 | 379 | case 'S': |
| 378 | Symtab = false; | |
| 380 | Symtab = SymtabWritingMode::NoSymtab; | |
| 379 | 381 | break; |
| 380 | 382 | case 'u': |
| 381 | 383 | OnlyUpdate = true; |
| ... | ... | @@ -1074,9 +1076,31 @@ static void createSymbolTable(object::Archive *OldArchive) { |
| 1074 | 1076 | // In summary, we only need to update the symbol table if we have none. |
| 1075 | 1077 | // This is actually very common because of broken build systems that think |
| 1076 | 1078 | // they have to run ranlib. |
| 1077 | if (OldArchive->hasSymbolTable()) | |
| 1078 | return; | |
| 1079 | if (OldArchive->hasSymbolTable()) { | |
| 1080 | if (OldArchive->kind() != object::Archive::K_AIXBIG) | |
| 1081 | return; | |
| 1079 | 1082 | |
| 1083 | // For archives in the Big Archive format, the bit mode option specifies | |
| 1084 | // which symbol table to generate. The presence of a symbol table that does | |
| 1085 | // not match the specified bit mode does not prevent creation of the symbol | |
| 1086 | // table that has been requested. | |
| 1087 | if (OldArchive->kind() == object::Archive::K_AIXBIG) { | |
| 1088 | BigArchive *BigArc = dyn_cast<BigArchive>(OldArchive); | |
| 1089 | if (BigArc->has32BitGlobalSymtab() && | |
| 1090 | Symtab == SymtabWritingMode::BigArchive32) | |
| 1091 | return; | |
| 1092 | ||
| 1093 | if (BigArc->has64BitGlobalSymtab() && | |
| 1094 | Symtab == SymtabWritingMode::BigArchive64) | |
| 1095 | return; | |
| 1096 | ||
| 1097 | if (BigArc->has32BitGlobalSymtab() && BigArc->has64BitGlobalSymtab() && | |
| 1098 | Symtab == SymtabWritingMode::NormalSymtab) | |
| 1099 | return; | |
| 1100 | ||
| 1101 | Symtab = SymtabWritingMode::NormalSymtab; | |
| 1102 | } | |
| 1103 | } | |
| 1080 | 1104 | if (OldArchive->isThin()) |
| 1081 | 1105 | Thin = true; |
| 1082 | 1106 | performWriteOperation(CreateSymTab, OldArchive, nullptr, nullptr); |
| ... | ... | @@ -1262,8 +1286,7 @@ static const char *matchFlagWithArg(StringRef Expected, |
| 1262 | 1286 | ArrayRef<const char *> Args) { |
| 1263 | 1287 | StringRef Arg = *ArgIt; |
| 1264 | 1288 | |
| 1265 | if (Arg.startswith("--")) | |
| 1266 | Arg = Arg.substr(2); | |
| 1289 | Arg.consume_front("--"); | |
| 1267 | 1290 | |
| 1268 | 1291 | size_t len = Expected.size(); |
| 1269 | 1292 | if (Arg == Expected) { |
| ... | ... | @@ -1272,7 +1295,7 @@ static const char *matchFlagWithArg(StringRef Expected, |
| 1272 | 1295 | |
| 1273 | 1296 | return *ArgIt; |
| 1274 | 1297 | } |
| 1275 | if (Arg.startswith(Expected) && Arg.size() > len && Arg[len] == '=') | |
| 1298 | if (Arg.starts_with(Expected) && Arg.size() > len && Arg[len] == '=') | |
| 1276 | 1299 | return Arg.data() + len + 1; |
| 1277 | 1300 | |
| 1278 | 1301 | return nullptr; |
| ... | ... | @@ -1389,6 +1412,8 @@ static int ar_main(int argc, char **argv) { |
| 1389 | 1412 | |
| 1390 | 1413 | static int ranlib_main(int argc, char **argv) { |
| 1391 | 1414 | std::vector<StringRef> Archives; |
| 1415 | bool HasAIXXOption = false; | |
| 1416 | ||
| 1392 | 1417 | for (int i = 1; i < argc; ++i) { |
| 1393 | 1418 | StringRef arg(argv[i]); |
| 1394 | 1419 | if (handleGenericOption(arg)) { |
| ... | ... | @@ -1406,6 +1431,28 @@ static int ranlib_main(int argc, char **argv) { |
| 1406 | 1431 | } else if (arg.front() == 'v') { |
| 1407 | 1432 | cl::PrintVersionMessage(); |
| 1408 | 1433 | return 0; |
| 1434 | } else if (arg.front() == 'X') { | |
| 1435 | if (object::Archive::getDefaultKindForHost() == | |
| 1436 | object::Archive::K_AIXBIG) { | |
| 1437 | HasAIXXOption = true; | |
| 1438 | arg.consume_front("X"); | |
| 1439 | const char *Xarg = arg.data(); | |
| 1440 | if (Xarg[0] == '\0') { | |
| 1441 | if (argv[i + 1][0] != '-') | |
| 1442 | BitMode = getBitMode(argv[++i]); | |
| 1443 | else | |
| 1444 | BitMode = BitModeTy::Unknown; | |
| 1445 | } else | |
| 1446 | BitMode = getBitMode(arg.data()); | |
| 1447 | ||
| 1448 | if (BitMode == BitModeTy::Unknown) | |
| 1449 | fail("the specified object mode is not valid. Specify -X32, " | |
| 1450 | "-X64, -X32_64, or -Xany"); | |
| 1451 | } else { | |
| 1452 | fail(Twine("-") + Twine(arg) + | |
| 1453 | " option not supported on non AIX OS"); | |
| 1454 | } | |
| 1455 | break; | |
| 1409 | 1456 | } else { |
| 1410 | 1457 | // TODO: GNU ranlib also supports a -t flag |
| 1411 | 1458 | fail("Invalid option: '-" + arg + "'"); |
| ... | ... | @@ -1417,6 +1464,31 @@ static int ranlib_main(int argc, char **argv) { |
| 1417 | 1464 | } |
| 1418 | 1465 | } |
| 1419 | 1466 | |
| 1467 | if (object::Archive::getDefaultKindForHost() == object::Archive::K_AIXBIG) { | |
| 1468 | // If not specify -X option, get BitMode from enviorment variable | |
| 1469 | // "OBJECT_MODE" for AIX OS if specify. | |
| 1470 | if (!HasAIXXOption) { | |
| 1471 | if (char *EnvObjectMode = getenv("OBJECT_MODE")) { | |
| 1472 | BitMode = getBitMode(EnvObjectMode); | |
| 1473 | if (BitMode == BitModeTy::Unknown) | |
| 1474 | fail("the OBJECT_MODE environment variable has an invalid value. " | |
| 1475 | "OBJECT_MODE must be 32, 64, 32_64, or any"); | |
| 1476 | } | |
| 1477 | } | |
| 1478 | ||
| 1479 | switch (BitMode) { | |
| 1480 | case BitModeTy::Bit32: | |
| 1481 | Symtab = SymtabWritingMode::BigArchive32; | |
| 1482 | break; | |
| 1483 | case BitModeTy::Bit64: | |
| 1484 | Symtab = SymtabWritingMode::BigArchive64; | |
| 1485 | break; | |
| 1486 | default: | |
| 1487 | Symtab = SymtabWritingMode::NormalSymtab; | |
| 1488 | break; | |
| 1489 | } | |
| 1490 | } | |
| 1491 | ||
| 1420 | 1492 | for (StringRef Archive : Archives) { |
| 1421 | 1493 | ArchiveName = Archive.str(); |
| 1422 | 1494 | performOperation(CreateSymTab); |
| ... | ... | @@ -1426,15 +1498,7 @@ static int ranlib_main(int argc, char **argv) { |
| 1426 | 1498 | return 0; |
| 1427 | 1499 | } |
| 1428 | 1500 | |
| 1429 | static int llvm_ar_main(int argc, char **argv, const llvm::ToolContext &) { | |
| 1430 | // ZIG PATCH: On Windows, InitLLVM calls GetCommandLineW(), | |
| 1431 | // and overwrites the args. We don't want it to do that, | |
| 1432 | // and we also don't need the signal handlers it installs | |
| 1433 | // (we have our own already), so we just use llvm_shutdown_obj | |
| 1434 | // instead. | |
| 1435 | // InitLLVM X(argc, argv); | |
| 1436 | llvm::llvm_shutdown_obj X; | |
| 1437 | ||
| 1501 | int llvm_ar_main(int argc, char **argv, const llvm::ToolContext &) { | |
| 1438 | 1502 | ToolName = argv[0]; |
| 1439 | 1503 | |
| 1440 | 1504 | llvm::InitializeAllTargetInfos(); |
| ... | ... | @@ -1464,8 +1528,3 @@ static int llvm_ar_main(int argc, char **argv, const llvm::ToolContext &) { |
| 1464 | 1528 | |
| 1465 | 1529 | fail("not ranlib, ar, lib or dlltool"); |
| 1466 | 1530 | } |
| 1467 | ||
| 1468 | extern "C" int ZigLlvmAr_main(int, char **); | |
| 1469 | int ZigLlvmAr_main(int argc, char **argv) { | |
| 1470 | return llvm_ar_main(argc, argv, {argv[0], nullptr, false}); | |
| 1471 | } |