Skip to content

Commit 5b682ca

Browse files
gaojiaqi7jyao1
authored andcommitted
rename profile.dev to profile.dev-opt
Binary size is not critical for tools so we can only set optimizations for debug build of `td-shim` and `td-payload`. By renaming the `profile.dev`, we can use the `dev-opt` profile for required packages and use the default `dev` profile for others. Signed-off-by: Jiaqi Gao <[email protected]>
1 parent 815152a commit 5b682ca

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ kbuild = "build --target x86_64-custom.json -Zbuild-std=core -Zbuild-std-feature
66
kimage = "run --target x86_64-custom.json -Zbuild-std=core -Zbuild-std-features=compiler-builtins-mem -- --no-run"
77
krun = "run --target x86_64-custom.json -Zbuild-std=core -Zbuild-std-features=compiler-builtins-mem"
88
ktest = "xtest --target x86_64-custom.json"
9-
xtask = "run -p xtask --release --"
9+
xtask = "run -p xtask --"
1010
image = "xtask image"

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ members = [
2121
"xtask",
2222
]
2323

24-
# the profile used for `cargo build`
25-
[profile.dev]
24+
# the profile used for debug build of `td-shim` and `td-payload`
25+
[profile.dev-opt]
26+
inherits = "dev"
2627
panic = "abort" # disable stack unwinding on panic
2728
opt-level = "z"
2829
lto = true

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ cargo xbuild -p td-payload --target x86_64-unknown-none --release --bin example
138138
cargo run -p td-shim-tools --bin td-shim-ld -- target/x86_64-unknown-none/release/ResetVector.bin target/x86_64-unknown-none/release/td-shim -t executable -p target/x86_64-unknown-none/release/example -o target/release/final-elf.bin
139139
```
140140

141+
To build the debug TdShim, please use `dev-opt` profile to build `td-shim` binary. For example:
142+
143+
```
144+
cargo xbuild -p td-shim --target x86_64-unknown-none --profile dev-opt --features=main,tdx
145+
cargo run -p td-shim-tools --bin td-shim-ld --features=linker -- target/x86_64-unknown-none/dev-opt/ResetVector.bin target/x86_64-unknown-none/dev-opt/td-shim -o target/debug/final.bin
146+
```
147+
141148
## Run
142149
REF: https://github.com/tianocore/edk2-staging/tree/TDVF
143150

xtask/src/build.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ lazy_static! {
1818
Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();
1919
static ref SHIM_OUTPUT: PathBuf = PROJECT_ROOT.join("target/x86_64-unknown-none/");
2020
static ref IMAGE_OUTPUT: PathBuf = PROJECT_ROOT.join("target/release/final.bin");
21+
static ref IMAGE_OUTPUT_DEBUG: PathBuf = PROJECT_ROOT.join("target/debug/final.bin");
2122
static ref METADATA: PathBuf = PROJECT_ROOT.join("td-shim-tools/etc/metadata.json");
2223
}
2324

@@ -227,15 +228,15 @@ impl BuildArgs {
227228
if self.release {
228229
"release"
229230
} else {
230-
"dev"
231+
"dev-opt"
231232
}
232233
}
233234

234235
fn profile_path(&self) -> &str {
235236
if self.release {
236237
"release"
237238
} else {
238-
"debug"
239+
"dev-opt"
239240
}
240241
}
241242

@@ -255,7 +256,11 @@ impl BuildArgs {
255256
}
256257

257258
fn output(&self) -> Result<PathBuf> {
258-
let path = self.output.as_ref().unwrap_or(&IMAGE_OUTPUT);
259+
let path = self.output.as_ref().unwrap_or(if self.release {
260+
&IMAGE_OUTPUT
261+
} else {
262+
&IMAGE_OUTPUT_DEBUG
263+
});
259264

260265
// Get the absolute path of the target file
261266
let absolute = if path.is_absolute() {

0 commit comments

Comments
 (0)