@@ -954,28 +954,39 @@ std::string LinkerDriver::getImportName(bool asLib) {
954
954
955
955
void LinkerDriver::createImportLibrary (bool asLib) {
956
956
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);
971
982
}
972
983
973
984
std::string libName = getImportName (asLib);
974
985
std::string path = getImplibPath ();
975
986
976
987
if (!ctx.config .incremental ) {
977
988
checkError (writeImportLibrary (libName, path, exports, ctx.config .machine ,
978
- ctx.config .mingw ));
989
+ ctx.config .mingw , nativeExports ));
979
990
return ;
980
991
}
981
992
@@ -985,7 +996,7 @@ void LinkerDriver::createImportLibrary(bool asLib) {
985
996
path, /* IsText=*/ false , /* RequiresNullTerminator=*/ false );
986
997
if (!oldBuf) {
987
998
checkError (writeImportLibrary (libName, path, exports, ctx.config .machine ,
988
- ctx.config .mingw ));
999
+ ctx.config .mingw , nativeExports ));
989
1000
return ;
990
1001
}
991
1002
@@ -995,8 +1006,9 @@ void LinkerDriver::createImportLibrary(bool asLib) {
995
1006
Fatal (ctx) << " cannot create temporary file for import library " << path
996
1007
<< " : " << ec.message ();
997
1008
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)) {
1000
1012
checkError (std::move (e));
1001
1013
return ;
1002
1014
}
@@ -2668,7 +2680,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2668
2680
// Windows specific -- when we are creating a .dll file, we also
2669
2681
// need to create a .lib file. In MinGW mode, we only do that when the
2670
2682
// -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 ())) {
2672
2685
llvm::TimeTraceScope timeScope (" Create .lib exports" );
2673
2686
ctx.forEachSymtab ([](SymbolTable &symtab) { symtab.fixupExports (); });
2674
2687
if (!config->noimplib && (!config->mingw || !config->implib .empty ()))
0 commit comments