From 96fe4c52ec02b5768d162fea942b82c1500f1c33 Mon Sep 17 00:00:00 2001 From: Maurice Lam Date: Wed, 13 Sep 2023 18:01:49 +0000 Subject: [PATCH] Add build_std argument to allow specifying which std components to build --- src/main.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 36eb167..fef75b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,6 +79,10 @@ struct Args { #[arg(long, default_value = "dot")] format: OutputFormat, + /// Argument forwarded to cargo as `-Zbuild-std=?` + #[arg(long)] + build_std: Option, + /// consider only the call graph that starts from this node start: Option, } @@ -161,14 +165,21 @@ fn run() -> anyhow::Result { cargo.arg("--release"); } - let build_std = if is_no_std { - "-Zbuild-std=core,alloc,compiler_builtins" + if is_no_std && args.build_std.is_none() { + warn!(concat!( + "Building no_std target, did you mean to specify ", + "--build_std=core,alloc,compiler_builtins ?", + )) + } + + let build_std = if let Some(std_components) = args.build_std { + format!("-Zbuild-std={std_components}") } else { - "-Zbuild-std" + String::from("-Zbuild-std") }; cargo.args(&[ - build_std, + &build_std, "--color=always", "--", // .ll file