Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UEFI: fix object generation type for UEFI target. #623

Merged
merged 1 commit into from Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/lib.rs
Expand Up @@ -1490,10 +1490,11 @@ impl Build {
cmd.push_cc_arg("-fdata-sections".into());
}
// Disable generation of PIC on bare-metal for now: rust-lld doesn't support this yet
if self
.pic
.unwrap_or(!target.contains("windows") && !target.contains("-none-"))
{
if self.pic.unwrap_or(
!target.contains("windows")
&& !target.contains("-none-")
&& !target.contains("uefi"),
) {
cmd.push_cc_arg("-fPIC".into());
// PLT only applies if code is compiled with PIC support,
// and only for ELF targets.
Expand Down Expand Up @@ -1556,6 +1557,12 @@ impl Build {
cmd.args.push(
format!("--target={}", target.replace("riscv64gc", "riscv64")).into(),
);
} else if target.contains("uefi") {
if target.contains("x86_64") {
cmd.args.push("--target=x86_64-unknown-windows-gnu".into());
} else if target.contains("i686") {
cmd.args.push("--target=i686-unknown-windows-gnu".into())
}
} else {
cmd.args.push(format!("--target={}", target).into());
}
Expand Down