diff options
author | Alexandre Ganea <alexandre.ganea@legionlabs.com> | 2022-01-20 14:53:18 -0500 |
---|---|---|
committer | Alexandre Ganea <alexandre.ganea@legionlabs.com> | 2022-01-20 14:53:26 -0500 |
commit | 83d59e05b201760e3f364ff6316301d347cbad95 (patch) | |
tree | fb59567dc25a7a313af89e4885d6b82b28902a7b /lld/MinGW/Driver.cpp | |
parent | 57ebfea38c03e5cd2d0677eabd2abf761b336097 (diff) | |
download | llvm-83d59e05b201760e3f364ff6316301d347cbad95.zip llvm-83d59e05b201760e3f364ff6316301d347cbad95.tar.gz llvm-83d59e05b201760e3f364ff6316301d347cbad95.tar.bz2 |
Re-land [LLD] Remove global state in lldCommon
Move all variables at file-scope or function-static-scope into a hosting structure (lld::CommonLinkerContext) that lives at lldMain()-scope. Drivers will inherit from this structure and add their own global state, in the same way as for the existing COFFLinkerContext.
See discussion in https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html
The previous land f860fe362282ed69b9d4503a20e5d20b9a041189 caused issues in https://lab.llvm.org/buildbot/#/builders/123/builds/8383, fixed by 22ee510dac9440a74b2e5b3fe3ff13ccdbf55af3.
Differential Revision: https://reviews.llvm.org/D108850
Diffstat (limited to 'lld/MinGW/Driver.cpp')
-rw-r--r-- | lld/MinGW/Driver.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp index 7c6b865..10ff7cf 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -100,7 +100,7 @@ opt::InputArgList MinGWOptTable::parse(ArrayRef<const char *> argv) { unsigned missingCount; SmallVector<const char *, 256> vec(argv.data(), argv.data() + argv.size()); - cl::ExpandResponseFiles(saver, getQuotingStyle(), vec); + cl::ExpandResponseFiles(saver(), getQuotingStyle(), vec); opt::InputArgList args = this->ParseArgs(vec, missingIndex, missingCount); if (missingCount) @@ -154,12 +154,11 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) { // Convert Unix-ish command line arguments to Windows-ish ones and // then call coff::link. -bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly, - raw_ostream &stdoutOS, raw_ostream &stderrOS) { - lld::stdoutOS = &stdoutOS; - lld::stderrOS = &stderrOS; - - stderrOS.enable_colors(stderrOS.has_colors()); +bool mingw::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS, + llvm::raw_ostream &stderrOS, bool exitEarly, + bool disableOutput) { + auto *ctx = new CommonLinkerContext; + ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput); MinGWOptTable parser; opt::InputArgList args = parser.parse(argsArr.slice(1)); @@ -445,5 +444,9 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly, // Pass the actual binary name, to make error messages be printed with // the right prefix. vec[0] = argsArr[0]; - return coff::link(vec, canExitEarly, stdoutOS, stderrOS); + + // The context will be re-created in the COFF driver. + lld::CommonLinkerContext::destroy(); + + return coff::link(vec, stdoutOS, stderrOS, exitEarly, disableOutput); } |