Skip to content

Commit fea3e89

Browse files
author
Sherry Fan
committed
improve build
1 parent 24d701b commit fea3e89

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

Makefile.toml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ CARGO_MAKE_RUST_TARGET_ARCH = { value = "x86_64", condition = { env_not_set = ["
1111
PACKAGE_NAME = { value = "services_benchmark_test", condition = { env_not_set = ["PACKAGE_NAME"] } }
1212
BUILD_MODE = { value = "release", condition = { env_not_set = ["BUILD_MODE"] } }
1313

14+
# no_std build flags for UEFI
15+
NO_STD_FLAGS = "-Zbuild-std=core,compiler_builtins,alloc -Zbuild-std-features=compiler-builtins-mem -Zunstable-options"
16+
1417
# Target configuration based on architecture
1518
UEFI_TARGET_X64 = "x86_64-unknown-uefi"
1619
UEFI_TARGET_ARM64 = "aarch64-unknown-uefi"
@@ -42,28 +45,28 @@ script = [
4245
[tasks.build-lib]
4346
description = "Build the library for UEFI target"
4447
command = "cargo"
45-
args = ["build", "--lib", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}"]
48+
args = ["build", "--lib", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "@@split(NO_STD_FLAGS, )"]
4649
dependencies = ["setup"]
4750

4851
# Build library in release mode
4952
[tasks.build-lib-release]
5053
description = "Build the library for UEFI target in release mode"
5154
command = "cargo"
52-
args = ["build", "--lib", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "--release"]
55+
args = ["build", "--lib", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "--release", "@@split(NO_STD_FLAGS, )"]
5356
dependencies = ["setup"]
5457

5558
# Build binary
5659
[tasks.build-bin]
5760
description = "Build the binary for UEFI target"
5861
command = "cargo"
59-
args = ["build", "--bin", "${PACKAGE_NAME}", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}"]
62+
args = ["build", "--bin", "${PACKAGE_NAME}", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "@@split(NO_STD_FLAGS, )"]
6063
dependencies = ["setup"]
6164

6265
# Build binary in release mode
6366
[tasks.build-bin-release]
6467
description = "Build the binary for UEFI target in release mode"
6568
command = "cargo"
66-
args = ["build", "--bin", "${PACKAGE_NAME}", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "--release"]
69+
args = ["build", "--bin", "${PACKAGE_NAME}", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "--release", "@@split(NO_STD_FLAGS, )"]
6770
dependencies = ["setup"]
6871

6972
# Build EFI application
@@ -149,7 +152,7 @@ args = ["llvm-cov", "--no-report"]
149152
[tasks.clippy]
150153
description = "Run clippy for the package"
151154
command = "cargo"
152-
args = ["clippy", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "--", "-D", "warnings"]
155+
args = ["clippy", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "@@split(NO_STD_FLAGS, )", "--", "-D", "warnings"]
153156
dependencies = ["setup"]
154157

155158
# Format code
@@ -162,7 +165,7 @@ args = ["fmt", "-p", "${PACKAGE_NAME}"]
162165
[tasks.check]
163166
description = "Check code for the package"
164167
command = "cargo"
165-
args = ["check", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}"]
168+
args = ["check", "-p", "${PACKAGE_NAME}", "--target", "${UEFI_TARGET}", "@@split(NO_STD_FLAGS, )"]
166169
dependencies = ["setup"]
167170

168171
# Full CI pipeline
@@ -197,4 +200,4 @@ script = "cspell --quiet --no-progress --no-summary --dot --gitignore -e \"{.g
197200

198201
[tasks.all]
199202
description = "Run all tasks for PR readiness."
200-
dependencies = ["deny", "clippy", "cspell", "build", "test", "coverage", "fmt", "doc"]
203+
dependencies = ["deny", "clippy", "cspell", "build", "test", "coverage", "fmt", "doc"]

services_benchmark_test/src/bench/event.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#[cfg(target_os = "uefi")]
21
use alloc::vec::Vec;
32

4-
#[cfg(not(target_os = "uefi"))]
5-
use std::vec::Vec;
6-
73
use core::{ffi::c_void, ptr};
84

95
use mu_rust_helpers::perf_timer::{Arch, ArchFunctionality as _};

services_benchmark_test/src/bench/protocol.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ use crate::{
1111
error::BenchError,
1212
};
1313

14-
#[cfg(target_os = "uefi")]
1514
use alloc::boxed::Box;
1615

17-
#[cfg(not(target_os = "uefi"))]
18-
use std::boxed::Box;
19-
2016
/// Benchmarks protocol installation performance.
2117
pub(crate) fn bench_install_protocol_interface(
2218
_handle: efi::Handle,

services_benchmark_test/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ pub static BOOT_SERVICES: StandardBootServices = StandardBootServices::new_unini
2828
#[cfg(target_os = "uefi")]
2929
extern crate alloc;
3030

31-
#[cfg(target_os = "uefi")]
32-
use alloc::{string::String, string::ToString, vec::Vec};
33-
34-
#[cfg(not(target_os = "uefi"))]
35-
use std::{string::String, string::ToString, vec::Vec};
31+
use alloc::{
32+
string::{String, ToString},
33+
vec::Vec,
34+
};
3635

3736
use core::fmt::Write;
3837
use mu_rust_helpers::perf_timer::{Arch, ArchFunctionality as _};

0 commit comments

Comments
 (0)