-
Notifications
You must be signed in to change notification settings - Fork 60
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
Multiple matching crates error, if dependency on compiletest is optional #114
Comments
Yes, this should be something that's fixable by |
Hmm, looking at
is the problem? |
You might also want to try not using |
Thanks for your replies! Just FYI, I won't be able to follow up here today, and tomorrow I'm off to RustFest. I'll check back in next week, or the week after. |
No problem 😄 This is a problem that's been a thorn in my side for some time, so it'd be nice to have it solved! Have fun at RustFest! Say hi to the guys from Seasoned Software if you catch them! |
Thank you! I don't know who they are, but I'll keep my eyes open :) |
@laumann I did some research based on your comments.
I don't think so. I commented it out and it made no difference. In any case,
I didn't really know what to set it to, so I checked out what Maybe compiletest should do the same, but I don't know how it would know which file is the right one. For reference, I think this is the relevant piece of code for |
Thanks for looking into this. Yes, you are correct, Sounds like the rlibs might be the problem, as you say. When |
Yes. After a
And another one in
The first Interestingly, if I run just
If I remove the rlibs (and just the rlibs), both variants of |
So we can pretty much say that the "duplicate" Can we identify which is which? If so, we might be able to just add those as link flags, instead of the entire folder. Otherwise I'm not what to do. Surely, Cargo has a way of knowing which is which? |
I've taken a look at the Cargo source trying to find that out, but didn't get very far before I ran out of time. Certainly it must know, but the question is how to get that knowledge out of Cargo and into compiletest. I plan to take a closer look at the Cargo code next week (if I find the time). |
OK, thanks again for looking into it 😃 |
I've taken another look at the Cargo code, but didn't come up with anything useful before running out of time. I've now added a workaround on my side (disabled caching on Travis), and have decided to leave this be for now. Sorry, I would have liked to fix this properly, but my time is limited and I have to pick my battles. |
meh, this is kind of annoying. One has to always |
Just ran into this as well (#147). The Has anyone figured out what exactly needs to be cleaned so it works in a stable fashion? |
@laumann Ok, here's what seems to work for me:
Using the cleanup code below (to replace Disclaimer: there may be some gotchas I'm not aware about but it seems to work so far for me. use std::fs::{read_dir, remove_file};
fn clean_rlibs(config: &compiletest_rs::Config) {
if config.target_rustcflags.is_some() {
for directory in config.target_rustcflags
.as_ref()
.unwrap()
.split_whitespace()
{
if let Ok(mut entries) = read_dir(directory) {
while let Some(Ok(entry)) = entries.next() {
let f = entry.file_name().clone().into_string().unwrap();
if f.ends_with(".rmeta") {
let prefix = &f[..f.len() - 5];
let _ = remove_file(entry.path());
if let Ok(mut entries) = read_dir(directory) {
while let Some(Ok(entry)) = entries.next() {
let f = entry.file_name().clone().into_string().unwrap();
if f.starts_with(prefix) && !f.ends_with(".rmeta") {
let _ = remove_file(entry.path());
}
}
}
}
}
}
}
}
} |
Thanks for looking further into this @aldanor 😄 Without yet having tried it, is this a replacement for I'm happy to have a PR with this. |
@laumann Np. Yea, this is a replacement to the current Disclaimer: I don’t have deep understanding of why this works, I just took a snapshot of I could open a PR if that helps :) |
@aldanor A PR would be nice - then we could ask others for feedback. I tried it out on the test-project and it seems to work fine. |
I've avoided this issue by mimicking the way cargo calls config.target_rustcflags = Some("--edition=2021 -L dependency=target/debug/deps/ --extern mycrate=<path to mycrate rlib> --extern adependency=<path to adependency rlib>"); where You can see an example of this working here. |
I'm trying to use compiletest for a
#[no_std]
crate. Because the crate contains examples that need to be built for an embedded platform wherestd
is not available (thumbv6m-none-eabi), I needed to make the dependency on compiletest optional and add a Cargo feature for it.Further details:
This works works fine:
This does not work:
It results in the following error (excerpt from full build log):
I believe the important part is
multiple matching crates
. I think I understand what happens here: We have two versions of the crate, one with the feature, one without, and rustc doesn't know which one to use. Is this something that could be fixed inclean_rmeta
?The text was updated successfully, but these errors were encountered: