Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Driver compilation for Chapter 5 #24

Closed
Fare9 opened this issue Jan 19, 2023 · 0 comments
Closed

Error in Driver compilation for Chapter 5 #24

Fare9 opened this issue Jan 19, 2023 · 0 comments

Comments

@Fare9
Copy link

Fare9 commented Jan 19, 2023

There are some issues in the code of Driver with recent versions of LLVM (I'm using the last version of the LLVM repository), the first problem is with the next code:

sys::fs::OpenFlags OpenFlags = sys::fs::OF_None;
if (FileType == CGFT_AssemblyFile)
    OpenFlags |= sys::fs::OF_Text;

The compiler will complain, so it's necessary to add a missing header:

#include "llvm/Support/FileSystem.h"

Next is the legacy::PassManager, the compiler complains adding the result from createPrintModulePass to the PassManager, since the returned llvm::ModulePass * cannot be casted to the llvm::Pass from that PassManager, so it is possible to use a code similar to the one of the tool opt. First we add the next header:

#include "llvm/Transforms/Utils/Debugify.h"

And then we change the next code:

legacy::PassManager PM;
if (FileType == CGFT_AssemblyFile && EmitLLVM) {
PM.add(createPrintModulePass(Out->os()));
} else {
if (TM->addPassesToEmitFile(PM, Out->os(), nullptr,
FileType)) {
WithColor::error() << "No support for file type\n";
return false;
}
}
PM.run(*M);

For:

llvm::DebugifyCustomPassManager PM;

if (FileType == CGFT_AssemblyFile && EmitLLVM)
    PM.add(createPrintModulePass(Out->os()));
else
{
    if (TM->addPassesToEmitFile(PM, Out->os(), nullptr, FileType))
    {
        WithColor::error() << "No support for file type\n";
        return false;
    }
}

PM.run(*M);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants