-
Notifications
You must be signed in to change notification settings - Fork 2k
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
initial Rust support #5740
initial Rust support #5740
Conversation
f2e2eea
to
2025005
Compare
@@ -262,7 +262,7 @@ ifeq (,$(RIOTNOLINK)) | |||
ifeq ($(BUILDOSXNATIVE),1) | |||
$(AD)$(if $(CPPMIX),$(CXX),$(LINK)) $(UNDEF) -o $(ELFFILE) $$(find $(BASELIBS) -size +8c) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie | |||
else | |||
$(AD)$(if $(CPPMIX),$(CXX),$(LINK)) $(UNDEF) -o $(ELFFILE) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGPREFIX)-Map=$(BINDIR)$(APPLICATION).map $(LINKFLAGPREFIX)--cref $(LINKFLAGS) | |||
$(AD)$(if $(CPPMIX),$(CXX),$(LINK)) $(UNDEF) -o $(ELFFILE) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(wildcard $(BINDIR)/_extra_libs/*.a) $(LINKFLAGPREFIX)--end-group $(LINKFLAGPREFIX)-Map=$(BINDIR)$(APPLICATION).map $(LINKFLAGPREFIX)--cref $(LINKFLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(wildcard)
is evaluated as the rule is read, not when the rule is executed. You need to use $$(find ...)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, but it worked. :)
I think a plain wildcard will work fine, as the shell can evaluate it.
How does rustc work? Does it compile to C / C++ as an intermediate target or does it compile directly to an object / assembly? |
Rustc uses llvm as code generator. The the cross-compiling version of rust's build system Cargo, xargo, instructs rustc to emit object files and .a archives, then usually calls gcc as linker. |
@@ -0,0 +1,21 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iff (sic, please argue for it) bash is really needed, at least invoke it like #!/usr/bin/env bash
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least you can be nice to non-linux people and change to #!/usr/bin/env bash
as requested ;-)
bb0eedf
to
cb33876
Compare
Anyone interested in reviewing this? |
Maybe someone™ is willing to review this at the next Hack'n'ACK ;-) |
Feature freeze -> postponed. |
@kaspar030 Is there any particular reason why you wrote that „ugly” linker stub instead of using |
Yes, cargo tries to call the linker, but doesn't know anything about RIOT's linking process, thus wouldn't link a correct binary. The linker stub just fetches all objects and archives cargo wants to link (all rust code), and puts them in place so the RIOT linking process can pick them up.
Maybe. Then again there'd be a target specific path to be set somewhere (AFAIR there's a search path for the target specs), compared to one that is identical for all platforms. |
- fixed _extra_libs inclusion - made rust_support a feature - allow additional xargo args
cb33876
to
7570d1f
Compare
|
I started working on rust support for riot as well. My version is very different of yours though, I decided to closely integrated rust into the existing build process instead of using xargo or cargo. I simply adjusted the existing Makefiles and decided to compile the rust code with make thus my version doesn't introduce a separate build system and doesn't need any linker hacks. Furthermore since I don't use xargo it is also possible to build code for the native family. Would you be interested in seeing my changes? |
The idea is to integrate rust into the existing build system as well as possible and to not use a separate buildsystem like cargo or xargo. Makefile.base has been modified to include support for main.rs and lib.rs files and a Makefile.rust has been added which sets a few rust related variables. This is very loosly based on RIOT-OS#5740
The idea is to integrate rust into the existing build system as well as possible and to not use a separate buildsystem like cargo or xargo. Makefile.base has been modified to include support for main.rs and lib.rs files and a Makefile.rust has been added which sets a few rust related variables. This is very loosly based on RIOT-OS#5740
The idea is to integrate rust into the existing build system as well as possible and to not use a separate buildsystem like cargo or xargo. Makefile.base has been modified to include support for main.rs and lib.rs files and a Makefile.rust has been added which sets a few rust related variables. This is very loosly based on RIOT-OS#5740
The idea is to integrate rust into the existing build system as well as possible and to not use a separate buildsystem like cargo or xargo. Makefile.base has been modified to include support for main.rs and lib.rs files and a Makefile.rust has been added which sets a few rust related variables. This is very loosly based on RIOT-OS#5740
Sorry if this does not belong here, but I have problems compiling the rust example. Upon running the make command I get the following error:
I have followed the setup instructions as specified in
Apparently, the ..../rustlb/src directory is missing:
OS: Ubuntu 16.04, a SAM-21r-xpro is connected and can be flashed with other examples. (Note: Yes, I am aware of #6162, however I wanted to give this a try first.) Thanks for any help! |
Any hopes to get this in for feature freeze? |
Any hopes to get this in for feature freeze?
As we're having a RUST related meeting on Feb 3rd, I think we should
postpone.
|
Done |
Hey @kaspar030 @miri64, I'm also interested in Rust, RIOT, and Rust+Embedded, (and I live in Berlin). Is there any way I could get more info about the Feb 3rd meeting you mentioned? Feel free to write here, or email/twitter me (my info is on my profile) |
Any new info about it? |
https://github.com/posborne/zinc |
ping @kaspar030, this one is nice and it would be great to have it in the next release. |
ping @kaspar030, any news here? This one was postponed several times, I think we should remove the milestone for now, and re-add as soon there is a realistic ETA. |
No new development for over a year. Let's close this for now. |
"Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety."
Sounds like exactly what we need. ;)
This PR integrates Rust's build system (Cargo) into RIOT and makes it possible to write RIOT applications in Rust.
Here's an accompanying Rust library which provides (currently more than incomplete) RIOT API bindings to Rust.
This works currently only on Sam R21, but adding other Cortex-M platforms should be easy.Currently this works only on Cortex-M platforms (no native!). Tested on samr21-xpro and nucleo-f334.