@@ -214,7 +214,8 @@ struct UndefinedDiag {
214214 std::vector<File> files;
215215};
216216
217- static void reportUndefinedSymbol (COFFLinkerContext &ctx,
217+ static void reportUndefinedSymbol (SymbolTable *symTab,
218+ COFFLinkerContext &ctx,
218219 const UndefinedDiag &undefDiag) {
219220 auto diag = errorOrWarn (ctx);
220221 diag << " undefined symbol: " << undefDiag.sym ;
@@ -232,6 +233,17 @@ static void reportUndefinedSymbol(COFFLinkerContext &ctx,
232233 }
233234 if (numDisplayedRefs < numRefs)
234235 diag << " \n >>> referenced " << numRefs - numDisplayedRefs << " more times" ;
236+
237+ // Hints
238+ StringRef name = undefDiag.sym ->getName ();
239+ if (name.consume_front (" __imp_" )) {
240+ Symbol *imp = symTab->find (name);
241+ if (imp && imp->isLazy ()) {
242+ diag << " \n NOTE: a relevant symbol '" << imp->getName ()
243+ << " ' is available in " << toString (imp->getFile ())
244+ << " but cannot be used because it is not an import library." ;
245+ }
246+ }
235247}
236248
237249void SymbolTable::loadMinGWSymbols () {
@@ -402,7 +414,7 @@ void SymbolTable::reportProblemSymbols(
402414 processFile (file, file->getSymbols ());
403415
404416 for (const UndefinedDiag &undefDiag : undefDiags)
405- reportUndefinedSymbol (ctx, undefDiag);
417+ reportUndefinedSymbol (this , ctx, undefDiag);
406418}
407419
408420void SymbolTable::reportUnresolvable () {
@@ -432,11 +444,10 @@ void SymbolTable::reportUnresolvable() {
432444 reportProblemSymbols (undefs, /* localImports=*/ nullptr , true );
433445}
434446
435- bool SymbolTable::resolveRemainingUndefines () {
447+ void SymbolTable::resolveRemainingUndefines () {
436448 llvm::TimeTraceScope timeScope (" Resolve remaining undefined symbols" );
437449 SmallPtrSet<Symbol *, 8 > undefs;
438450 DenseMap<Symbol *, Symbol *> localImports;
439- bool foundLazy = false ;
440451
441452 for (auto &i : symMap) {
442453 Symbol *sym = i.second ;
@@ -481,11 +492,6 @@ bool SymbolTable::resolveRemainingUndefines() {
481492 imp = findLocalSym (*mangledName);
482493 }
483494 }
484- if (imp && imp->isLazy ()) {
485- forceLazy (imp);
486- foundLazy = true ;
487- continue ;
488- }
489495 if (imp && isa<Defined>(imp)) {
490496 auto *d = cast<Defined>(imp);
491497 replaceSymbol<DefinedLocalImport>(sym, ctx, name, d);
@@ -513,7 +519,6 @@ bool SymbolTable::resolveRemainingUndefines() {
513519 reportProblemSymbols (
514520 undefs, ctx.config .warnLocallyDefinedImported ? &localImports : nullptr ,
515521 false );
516- return foundLazy;
517522}
518523
519524std::pair<Symbol *, bool > SymbolTable::insert (StringRef name) {
0 commit comments