@@ -954,28 +954,39 @@ std::string LinkerDriver::getImportName(bool asLib) {
954954
955955void LinkerDriver::createImportLibrary (bool asLib) {
956956 llvm::TimeTraceScope timeScope (" Create import library" );
957- std::vector<COFFShortExport> exports;
958- for (Export &e1 : ctx.symtab .exports ) {
959- COFFShortExport e2 ;
960- e2 .Name = std::string (e1 .name );
961- e2 .SymbolName = std::string (e1 .symbolName );
962- e2 .ExtName = std::string (e1 .extName );
963- e2 .ExportAs = std::string (e1 .exportAs );
964- e2 .ImportName = std::string (e1 .importName );
965- e2 .Ordinal = e1 .ordinal ;
966- e2 .Noname = e1 .noname ;
967- e2 .Data = e1 .data ;
968- e2 .Private = e1 .isPrivate ;
969- e2 .Constant = e1 .constant ;
970- exports.push_back (e2 );
957+ std::vector<COFFShortExport> exports, nativeExports;
958+
959+ auto getExports = [](SymbolTable &symtab,
960+ std::vector<COFFShortExport> &exports) {
961+ for (Export &e1 : symtab.exports ) {
962+ COFFShortExport e2 ;
963+ e2 .Name = std::string (e1 .name );
964+ e2 .SymbolName = std::string (e1 .symbolName );
965+ e2 .ExtName = std::string (e1 .extName );
966+ e2 .ExportAs = std::string (e1 .exportAs );
967+ e2 .ImportName = std::string (e1 .importName );
968+ e2 .Ordinal = e1 .ordinal ;
969+ e2 .Noname = e1 .noname ;
970+ e2 .Data = e1 .data ;
971+ e2 .Private = e1 .isPrivate ;
972+ e2 .Constant = e1 .constant ;
973+ exports.push_back (e2 );
974+ }
975+ };
976+
977+ if (ctx.hybridSymtab ) {
978+ getExports (ctx.symtab , nativeExports);
979+ getExports (*ctx.hybridSymtab , exports);
980+ } else {
981+ getExports (ctx.symtab , exports);
971982 }
972983
973984 std::string libName = getImportName (asLib);
974985 std::string path = getImplibPath ();
975986
976987 if (!ctx.config .incremental ) {
977988 checkError (writeImportLibrary (libName, path, exports, ctx.config .machine ,
978- ctx.config .mingw ));
989+ ctx.config .mingw , nativeExports ));
979990 return ;
980991 }
981992
@@ -985,7 +996,7 @@ void LinkerDriver::createImportLibrary(bool asLib) {
985996 path, /* IsText=*/ false , /* RequiresNullTerminator=*/ false );
986997 if (!oldBuf) {
987998 checkError (writeImportLibrary (libName, path, exports, ctx.config .machine ,
988- ctx.config .mingw ));
999+ ctx.config .mingw , nativeExports ));
9891000 return ;
9901001 }
9911002
@@ -995,8 +1006,9 @@ void LinkerDriver::createImportLibrary(bool asLib) {
9951006 Fatal (ctx) << " cannot create temporary file for import library " << path
9961007 << " : " << ec.message ();
9971008
998- if (Error e = writeImportLibrary (libName, tmpName, exports,
999- ctx.config .machine , ctx.config .mingw )) {
1009+ if (Error e =
1010+ writeImportLibrary (libName, tmpName, exports, ctx.config .machine ,
1011+ ctx.config .mingw , nativeExports)) {
10001012 checkError (std::move (e));
10011013 return ;
10021014 }
@@ -2668,7 +2680,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
26682680 // Windows specific -- when we are creating a .dll file, we also
26692681 // need to create a .lib file. In MinGW mode, we only do that when the
26702682 // -implib option is given explicitly, for compatibility with GNU ld.
2671- if (!ctx.symtab .exports .empty () || config->dll ) {
2683+ if (config->dll || !ctx.symtab .exports .empty () ||
2684+ (ctx.hybridSymtab && !ctx.hybridSymtab ->exports .empty ())) {
26722685 llvm::TimeTraceScope timeScope (" Create .lib exports" );
26732686 ctx.forEachSymtab ([](SymbolTable &symtab) { symtab.fixupExports (); });
26742687 if (!config->noimplib && (!config->mingw || !config->implib .empty ()))
0 commit comments