Skip to content

Commit 607e6a7

Browse files
committed
fix entrypoint
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent cefde96 commit 607e6a7

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/cargo_cmd.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub trait CargoCmd {
1313
fn cc_env(&mut self, triplet: impl AsRef<str>, cc: impl AsRef<Path>) -> &mut Self;
1414
fn ar_env(&mut self, triplet: impl AsRef<str>, ar: impl AsRef<Path>) -> &mut Self;
1515
fn sysroot(&mut self, path: impl AsRef<Path>) -> &mut Self;
16+
fn entrypoint(&mut self, entry: impl AsRef<str>) -> &mut Self;
1617
fn append_rustflags(&mut self, flags: impl AsRef<OsStr>) -> &mut Self;
1718
fn append_cflags(&mut self, triplet: impl AsRef<str>, flags: impl AsRef<OsStr>) -> &mut Self;
1819
fn append_bindgen_cflags(&mut self, flags: impl AsRef<OsStr>) -> &mut Self;
@@ -102,6 +103,11 @@ impl CargoCmd for Command {
102103
.append_rustflags(path.as_ref())
103104
}
104105

106+
fn entrypoint(&mut self, entry: impl AsRef<str>) -> &mut Self {
107+
let entry = entry.as_ref();
108+
self.append_rustflags(format!("-Clink-args=-e{entry}"))
109+
}
110+
105111
fn append_rustflags(&mut self, flags: impl AsRef<OsStr>) -> &mut Self {
106112
if flags.as_ref().is_empty() {
107113
return self;

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl CargoCommandExt for std::process::Command {
8383
fn populate_from_args(&mut self, args: &Args) -> &mut Self {
8484
self.target(&args.target);
8585
self.sysroot(args.sysroot_dir());
86+
self.entrypoint("entrypoint");
8687
if let Some(clang) = &args.clang {
8788
self.cc_env(&args.target, clang);
8889
} else {

src/sysroot.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub fn build(args: &Args) -> Result<()> {
2424
let target_spec = match args.target.as_str() {
2525
"x86_64-hyperlight-none" => {
2626
let mut spec = get_spec(args, "x86_64-unknown-none")?;
27-
spec.entry_name = Some("entrypoint".into());
27+
// entry_name seems to be ignored, use RUSTFLAGS with -Clink-args=-eentrypoint instead
28+
//spec.entry_name = Some("entrypoint".into());
2829
spec.code_model = Some("small".into());
2930
spec.linker = Some("rust-lld".into());
3031
spec.linker_flavor = Some("gnu-lld".into());

0 commit comments

Comments
 (0)