diff options
Diffstat (limited to 'lld/lib/Driver/WinLinkDriver.cpp')
| -rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 9d8f0890893..393bc99e4d1 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -767,9 +767,9 @@ bool WinLinkDriver::linkPECOFF(int argc, const char **argv, raw_ostream &diag) { return link(context, diag); } -bool WinLinkDriver::parse(int argc, const char *argv[], - PECOFFLinkingContext &ctx, raw_ostream &diag, - bool isReadingDirectiveSection) { +bool WinLinkDriver::doParse(int argc, const char *argv[], + PECOFFLinkingContext &ctx, raw_ostream &diag, + bool isReadingDirectiveSection) { std::map<StringRef, StringRef> failIfMismatchMap; // Parse the options. std::unique_ptr<llvm::opt::InputArgList> parsedArgs = @@ -1251,4 +1251,16 @@ bool WinLinkDriver::parse(int argc, const char *argv[], return ctx.validate(diag); } +// Parse may be called from multiple threads simultaneously to parse .drectve +// sections. doParse() is not thread-safe because it mutates the context +// object. This function wraps doParse() with a mutex. +bool WinLinkDriver::parse(int argc, const char *argv[], + PECOFFLinkingContext &ctx, raw_ostream &diag, + bool isReadingDirectiveSection) { + ctx.lock(); + bool r = doParse(argc, argv, ctx, diag, isReadingDirectiveSection); + ctx.unlock(); + return r; +} + } // namespace lld |

