[PoC] Use clang driver to link the object files
This commit is contained in:
parent
2298be5783
commit
ab54e7f5be
|
@ -166,25 +166,25 @@ int dumpAsObject(Namespace &ns) {
|
|||
|
||||
llvm::outs() << "Wrote " << filename << "\n";
|
||||
|
||||
clang::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagID(
|
||||
new clang::DiagnosticIDs());
|
||||
clang::IntrusiveRefCntPtr<clang::DiagnosticOptions> diagOpts =
|
||||
new clang::DiagnosticOptions();
|
||||
clang::TextDiagnosticPrinter diagPrinter(llvm::errs(), &*diagOpts);
|
||||
clang::DiagnosticsEngine diags(diagID, &*diagOpts, &diagPrinter);
|
||||
clang::driver::Driver d("clang", targetTriple, diags, "Serene compiler");
|
||||
std::vector<const char *> args;
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> opts =
|
||||
new clang::DiagnosticOptions;
|
||||
clang::DiagnosticsEngine diags(
|
||||
new clang::DiagnosticIDs, opts,
|
||||
new clang::TextDiagnosticPrinter(llvm::errs(), opts.get()));
|
||||
|
||||
args.push_back(filename);
|
||||
args.push_back("-o");
|
||||
args.push_back(
|
||||
clang::driver::Driver d("clang", targetTriple, diags, "Serene compiler");
|
||||
std::vector<const char *> args = {"hnt"};
|
||||
auto objf =
|
||||
llvm::formatv("/home/lxsameer/src/serene/serene/build/{0}.o", filename)
|
||||
.str()
|
||||
.c_str());
|
||||
.str();
|
||||
args.push_back(objf.c_str());
|
||||
args.push_back("-o");
|
||||
args.push_back(filename);
|
||||
|
||||
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) {
|
||||
return 1;
|
||||
|
|
|
@ -39,7 +39,7 @@ CLOSED: [2021-07-10 Sat 09:04]
|
|||
- Lexical analyzer (Lexer)
|
||||
- Syntax analyzer (Parser)
|
||||
- Semantic analyzer
|
||||
- Middeend
|
||||
- Middleend
|
||||
- Intermediate code generation
|
||||
- Code optimizer
|
||||
- Backend
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue