mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
cleanup targets and llvm config to properly progate and build with any subset of features
This commit is contained in:
parent
0c0a92814c
commit
d78b351798
10 changed files with 106 additions and 50 deletions
|
@ -4,7 +4,6 @@ use roc_gen_llvm::llvm::build::module_from_builtins;
|
|||
pub use roc_gen_llvm::llvm::build::FunctionIterator;
|
||||
use roc_load::file::{LoadedModule, MonomorphizedModule};
|
||||
use roc_module::symbol::{Interns, ModuleId};
|
||||
#[cfg(feature = "llvm")]
|
||||
use roc_mono::ir::OptLevel;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
@ -19,6 +18,7 @@ pub struct CodeGenTiming {
|
|||
|
||||
// TODO: If modules besides this one start needing to know which version of
|
||||
// llvm we're using, consider moving me somewhere else.
|
||||
#[cfg(feature = "llvm")]
|
||||
const LLVM_VERSION: &str = "12";
|
||||
|
||||
// TODO instead of finding exhaustiveness problems in monomorphization, find
|
||||
|
@ -171,6 +171,50 @@ fn report_problems_help(
|
|||
problems_reported
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "llvm"))]
|
||||
pub fn gen_from_mono_module(
|
||||
arena: &bumpalo::Bump,
|
||||
loaded: MonomorphizedModule,
|
||||
_roc_file_path: &Path,
|
||||
target: &target_lexicon::Triple,
|
||||
app_o_file: &Path,
|
||||
opt_level: OptLevel,
|
||||
_emit_debug_info: bool,
|
||||
) -> CodeGenTiming {
|
||||
match opt_level {
|
||||
OptLevel::Optimize => {
|
||||
todo!("Return this error message in a better way: optimized builds not supported without llvm backend");
|
||||
}
|
||||
OptLevel::Normal | OptLevel::Development => {
|
||||
gen_from_mono_module_dev(arena, loaded, target, app_o_file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "llvm")]
|
||||
pub fn gen_from_mono_module(
|
||||
arena: &bumpalo::Bump,
|
||||
loaded: MonomorphizedModule,
|
||||
roc_file_path: &Path,
|
||||
target: &target_lexicon::Triple,
|
||||
app_o_file: &Path,
|
||||
opt_level: OptLevel,
|
||||
emit_debug_info: bool,
|
||||
) -> CodeGenTiming {
|
||||
match opt_level {
|
||||
OptLevel::Normal | OptLevel::Optimize => gen_from_mono_module_llvm(
|
||||
arena,
|
||||
loaded,
|
||||
&roc_file_path,
|
||||
target,
|
||||
app_o_file,
|
||||
opt_level,
|
||||
emit_debug_info,
|
||||
),
|
||||
OptLevel::Development => gen_from_mono_module_dev(arena, loaded, target, app_o_file),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO how should imported modules factor into this? What if those use builtins too?
|
||||
// TODO this should probably use more helper functions
|
||||
// TODO make this polymorphic in the llvm functions so it can be reused for another backend.
|
||||
|
@ -404,7 +448,7 @@ pub fn gen_from_mono_module_llvm(
|
|||
emit_o_file,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "target-wasm32")]
|
||||
pub fn gen_from_mono_module_dev(
|
||||
arena: &bumpalo::Bump,
|
||||
loaded: MonomorphizedModule,
|
||||
|
@ -415,13 +459,31 @@ pub fn gen_from_mono_module_dev(
|
|||
|
||||
match target.architecture {
|
||||
Architecture::Wasm32 => gen_from_mono_module_dev_wasm32(arena, loaded, app_o_file),
|
||||
Architecture::X86_64 => {
|
||||
Architecture::X86_64 | Architecture::Aarch64(_) => {
|
||||
gen_from_mono_module_dev_assembly(arena, loaded, target, app_o_file)
|
||||
}
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "target-wasm32"))]
|
||||
pub fn gen_from_mono_module_dev(
|
||||
arena: &bumpalo::Bump,
|
||||
loaded: MonomorphizedModule,
|
||||
target: &target_lexicon::Triple,
|
||||
app_o_file: &Path,
|
||||
) -> CodeGenTiming {
|
||||
use target_lexicon::Architecture;
|
||||
|
||||
match target.architecture {
|
||||
Architecture::X86_64 | Architecture::Aarch64(_) => {
|
||||
gen_from_mono_module_dev_assembly(arena, loaded, target, app_o_file)
|
||||
}
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "target-wasm32")]
|
||||
fn gen_from_mono_module_dev_wasm32(
|
||||
arena: &bumpalo::Bump,
|
||||
loaded: MonomorphizedModule,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue