@@ -960,28 +960,39 @@ std::string LinkerDriver::getImportName(bool asLib) {
960
960
961
961
void LinkerDriver::createImportLibrary (bool asLib) {
962
962
llvm::TimeTraceScope timeScope (" Create import library" );
963
- std::vector<COFFShortExport> exports;
964
- for (Export &e1 : ctx.symtab .exports ) {
965
- COFFShortExport e2 ;
966
- e2 .Name = std::string (e1 .name );
967
- e2 .SymbolName = std::string (e1 .symbolName );
968
- e2 .ExtName = std::string (e1 .extName );
969
- e2 .ExportAs = std::string (e1 .exportAs );
970
- e2 .ImportName = std::string (e1 .importName );
971
- e2 .Ordinal = e1 .ordinal ;
972
- e2 .Noname = e1 .noname ;
973
- e2 .Data = e1 .data ;
974
- e2 .Private = e1 .isPrivate ;
975
- e2 .Constant = e1 .constant ;
976
- exports.push_back (e2 );
963
+ std::vector<COFFShortExport> exports, nativeExports;
964
+
965
+ auto getExports = [](SymbolTable &symtab,
966
+ std::vector<COFFShortExport> &exports) {
967
+ for (Export &e1 : symtab.exports ) {
968
+ COFFShortExport e2 ;
969
+ e2 .Name = std::string (e1 .name );
970
+ e2 .SymbolName = std::string (e1 .symbolName );
971
+ e2 .ExtName = std::string (e1 .extName );
972
+ e2 .ExportAs = std::string (e1 .exportAs );
973
+ e2 .ImportName = std::string (e1 .importName );
974
+ e2 .Ordinal = e1 .ordinal ;
975
+ e2 .Noname = e1 .noname ;
976
+ e2 .Data = e1 .data ;
977
+ e2 .Private = e1 .isPrivate ;
978
+ e2 .Constant = e1 .constant ;
979
+ exports.push_back (e2 );
980
+ }
981
+ };
982
+
983
+ if (ctx.hybridSymtab ) {
984
+ getExports (ctx.symtab , nativeExports);
985
+ getExports (*ctx.hybridSymtab , exports);
986
+ } else {
987
+ getExports (ctx.symtab , exports);
977
988
}
978
989
979
990
std::string libName = getImportName (asLib);
980
991
std::string path = getImplibPath ();
981
992
982
993
if (!ctx.config .incremental ) {
983
994
checkError (writeImportLibrary (libName, path, exports, ctx.config .machine ,
984
- ctx.config .mingw ));
995
+ ctx.config .mingw , nativeExports ));
985
996
return ;
986
997
}
987
998
@@ -991,7 +1002,7 @@ void LinkerDriver::createImportLibrary(bool asLib) {
991
1002
path, /* IsText=*/ false , /* RequiresNullTerminator=*/ false );
992
1003
if (!oldBuf) {
993
1004
checkError (writeImportLibrary (libName, path, exports, ctx.config .machine ,
994
- ctx.config .mingw ));
1005
+ ctx.config .mingw , nativeExports ));
995
1006
return ;
996
1007
}
997
1008
@@ -1001,8 +1012,9 @@ void LinkerDriver::createImportLibrary(bool asLib) {
1001
1012
Fatal (ctx) << " cannot create temporary file for import library " << path
1002
1013
<< " : " << ec.message ();
1003
1014
1004
- if (Error e = writeImportLibrary (libName, tmpName, exports,
1005
- ctx.config .machine , ctx.config .mingw )) {
1015
+ if (Error e =
1016
+ writeImportLibrary (libName, tmpName, exports, ctx.config .machine ,
1017
+ ctx.config .mingw , nativeExports)) {
1006
1018
checkError (std::move (e));
1007
1019
return ;
1008
1020
}
@@ -2672,7 +2684,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2672
2684
// Windows specific -- when we are creating a .dll file, we also
2673
2685
// need to create a .lib file. In MinGW mode, we only do that when the
2674
2686
// -implib option is given explicitly, for compatibility with GNU ld.
2675
- if (!ctx.symtab .exports .empty () || config->dll ) {
2687
+ if (config->dll || !ctx.symtab .exports .empty () ||
2688
+ (ctx.hybridSymtab && !ctx.hybridSymtab ->exports .empty ())) {
2676
2689
llvm::TimeTraceScope timeScope (" Create .lib exports" );
2677
2690
ctx.forEachSymtab ([](SymbolTable &symtab) { symtab.fixupExports (); });
2678
2691
if (!config->noimplib && (!config->mingw || !config->implib .empty ()))
0 commit comments