-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
globally disabled logs still require symbols on x86 = linker error #411
Comments
git bisect points to PR #291 as the cause of this issue |
a user has reported the |
477: Disable logging calls via conditional compilation when all defmt features are disabled r=jonas-schievink a=WasabiFan This is my take on fixing #411. It's not clear whether this is the "right" fix, as that issue was marked with a "medium" difficulty tag which would seem to imply there was more work expected here. Either way, it allows the sample in the linked issue to build for me, and fixes the usage in my own project. The change here is to replace an "if" emitted by the logging macros (albeit with constant boolean conditions evaluation time) with an explicit `#[cfg(...)]` annotation. With the new form, the compiler seems to successfully strip out the unreachable macro body and as such there are no broken references to the nonexistent symbols. Co-authored-by: Kaelin Laundry <wasabifan@outlook.com>
I think this issue is solved by #477. @WasabiFan tested it on windows and it also works for me on fedora. |
Unfortunately (in addition to having inadvertently introduced breaking changes), this doesn't seem to solve the problem in all cases. To give a sampling:
So I'm pretty strongly convinced that my fix is not sufficient to be truly dependable. However, the fact that it can build demonstrates that there isn't much standing in the way of fixing this the "right" way -- I think bounding all four functions which declare external symbols (those containing In my own project I have now (surely inadvisably) enabled the I think for now this issue should be re-opened and I'd be interested to hear thoughts on adding those additional feature checks to the four functions mentioned above -- i.e., disable any attempt to resolve those symbols when no defmt features are enabled. In that case, building with I added the following to my [dev-dependencies]
defmt = { version = "0.2.2", features = [ "unstable-test" ] } And adopted the new Cargo feature resolver, so that the feature is not enabled in production builds: [package]
resolver = "2" |
Hi @WasabiFan, Could you reproduce the error on any other windows machine, except yours? And am I understanding it correctly that building the binary works for you, but building the tests fails? |
I could not. I tried on mine and that of one team member. I was on Rust 1.51.0 and linker version
That's correct. I've included some more investigation below. For reference, this is what the failure looks like on Windows:
I think I've found why my particular project fails when building tests: adding a Here's a modified version of the repro case from the OP: fn main() {
defmt::info!("hello");
println!("Hello, world!");
}
#[cfg(test)]
mod tests {
use proptest::prelude::*;
proptest! {
#[test]
fn something(i in 0..10) {
}
}
} With the following dependencies in an otherwise bare project:
...gives the same error quoted above. Again, this is probably specific to the software versions on my machine. Commenting out the |
Further update -- I bit the bullet and tried an upgrade to Rust 1.52.1; the error no longer reproduces. Edit: the latter part was user error, I can consistently repro on 1.51.0 yet pass a test run on 1.52.1. |
Annnnnd it's back. This time, I ran a The MS linker is doing something undocumented which I'm running right up against in inconsistent ways. |
Is it now also happening on |
That's correct. |
I will try to test it on my windows partition tomorrow. I'd like to reproduce it on at least one other machine, before taking further steps. |
I just failed to reproduce the error. I will close this issue for now, since the original error is resolved. If you encounter this issue again and are able to reproduce it somewhat realiably, please open a new issue! PS: setting up rust on windows isn't exactly fun, is it? 😅 |
This program:
fails to link if you use
defmt
v0.2.0but links and runs fine if you use
defmt
v0.1.3note that all logs are disabled in both cases (no Cargo features were added to the crate's Cargo.toml)
The text was updated successfully, but these errors were encountered: