diff --git a/.cargo/config.toml b/.cargo/config.toml index 8b6e8d5..85d49dc 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,13 +1,2 @@ [build] target = "x86_64-unknown-uefi" - -[target.x86_64-unknown-uefi] -rustflags = [ - "-Clink-arg=/heap:0,0", - "-Clink-arg=/stack:0,0", - "-Clink-arg=/dll", - "-Clink-arg=/base:0", - "-Clink-arg=/align:32", - "-Clink-arg=/filealign:32", - "-Clink-arg=/subsystem:efi_boot_service_driver" -] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..6077d90 --- /dev/null +++ b/build.rs @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-3.0-only + +use std::env; + +fn main() { + let target = env::var("TARGET").unwrap(); + if target.ends_with("-unknown-uefi") { + println!("cargo::rustc-link-arg=/heap:0,0"); + println!("cargo::rustc-link-arg=/stack:0,0"); + println!("cargo::rustc-link-arg=/dll"); + println!("cargo::rustc-link-arg=/base:0"); + println!("cargo::rustc-link-arg=/align:32"); + println!("cargo::rustc-link-arg=/filealign:32"); + println!("cargo::rustc-link-arg=/subsystem:efi_boot_service_driver"); + } +}