-
Notifications
You must be signed in to change notification settings - Fork 14
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
Can't compile when using a workspace #117
Comments
Ugh, I hit that assertion myself, but for me compiling with My guess (and it really is only a wild guess) would be that this could be something address space related. I'll try to reproduce this again tomorrow and get at least the types involved, which should hopefully help understanding what is going on. |
FWIW, it seems incredibly unlikely that workspaces have anything to do with the root of the problem. LTO is more likely, but I've compiled with LTO and not experienced it. One thing that I have run into before is arbitrary reordering of pieces of the standard library cause LLVM to process things in a specific order and then choke on that. This can make reproducing a problem a very tricky business. |
This is my hunch too. After my initial patch that added support for functions in non-default address spaces (and the subsequent commit of an adaption of it by another LLVM developer), I've hit a few casting related problems in LLVM due to AVR's program memory address space now being set to The usual culprit - |
If you have a debugger handy, in In GDB, type
This will print the textual IR representation of the type being casted. If it looks like a function pointer, or it contains the text |
Yes, noticed that as well :(
I was also pretty irritated when I noticed this. The thing is, it worked when I recreated the project outside the workspace. I was then able to reliably reproduce it in the workspace project and fix it by removing the workspace ... Maybe in some way related to the fact that you have to specify profiles in the workspace root instead of the crate's
I will try that and report back, thanks! |
Note that (from my experiences in the past) you may need an unoptimized LLVM for that to work (optimized + debug info is not enough since, IIRC, local variables may have been optimized or gdb may not find methods). |
In my case: $ frame 4
$ p Ty->dump()
void (%"str::traits::{{impl}}::index::{{closure}}"*)*
$ p C->dump()
define internal fastcc void @"core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}"(...) unnamed_addr addrspace(1) #2 { ... }
$ p opc
llvm::Instruction::BitCast
$ frame 8
$ p I.dump()
call fastcc addrspace(0) void bitcast (void (%"type 0x7fffdc629830"*)* @"core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}" to void (%0*)*)(%"str::traits::{{impl}}::index::{{closure}}"* noalias nocapture nonnull dereferenceable(6) %4) #3, !noalias !38
$ bt
#4 llvm::ConstantExpr::getCast (oc=47, C=0x7fffdc78bcb8, Ty=0x7fffdc2c0e90, OnlyIfReduced=false)
at [...]/src/llvm/lib/IR/Constants.cpp:1512
#5 llvm::ConstantExpr::getWithOperands (this=0x7fffdc78d288, Ops=..., Ty=0x7fffdc2c0e90, OnlyIfReduced=false, SrcTy=0x0)
at [...]/src/llvm/lib/IR/Constants.cpp:1206
#6 (anonymous namespace)::Mapper::mapValue (this=0x7fffdc003d40, V=0x7fffdc78d288) at [...]/src/llvm/lib/Transforms/Utils/ValueMapper.cpp:475
#7 (anonymous namespace)::Mapper::remapInstruction (this=0x7fffdc003d40, I=0x7fffdc793730)
at [...]/src/llvm/lib/Transforms/Utils/ValueMapper.cpp:873
#8 (anonymous namespace)::Mapper::remapFunction (this=0x7fffdc003d40, F=...)
at [...]/src/llvm/lib/Transforms/Utils/ValueMapper.cpp:955
#9 (anonymous namespace)::Mapper::flush (this=0x7fffdc003d40) at [...]/src/llvm/lib/Transforms/Utils/ValueMapper.cpp:855
#10 (anonymous namespace)::FlushingMapper::~FlushingMapper (this=0x7fffe8cd9bb0, __in_chrg=<optimized out>)
at [...]/src/llvm/lib/Transforms/Utils/ValueMapper.cpp:1073
#11 llvm::ValueMapper::mapValue (this=0x7fffe8cda280, V=...)
at [...]/src/llvm/lib/Transforms/Utils/ValueMapper.cpp:1098
#12 (anonymous namespace)::IRLinker::run (this=0x7fffe8cd9eb0)
at [...]/src/llvm/lib/Linker/IRMover.cpp:1355
#13 llvm::IRMover::move(std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >, llvm::ArrayRef<llvm::GlobalValue*>, std::function<void (llvm::GlobalValue&, std::function<void (llvm::GlobalValue&)>)>, bool) (this=0x555555a9ab60, Src=std::unique_ptr<llvm::Module> containing 0x0, ValuesToLink=..., AddLazyFor=..., IsPerformingImport=false)
at [...]/src/llvm/lib/Linker/IRMover.cpp:1476
#14 (anonymous namespace)::ModuleLinker::run (this=0x7fffe8cda510)
at [...]/src/llvm/lib/Linker/LinkModules.cpp:557
#15 llvm::Linker::linkInModule(std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >, unsigned int, std::function<void (llvm::Module&, llvm::StringSet<llvm::MallocAllocator> const&)>) (this=0x555555a9ab60, Src=std::unique_ptr<llvm::Module> containing 0x0, Flags=0, InternalizeCallback=...)
at [...]/src/llvm/lib/Linker/LinkModules.cpp:579
#16 LLVMRustLinkerAdd (L=0x555555a9ab60, BC=<optimized out>, Len=<optimized out>)
at ../rustllvm/Linker.cpp:64
#17 rustc_codegen_llvm::back::lto::fat_lto::{{closure}} () |
A few things to note:
|
Minimized: target datalayout = "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"
target triple = "avr-unknown-unknown"
define internal { i16, i16 } @will_be_tail_call([0 x i8]*) addrspace(1) {
start:
store [0 x i8]* %0, [0 x i8]** undef, align 1
ret { i16, i16 } undef
}
define void @main() addrspace(1) personality i32 (...) addrspace(1)* @rust_eh_personality {
start:
invoke addrspace(1) { i16, i16 } @will_be_tail_call([0 x i8]* undef)
to label %bb29 unwind label %cleanup
bb29:
unreachable
cleanup:
landingpad { i8*, i32 }
cleanup
resume { i8*, i32 } undef
}
declare i32 @rust_eh_personality(...) addrspace(1) If you run this code through |
I've been skimming the uses of @dylanmckay: Do you have a link to an example fix patch?
|
Great work. One way to confirm whether or not |
|
Yeah, I am a bit concerned that there's latent bugs hidden deep within LLVM caused by address space assumptions, but on the plus side, the LLVM IR verifier will always catch it and trigger an error and so it'll never silently break. This is made a bit more likely due to AVR being an experimental backend and so only the experimental buildbots compile it. This means LLVM developers may still introduce uses of |
N.B. The only thing stopping me from submitting an RFC to remove the experimental status now is the lack of integration test suite. Once I've finished up the local branch I linked above, I should have integration tests working. |
Thanks for reminding me of this, I hadn't thought of |
I'll see if there are other situation in which Edit: One more in |
So, I can compile However, both issues I've found have two things in common: (1) They happened due to I then did a brief search for I took an even shorter look at other uses of Btw, the |
Here is the commit fixing all the uses in I didn't run any tests on this (yet), but it compiles and in general makes sense, as far as I can tell. I fixed the calls to (1) Copying the address space from the function that was being replaced. @dylanmckay: Can you commit this directly to LLVM or should I post this to reviews.llvm.org? Edit: I added some (GitHub) comments to the commit about things I noticed / wasn't 100% sure about. |
I've realised that the verifier will not always catch instances of this; it may not come up if the I wrote up LLVM bug PR39573 to track the creation of a purpose-built AVR-specific pass that ensures every single function is in |
Extremely low chance of regression; there is not a single in-tree LLVM backend that sets program address space to
Either or. It looks like you've got four LLVM commits to your name; you could definitely get push access to LLVM trunk if you wanted it. I like to encourage this because it means your work will come up under your own name (as opposed to a "Patch by" line) and attached to your GitHub so you can win social points if that's your kind of thing. That way it doesn't just look like I did everybody's work at a glance. Usually after a few LLVM patches, people send an email to Chris and he gives it. I think I got commit access after about 2-3 patches. Completely up to you though, I have no problem committing and/or reviewing the patches $ git log | grep "Tim Neu"
Patch by Peter Nimmervoll (@brainlag) and Tim Neumann (@TimNN)
Patch by Tim Neumann
Patch by Tim Neumann!
Patch by Tim Neumann. |
I know that :) I was mostly asking: Are you comfortable with committing this patch without another review from someone else.
I'm fine with you committing this patch for now, I'll think about getting commit access. |
I added a few tests and upstreamed in r349469. |
I guess that now we just need to update LLVM or cherry-pick the patch. |
Cherry-picked the fix in a3b0834. |
After upgrading to the new compiler, I can no longer build my project that is part of a cargo workspace. Building outside of a workspace works. I get the following error:
I get this error even with a completely stripped down file like:
The only other observation I was able to make is that is does not happen when I remove
lto = true
from the rootCargo.toml
. For reference:The text was updated successfully, but these errors were encountered: