| author | |
| committer | |
| log | 9ea23272fac7f4580d29f7ee557108883f127a5d |
| tree | 5251b09dbe1149afaa70fc588e280bed97de232e |
| parent | 77b530b50aedd1cf9943e1d4fdd97a364fe9a921 |
This applies de776439b61fb71c1256ad86238799c758c66048
from the LLVM git monorepo to the embedded LLD.6 files changed, 18 insertions(+), 10 deletions(-)
deps/lld/COFF/Config.h+1| ... | @@ -157,6 +157,7 @@ struct Configuration { | ... | @@ -157,6 +157,7 @@ struct Configuration { |
| 157 | uint32_t MinorImageVersion = 0; | 157 | uint32_t MinorImageVersion = 0; |
| 158 | uint32_t MajorOSVersion = 6; | 158 | uint32_t MajorOSVersion = 6; |
| 159 | uint32_t MinorOSVersion = 0; | 159 | uint32_t MinorOSVersion = 0; |
| 160 | bool CanExitEarly = false; | ||
| 160 | bool DynamicBase = true; | 161 | bool DynamicBase = true; |
| 161 | bool NxCompat = true; | 162 | bool NxCompat = true; |
| 162 | bool AllowIsolation = true; | 163 | bool AllowIsolation = true; |
deps/lld/COFF/Driver.cpp+10-6| ... | @@ -52,15 +52,22 @@ BumpPtrAllocator BAlloc; | ... | @@ -52,15 +52,22 @@ BumpPtrAllocator BAlloc; |
| 52 | StringSaver Saver{BAlloc}; | 52 | StringSaver Saver{BAlloc}; |
| 53 | std::vector<SpecificAllocBase *> SpecificAllocBase::Instances; | 53 | std::vector<SpecificAllocBase *> SpecificAllocBase::Instances; |
| 54 | 54 | ||
| 55 | bool link(ArrayRef<const char *> Args, raw_ostream &Diag) { | 55 | bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) { |
| 56 | ErrorCount = 0; | 56 | ErrorCount = 0; |
| 57 | ErrorOS = &Diag; | 57 | ErrorOS = &Diag; |
| 58 | Config = make<Configuration>(); | 58 | Config = make<Configuration>(); |
| 59 | Config->Argv = {Args.begin(), Args.end()}; | 59 | Config->Argv = {Args.begin(), Args.end()}; |
| 60 | Config->ColorDiagnostics = | 60 | Config->ColorDiagnostics = |
| 61 | (ErrorOS == &llvm::errs() && Process::StandardErrHasColors()); | 61 | (ErrorOS == &llvm::errs() && Process::StandardErrHasColors()); |
| 62 | Config->CanExitEarly = CanExitEarly; | ||
| 62 | Driver = make<LinkerDriver>(); | 63 | Driver = make<LinkerDriver>(); |
| 63 | Driver->link(Args); | 64 | Driver->link(Args); |
| 65 | |||
| 66 | // Call exit() if we can to avoid calling destructors. | ||
| 67 | if (CanExitEarly) | ||
| 68 | exitLld(ErrorCount ? 1 : 0); | ||
| 69 | |||
| 70 | freeArena(); | ||
| 64 | return !ErrorCount; | 71 | return !ErrorCount; |
| 65 | } | 72 | } |
| 66 | 73 | ||
| ... | @@ -1030,7 +1037,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { | ... | @@ -1030,7 +1037,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { |
| 1030 | if (!Args.hasArgNoClaim(OPT_INPUT)) { | 1037 | if (!Args.hasArgNoClaim(OPT_INPUT)) { |
| 1031 | fixupExports(); | 1038 | fixupExports(); |
| 1032 | createImportLibrary(/*AsLib=*/true); | 1039 | createImportLibrary(/*AsLib=*/true); |
| 1033 | exit(0); | 1040 | return; |
| 1034 | } | 1041 | } |
| 1035 | 1042 | ||
| 1036 | // Handle /delayload | 1043 | // Handle /delayload |
| ... | @@ -1122,7 +1129,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { | ... | @@ -1122,7 +1129,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { |
| 1122 | // This is useful because MSVC link.exe can generate complete PDBs. | 1129 | // This is useful because MSVC link.exe can generate complete PDBs. |
| 1123 | if (Args.hasArg(OPT_msvclto)) { | 1130 | if (Args.hasArg(OPT_msvclto)) { |
| 1124 | invokeMSVC(Args); | 1131 | invokeMSVC(Args); |
| 1125 | exit(0); | 1132 | return; |
| 1126 | } | 1133 | } |
| 1127 | 1134 | ||
| 1128 | // Do LTO by compiling bitcode input files to a set of native COFF files then | 1135 | // Do LTO by compiling bitcode input files to a set of native COFF files then |
| ... | @@ -1172,9 +1179,6 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { | ... | @@ -1172,9 +1179,6 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { |
| 1172 | 1179 | ||
| 1173 | // Write the result. | 1180 | // Write the result. |
| 1174 | writeResult(&Symtab); | 1181 | writeResult(&Symtab); |
| 1175 | |||
| 1176 | // Call exit to avoid calling destructors. | ||
| 1177 | exit(0); | ||
| 1178 | } | 1182 | } |
| 1179 | 1183 | ||
| 1180 | } // namespace coff | 1184 | } // namespace coff |
deps/lld/COFF/Error.cpp+3-2| ... | @@ -32,7 +32,7 @@ namespace coff { | ... | @@ -32,7 +32,7 @@ namespace coff { |
| 32 | uint64_t ErrorCount; | 32 | uint64_t ErrorCount; |
| 33 | raw_ostream *ErrorOS; | 33 | raw_ostream *ErrorOS; |
| 34 | 34 | ||
| 35 | static LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) { | 35 | LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) { |
| 36 | // Dealloc/destroy ManagedStatic variables before calling | 36 | // Dealloc/destroy ManagedStatic variables before calling |
| 37 | // _exit(). In a non-LTO build, this is a nop. In an LTO | 37 | // _exit(). In a non-LTO build, this is a nop. In an LTO |
| 38 | // build allows us to get the output of -time-passes. | 38 | // build allows us to get the output of -time-passes. |
| ... | @@ -78,7 +78,8 @@ void error(const Twine &Msg) { | ... | @@ -78,7 +78,8 @@ void error(const Twine &Msg) { |
| 78 | print("error: ", raw_ostream::RED); | 78 | print("error: ", raw_ostream::RED); |
| 79 | *ErrorOS << "too many errors emitted, stopping now" | 79 | *ErrorOS << "too many errors emitted, stopping now" |
| 80 | << " (use /ERRORLIMIT:0 to see all errors)\n"; | 80 | << " (use /ERRORLIMIT:0 to see all errors)\n"; |
| 81 | exitLld(1); | 81 | if (Config->CanExitEarly) |
| 82 | exitLld(1); | ||
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | ++ErrorCount; | 85 | ++ErrorCount; |
deps/lld/COFF/Error.h+2| ... | @@ -27,6 +27,8 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg); | ... | @@ -27,6 +27,8 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg); |
| 27 | LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix); | 27 | LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix); |
| 28 | LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error &Err, const Twine &Prefix); | 28 | LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error &Err, const Twine &Prefix); |
| 29 | 29 | ||
| 30 | LLVM_ATTRIBUTE_NORETURN void exitLld(int Val); | ||
| 31 | |||
| 30 | template <class T> T check(ErrorOr<T> V, const Twine &Prefix) { | 32 | template <class T> T check(ErrorOr<T> V, const Twine &Prefix) { |
| 31 | if (auto EC = V.getError()) | 33 | if (auto EC = V.getError()) |
| 32 | fatal(EC, Prefix); | 34 | fatal(EC, Prefix); |
deps/lld/include/lld/Driver/Driver.h+1-1| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | ||
| 16 | namespace lld { | 16 | namespace lld { |
| 17 | namespace coff { | 17 | namespace coff { |
| 18 | bool link(llvm::ArrayRef<const char *> Args, | 18 | bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly, |
| 19 | llvm::raw_ostream &Diag = llvm::errs()); | 19 | llvm::raw_ostream &Diag = llvm::errs()); |
| 20 | } | 20 | } |
| 21 | 21 |
deps/lld/tools/lld/lld.cpp+1-1| ... | @@ -103,7 +103,7 @@ int main(int Argc, const char **Argv) { | ... | @@ -103,7 +103,7 @@ int main(int Argc, const char **Argv) { |
| 103 | case Gnu: | 103 | case Gnu: |
| 104 | return !elf::link(Args, true); | 104 | return !elf::link(Args, true); |
| 105 | case WinLink: | 105 | case WinLink: |
| 106 | return !coff::link(Args); | 106 | return !coff::link(Args, true); |
| 107 | case Darwin: | 107 | case Darwin: |
| 108 | return !mach_o::link(Args); | 108 | return !mach_o::link(Args); |
| 109 | default: | 109 | default: |