Add wasi-exec-model cg option for emitting wasi reactors
This commit is contained in:
parent
7efc097c4f
commit
92d3537abb
9 changed files with 69 additions and 20 deletions
|
@ -1193,6 +1193,7 @@ fn exec_linker(
|
|||
|
||||
fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
|
||||
let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) {
|
||||
(CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe,
|
||||
(CrateType::Executable, false, RelocModel::Pic) => LinkOutputKind::DynamicPicExe,
|
||||
(CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe,
|
||||
(CrateType::Executable, true, RelocModel::Pic) => LinkOutputKind::StaticPicExe,
|
||||
|
|
|
@ -314,6 +314,10 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
self.cmd.arg("-static");
|
||||
self.build_dylib(out_filename);
|
||||
}
|
||||
LinkOutputKind::WasiReactorExe => {
|
||||
self.linker_arg("--entry");
|
||||
self.linker_arg("_initialize");
|
||||
}
|
||||
}
|
||||
// VxWorks compiler driver introduced `--static-crt` flag specifically for rustc,
|
||||
// it switches linking for libc and similar system libraries to static without using
|
||||
|
@ -662,6 +666,9 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||
arg.push(out_filename.with_extension("dll.lib"));
|
||||
self.cmd.arg(arg);
|
||||
}
|
||||
LinkOutputKind::WasiReactorExe => {
|
||||
panic!("can't link as reactor on non-wasi target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1085,6 +1092,10 @@ impl<'a> Linker for WasmLd<'a> {
|
|||
LinkOutputKind::DynamicDylib | LinkOutputKind::StaticDylib => {
|
||||
self.cmd.arg("--no-entry");
|
||||
}
|
||||
LinkOutputKind::WasiReactorExe => {
|
||||
self.cmd.arg("--entry");
|
||||
self.cmd.arg("_initialize");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue