hoist rustc flag string array to global const

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-27 20:55:21 +00:00 committed by Jason Volk
parent c3e751542d
commit ea95627dce

View file

@ -9,11 +9,13 @@ pub(super) fn flags_capture(args: TokenStream) -> TokenStream {
};
let flag = std::env::args().collect::<Vec<_>>();
let flag_len = flag.len();
let ret = quote! {
pub static RUSTC_FLAGS: [&str; #flag_len] = [#( #flag ),*];
#[conduit_core::ctor]
fn _set_rustc_flags() {
let flags = &[#( #flag ),*];
conduit_core::info::rustc::FLAGS.lock().expect("locked").insert(#crate_name, flags);
conduit_core::info::rustc::FLAGS.lock().expect("locked").insert(#crate_name, &RUSTC_FLAGS);
}
// static strings have to be yanked on module unload