Skip to content

Commit

Permalink
[cpp] buildmeta - retrieve target triple and necessary llvm setup
Browse files Browse the repository at this point in the history
  • Loading branch information
harrand committed May 20, 2024
1 parent 67beabe commit 03120bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cpp/src/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
#include "diag.hpp"
#include "timer.hpp"

#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
// note: do not remove this, even if your editor says its unused. it's used.
#include "llvm/ExecutionEngine/MCJIT.h"

#include "llvm/Support/TargetSelect.h"
#include "llvm/TargetParser/Host.h"

namespace build
{
ast::node try_find_build_meta_region(const info& i, std::string_view name, std::size_t* lex_timers, std::size_t* parse_timers);
Expand All @@ -22,6 +30,12 @@ namespace build
static_assert("unknown platform");
ret.link_name += ".out";
#endif
ret.target_triple = llvm::sys::getDefaultTargetTriple();
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
llvm::InitializeAllAsmPrinters();

// try to find the node that constitutes a build meta-region with the same name as the target provided.
ast::node meta_region = try_find_build_meta_region(ret, ret.compiler_args.target_name, lex_timers, parse_timers);
Expand Down
1 change: 1 addition & 0 deletions cpp/src/build.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace build
config_type config = config_type::debug;
std::string link_name = "a";
std::vector<std::filesystem::path> extra_input_files = {};
std::string target_triple;
config::compiler_args compiler_args;

std::filesystem::path get_output_path() const;
Expand Down

0 comments on commit 03120bc

Please sign in to comment.