[PoC] Use clang driver to link the object files

This commit is contained in:
Sameer Rahmani 2021-07-12 23:39:29 +01:00
parent 2298be5783
commit ab54e7f5be
4 changed files with 16 additions and 16 deletions

View File

@ -166,25 +166,25 @@ int dumpAsObject(Namespace &ns) {
llvm::outs() << "Wrote " << filename << "\n"; llvm::outs() << "Wrote " << filename << "\n";
clang::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagID( llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> opts =
new clang::DiagnosticIDs()); new clang::DiagnosticOptions;
clang::IntrusiveRefCntPtr<clang::DiagnosticOptions> diagOpts = clang::DiagnosticsEngine diags(
new clang::DiagnosticOptions(); new clang::DiagnosticIDs, opts,
clang::TextDiagnosticPrinter diagPrinter(llvm::errs(), &*diagOpts); new clang::TextDiagnosticPrinter(llvm::errs(), opts.get()));
clang::DiagnosticsEngine diags(diagID, &*diagOpts, &diagPrinter);
clang::driver::Driver d("clang", targetTriple, diags, "Serene compiler");
std::vector<const char *> args;
args.push_back(filename); clang::driver::Driver d("clang", targetTriple, diags, "Serene compiler");
args.push_back("-o"); std::vector<const char *> args = {"hnt"};
args.push_back( auto objf =
llvm::formatv("/home/lxsameer/src/serene/serene/build/{0}.o", filename) llvm::formatv("/home/lxsameer/src/serene/serene/build/{0}.o", filename)
.str() .str();
.c_str()); args.push_back(objf.c_str());
args.push_back("-o");
args.push_back(filename);
d.setCheckInputsExist(false); d.setCheckInputsExist(false);
const std::unique_ptr<clang::driver::Compilation> compilation(
d.BuildCompilation(args)); std::unique_ptr<clang::driver::Compilation> compilation;
compilation.reset(d.BuildCompilation(args));
if (!compilation) { if (!compilation) {
return 1; return 1;

View File

@ -39,7 +39,7 @@ CLOSED: [2021-07-10 Sat 09:04]
- Lexical analyzer (Lexer) - Lexical analyzer (Lexer)
- Syntax analyzer (Parser) - Syntax analyzer (Parser)
- Semantic analyzer - Semantic analyzer
- Middeend - Middleend
- Intermediate code generation - Intermediate code generation
- Code optimizer - Code optimizer
- Backend - Backend

Binary file not shown.

Binary file not shown.