-
Notifications
You must be signed in to change notification settings - Fork 703
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
Upgrade Rust nightly #370
Upgrade Rust nightly #370
Conversation
Update: rust-lang/cc-rs#158 |
/cc maybe @japaric can save us! |
Thanks to @japaric, btw, for explaining how to get this working! I haven't tested extensively yet, but otherwise I think this is ready. |
My suggestion: diff --git a/boards/Makefile.common b/boards/Makefile.common
index 356eba87..6c77c151 100644
--- a/boards/Makefile.common
+++ b/boards/Makefile.common
@@ -41,6 +41,14 @@ ifneq ($(shell RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VE
endif
endif
+# Check that xargo is installed
+CHECK := $(strip $(firstword $(shell $(XARGO) --version 2>&1)))
+ifneq ($(CHECK), xargo)
+ $(warning You do not seem to have xargo installed.)
+ $(warning Installing xargo now.)
+ DUMMY := $(shell cd /tmp && cargo install xargo; cd -)
+endif
+
# Dump configuration for verbose builds
ifneq ($(V),)
$(info ) |
This has been rebased and squashed ; I think it should be good to go |
* Use Xargo to get automatically built core * Remove dependency on rust-core * Remove cutom targets; add RUSTFLAGS where needed * Update use of Unique and NonZero * Add "mem" feature to "compiler_builtins" crate * auto-install xargo if needed
@alevy did you have this working on the NRF? It compiles, but it seems to hard fault with some immediacy. First trick, in the current code, all the ISRs are weakly aliased to the diff --git a/chips/nrf51/src/crt1.c b/chips/nrf51/src/crt1.c
index bf6d773c..dbe9ad9e 100644
--- a/chips/nrf51/src/crt1.c
+++ b/chips/nrf51/src/crt1.c
@@ -20,19 +20,40 @@ extern uint32_t _ezero;
extern uint32_t _srelocate;
extern uint32_t _erelocate;
+void reset_handler(void);
+
void Dummy_Handler(void)
{
while (1) {
}
}
-void reset_handler(void);
-void NMI_Handler(void) __attribute__ ((weak, alias("Dummy_Handler")));
-void HardFault_Handler(void)
- __attribute__ ((weak, alias("Dummy_Handler")));
-void SVC_Handler(void) __attribute__ ((weak, alias("Dummy_Handler")));
-void PendSV_Handler(void) __attribute__ ((weak, alias("Dummy_Handler")));
-void SysTick_Handler(void) __attribute__ ((weak, alias("Dummy_Handler")));
+void NMI_Handler(void) __attribute__ ((weak));
+void NMI_Handler(void) {
+ while (1) {
+ }
+}
+
+void HardFault_Handler(void) __attribute__ ((weak));
+void HardFault_Handler(void) {
+ while (1) {
+ }
+}
+void SVC_Handler(void) __attribute__ ((weak));
+void SVC_Handler(void) {
+ while (1) {
+ }
+}
+void PendSV_Handler(void) __attribute__ ((weak));
+void PendSV_Handler(void) {
+ while (1) {
+ }
+}
+void SysTick_Handler(void) __attribute__ ((weak));
+void SysTick_Handler(void) {
+ while (1) {
+ }
+}
PERIPHERAL_INTERRUPT_HANDLERS With no apps loaded, this'll eventually end up looping at
Keeping on keeping on,
From this we learn that we're nominally at the top-level (
In practice, that's a garbage PC (that address is data used by that function, not an instruction, so ignore that "decoding"). So most likely it was a garbage return to the top-level I'm going to drop this for tonight, but wanted to give you some place to start if you dig into what broke for the nrf tomorrow. |
Okay.. so this has been a truly miserable experience:
Once upon a time I swear I found a page that documented the "target specs" file (i.e. sam4l.json), but that page is lost to the annals of somewhere and is un-google-able. Rust has updated how they handle target specs which required a fair bit of stumbling in the dark :/
The key issue seems to be this one rust-lang/rust#35021 which in a particularly sick joke changed the
no-compiler-rt
flag from doing what we want to being a silent no-op. The effect is that now we need to pass-nostartflags
to the linker.Rust's added support for multiple "linker flavors", so you have to choose one. That's fine, but now in order to pass any arguments to the linker, you have to include the flavor specifier again. This would almost make sense if you could have multiple flavors, but you can't, there can only be one running linker flavor, so what's the point of scoping to arguments? And back on the real theme here, why does Cargo silently accept and ignore arguments that it's not going to do anything with :( ? Anyways, this is what you want:
Great, now we've gotten rid of undefined references from
_start
and friends, now we get to the other problem created from that issue linked above. Rust has decided to port all of the compiler intrinsics (all the code that the compiler can emit while it's working, stuff like__aeabi_memclr4
and friends), as they're not yet done, we have undefined references again.But! There's hope, they have a fallback system that will simply plug in the old C versions of each of the intrinsics whenever a rust one is missing. Unfortunately this doesn't work because we're building for a "sam4l" target, and the C compiler doesn't have a clue how to emit intrinsics for a "sam4l":
It doesn't/can't choose the right compiler or flags because it doesn't have a clue what a sam4l is. While there's probably a way to tell it that "sam4l" target should use "thumbv7em-linux-eabi" intrinsics, I'm officially tired and really frustrated. We'll pick this up again tomorrow.