mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
emit .bc to the right place in wasm + debug mode
This commit is contained in:
parent
e609da8c6c
commit
541c56adb7
1 changed files with 46 additions and 28 deletions
|
@ -219,36 +219,54 @@ pub fn gen_from_mono_module(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assemble the .ll into a .bc
|
use target_lexicon::Architecture;
|
||||||
let _ = Command::new("llvm-as")
|
match target.architecture {
|
||||||
.args(&[
|
Architecture::X86_64 | Architecture::Aarch64(_) => {
|
||||||
app_ll_dbg_file.to_str().unwrap(),
|
// assemble the .ll into a .bc
|
||||||
"-o",
|
let _ = Command::new("llvm-as")
|
||||||
app_bc_file.to_str().unwrap(),
|
.args(&[
|
||||||
])
|
app_ll_dbg_file.to_str().unwrap(),
|
||||||
.output()
|
"-o",
|
||||||
.unwrap();
|
app_bc_file.to_str().unwrap(),
|
||||||
|
])
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let llc_args = &[
|
let llc_args = &[
|
||||||
"-filetype=obj",
|
"-filetype=obj",
|
||||||
app_bc_file.to_str().unwrap(),
|
app_bc_file.to_str().unwrap(),
|
||||||
"-o",
|
"-o",
|
||||||
app_o_file.to_str().unwrap(),
|
app_o_file.to_str().unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
// write the .o file. Note that this builds the .o for the local machine,
|
// write the .o file. Note that this builds the .o for the local machine,
|
||||||
// and ignores the `target_machine` entirely.
|
// and ignores the `target_machine` entirely.
|
||||||
//
|
//
|
||||||
// different systems name this executable differently, so we shotgun for
|
// different systems name this executable differently, so we shotgun for
|
||||||
// the most common ones and then give up.
|
// the most common ones and then give up.
|
||||||
let _: Result<std::process::Output, std::io::Error> =
|
let _: Result<std::process::Output, std::io::Error> =
|
||||||
Command::new(format!("llc-{}", LLVM_VERSION))
|
Command::new(format!("llc-{}", LLVM_VERSION))
|
||||||
.args(llc_args)
|
.args(llc_args)
|
||||||
.output()
|
.output()
|
||||||
.or_else(|_| Command::new("llc").args(llc_args).output())
|
.or_else(|_| Command::new("llc").args(llc_args).output())
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
panic!("We couldn't find llc-{} on your machine!", LLVM_VERSION);
|
panic!("We couldn't find llc-{} on your machine!", LLVM_VERSION);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Architecture::Wasm32 => {
|
||||||
|
// assemble the .ll into a .bc
|
||||||
|
let _ = Command::new("llvm-as")
|
||||||
|
.args(&[
|
||||||
|
app_ll_dbg_file.to_str().unwrap(),
|
||||||
|
"-o",
|
||||||
|
app_o_file.to_str().unwrap(),
|
||||||
|
])
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Emit the .o file
|
// Emit the .o file
|
||||||
use target_lexicon::Architecture;
|
use target_lexicon::Architecture;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue