[SOLVED] No_std + write_fmt (macros?) error


#1

I"m having trouble using write_fmt as others have done in the Rust kernel blogs. I have implemented write_str which works fine, however, whenever I try to use write_fmt I get this error.

Assertion failed: ((Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"), function init, file /buildslave/rust-buildbot/slave/nightly-dist-rustc-cross-host-linux/build/src/llvm/lib/IR/Instructions.cpp, line 258.

print macro:

	($fmt:expr, $($arg:tt)*) => ({
		use ::core::fmt::Write;
		use ::std::io::KernelDebugWriter;
		let mut writer = KernelDebugWriter {};
        writer.write_fmt(format_args!($fmt, $($arg)*)).unwrap();
	});

Simply calling with
writer.write_fmt(format_args!("{}", 1i32));
generates same error.


#2

Actually lazy_static!() also generates similar error…

For example

lazy_static! {
    pub static ref X: i32 = 0i32;
}
Assertion failed: ((Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"), function init, file /buildslave/rust-buildbot/slave/nightly-dist-rustc-cross-host-linux/build/src/llvm/lib/IR/Instructions.cpp, line 258.

#3

That’s an internal compiler error; those are never your fault.

You might want to open an issue in the tracker. It might be related to issue 33065, but I don’t know enough to be sure.


#4

It seems adding

[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

to Cargo.toml solved a lot of weird problems, including the two mentioned here.