-
Notifications
You must be signed in to change notification settings - Fork 1
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
Timer examples fails build with linker error when LTO is enabled #3
Comments
@pftbest Do you know which part of the code generated by LLVM is causing issues with our linker scripts? The error message looks to me like it came from the assembler, which runs before linking. |
@YuhanLiin The issue is not specifically in linker scripts, as you noticed correctly they are only used at link time. The issue is in architecture. The way we generate interrupt vectors is different from what is currently implemented in LLVM by the code from link above. Latest LLVM code tries to automatically create a 2 byte interrupt vector for every interrupt handler it generates, and places them each in a different sections named __interrupt_vector_X. It does this because default linker scripts provided by TI expect to find interrupt vectors in this sections. Our linker scripts expect a different layout, we have a single section where all the interrupt vectors are located. And all of them are assigned to a weak symbol pointing to default handler. You can see them here. The assembler error is caused by the names conflict between our vectors and automatically generated ones. Even if we somehow solve the names conflict by for example renaming it somehow, the underlying issue will still be present. I want to solve this by sending a patch to LLVM so it doesn't generate this vectors automatically for our use case, like it did in older versions of LLVM. Because we already have svd2rust generator which does it better. cc @cr1901 |
@pftbest I say send the patch, but try to get in contact with the Access Softek maintainers as well and see how much they object :P. |
Pushed the commit, now we wait for review |
Looks like it's been merged. |
Interesting... I intended to submit a patch, but didn't get around to it because of health issues. That being said, I just updated my own copy of the Rust source to current
On the other hand, I keep a reference to upstream for visualization purposes (
@pftbest's msp430 patch made it into LLVM upstream, but didn't make it's way into Rust's copy yet. Adding his patch isn't difficult; I've done a cherry-pick into Rust's copy of LLVM before and am happy to do it again. But before I do that (the patch needs to be merged anyway to prevent assertion failures when they are enabled), I'm curious why @YuhanLiin's issue disappeared without the patch being merged? |
Did the link error go away? The last time I tried it still couldn't link. If you managed to make it go away, which nightly did you use? |
No, and this is currently the behavior I would expect until I get the patch into Rust. I'll do that soon. Thanks for checking! |
…chton Bump LLVM submodule to fix LLVM assertion failure in MSP430 interrupt generation. This PR brings in changes introduced by [this cherry-pick](rust-lang/llvm-project#37) to the Rust repository. Nightlies downloaded from `rustup` do not appear to have llvm assertions enabled; the assertion failure [sometimes](YuhanLiin/msp430fr2355-quickstart#3) causes link errors that shouldn't occur. I couldn't find any indication of other bugs; however, it should still be fixed.
Just got the chance to try the newest nightly (1.42) and all the interrupt examples build and run fine with LTO. |
When building the timer example on release mode with LTO, the build fails at link time with the following error:
note: "msp430-elf-gcc" "-mcpu=msp430" "-c" "-o" "/home/yuhan/projects/rust/embedded/msp430-quickstart/target/msp430-none-elf/release/examples/timer-4c17cb377a7ad494.timer.6hi1yd99-cgu.0.rcgu.o" "/home/yuhan/projects/rust/embedded/msp430-quickstart/target/msp430-none-elf/release/examples/timer-4c17cb377a7ad494.timer.6hi1yd99-cgu.0.rcgu.s"
note: /home/yuhan/projects/rust/embedded/msp430-quickstart/target/msp430-none-elf/release/examples/timer-4c17cb377a7ad494.timer.6hi1yd99-cgu.0.rcgu.s: Assembler messages:
/home/yuhan/projects/rust/embedded/msp430-quickstart/target/msp430-none-elf/release/examples/timer-4c17cb377a7ad494.timer.6hi1yd99-cgu.0.rcgu.s:60: Error: redefined symbol cannot be used on reloc.
The error is due to the following LLVM code (https://github.com/access-softek/msp430-clang/blob/672cd1feb4044a11ed4974f848af3cb676aafde4/src/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp#L169) generating output incompatible with our current linker scripts.
The text was updated successfully, but these errors were encountered: