Skip to content

Commit b2792e3

Browse files
xiaoyuxlujyao1
andauthored
Support UEFI: fix object generation type for UEFI target. (#623)
Co-authored-by: Jiewen Yao <[email protected]>
1 parent 114437e commit b2792e3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/lib.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1490,10 +1490,11 @@ impl Build {
14901490
cmd.push_cc_arg("-fdata-sections".into());
14911491
}
14921492
// Disable generation of PIC on bare-metal for now: rust-lld doesn't support this yet
1493-
if self
1494-
.pic
1495-
.unwrap_or(!target.contains("windows") && !target.contains("-none-"))
1496-
{
1493+
if self.pic.unwrap_or(
1494+
!target.contains("windows")
1495+
&& !target.contains("-none-")
1496+
&& !target.contains("uefi"),
1497+
) {
14971498
cmd.push_cc_arg("-fPIC".into());
14981499
// PLT only applies if code is compiled with PIC support,
14991500
// and only for ELF targets.
@@ -1556,6 +1557,12 @@ impl Build {
15561557
cmd.args.push(
15571558
format!("--target={}", target.replace("riscv64gc", "riscv64")).into(),
15581559
);
1560+
} else if target.contains("uefi") {
1561+
if target.contains("x86_64") {
1562+
cmd.args.push("--target=x86_64-unknown-windows-gnu".into());
1563+
} else if target.contains("i686") {
1564+
cmd.args.push("--target=i686-unknown-windows-gnu".into())
1565+
}
15591566
} else {
15601567
cmd.args.push(format!("--target={}", target).into());
15611568
}

0 commit comments

Comments
 (0)