diff --git a/src/MainUtils.cpp b/src/MainUtils.cpp index 0a43d1d..0d07e82 100644 --- a/src/MainUtils.cpp +++ b/src/MainUtils.cpp @@ -161,7 +161,7 @@ void LoadMLIR(string inputFilename, mlir::MLIRContext &context, } void genConstPackObj(const mlir::OwningModuleRef &module, - llvm::Optional &constPackObjPath) { + llvm::Optional &constPackObjPath, string outputBaseName) { // Extract constant pack file name, which is embedded as a symbol in the // module being compiled. auto constPackFilePathSym = (*module).lookupSymbol( @@ -223,6 +223,12 @@ void genConstPackObj(const mlir::OwningModuleRef &module, .exec(); #else + /* The final constant pack object file on Windows is NOT embedded into + * the shared library but rather is kept in a separate .bin file. So + * do not set it in constPackObjPath so that when this function returns + * the caller (compileModuleToSharedLibrary and compileModuleToJniJar) + * won't put it into llvm::FileRemover. + */ llvm::SmallVector permConstPackFileName( constPackFilePath.begin(), constPackFilePath.end()); llvm::sys::path::replace_extension(permConstPackFileName, "bin"); @@ -309,7 +315,7 @@ void compileModuleToSharedLibrary( const mlir::OwningModuleRef &module, std::string outputBaseName) { llvm::Optional constPackObjPath; - genConstPackObj(module, constPackObjPath); + genConstPackObj(module, constPackObjPath, outputBaseName); llvm::FileRemover constPackObjRemover(constPackObjPath.getValue()); string bitcodePath = outputBaseName + ".bc"; @@ -330,7 +336,7 @@ void compileModuleToJniJar( const mlir::OwningModuleRef &module, std::string outputBaseName) { llvm::Optional constPackObjPath; - genConstPackObj(module, constPackObjPath); + genConstPackObj(module, constPackObjPath, outputBaseName); llvm::FileRemover constPackObjRemover(constPackObjPath.getValue()); string bitcodePath = outputBaseName + ".bc";