Skip to content
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

Add some Rust library building infrastructure #16833

Merged
merged 9 commits into from
Jul 10, 2022

Conversation

chrysn
Copy link
Member

@chrysn chrysn commented Sep 10, 2021

Contribution description

Building on #16274 this adds a single module that can encapsulate arbitrarily many Rust-based modules.

It's heavily WIP, and will be rebased, but the core idea is something that I already want to have discussable:

  • For every RIOT build, there should be at most one Rust crate built and statically linked. That allows cargo to manage shared dependencies well, and avoid code like formatting being pulled in twice.
  • The module introduced here is intended to serve as that module if there if crates should come in but no application Rust code is used.
  • Conceptually, both the RIOT modules and the Rust crates stay separate:
    • Pure-Rust RIOT modules are pseudomodules on the RIOT side and pull in the single module.
    • The module checks the list of enabled modules, and pulls in the relevant crates.

Note that Rust-only modules have little options to be usable, as otherwise they won't be called into:

  • They can export XFA sections (like the demo does).
  • They can export implementations of otherwise weak symbols.
  • They can do what other modules do, and add extern int module_setup(void); to wherever in the init system they need to be called initially. (Personally I'd discourage that in favor of XFA.)

Testing procedure

It's not a full test, but it's a good one:

$ make BOARD=microbit-v2 -C examples/saul all flash term

TBD

It's all a bit rough so far...

but these items are still open:

  • Become less hard-coded -- right now adding a module means changing Cargo.toml, src/lib.rs and the Makefiles
  • Be available for application Rust code: Application Rust code should easily be able to take over this module's responsibilities.

Issues/PRs references

This is based on #16274, and will be rebased onto that. Only look at the commits not on that other PR, currently it's the last one only.

[edit: testing procedure]

@chrysn chrysn added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Area: build system Area: Build system Area: pkg Area: External package ports labels Sep 10, 2021
@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: examples Area: Example Applications Area: sys Area: System Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: native Platform: This PR/issue effects the native platform Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms and removed Area: pkg Area: External package ports labels Sep 10, 2021
@chrysn
Copy link
Member Author

chrysn commented Nov 15, 2021

Rebased to track #16274

@github-actions github-actions bot added Area: Kconfig Area: Kconfig integration Area: tools Area: Supplementary tools labels Nov 16, 2021
@github-actions github-actions bot added the Area: CI Area: Continuous Integration of RIOT components label Nov 18, 2021
@chrysn chrysn mentioned this pull request Dec 16, 2021
11 tasks
@github-actions github-actions bot removed Area: cpu Area: CPU/MCU ports Platform: native Platform: This PR/issue effects the native platform Area: Kconfig Area: Kconfig integration Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms Area: examples Area: Example Applications Area: tools Area: Supplementary tools Area: doc Area: Documentation Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: CI Area: Continuous Integration of RIOT components labels Dec 18, 2021
@chrysn chrysn added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 8, 2022
@chrysn
Copy link
Member Author

chrysn commented Jul 8, 2022

@kaspar030, are you happy with the adjustment?

Rerunning tests given the failed one looks like a glitch (being unrelated and not having failed in other recent runs)

Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@kaspar030
Copy link
Contributor

Please squash!

chrysn added a commit to chrysn-pull-requests/RIOT that referenced this pull request Jul 9, 2022
@chrysn
Copy link
Member Author

chrysn commented Jul 9, 2022 via email

chrysn added a commit to chrysn-pull-requests/RIOT that referenced this pull request Jul 9, 2022
@chrysn
Copy link
Member Author

chrysn commented Jul 9, 2022

Updated again to fix some commit wordings, and documentation typos or misreferences.

chrysn and others added 7 commits July 10, 2022 21:27
Co-authored-by: Marian Buschsieweke <[email protected]>
It is enabled by saul_default on microbit-v2.

Co-authored-by: Marian Buschsieweke <[email protected]>
Taken and simplified from shell test.
Of all the library crates, this is the only root crate, and responsible
for pinning good versions.
@chrysn
Copy link
Member Author

chrysn commented Jul 10, 2022

Builds and tests passed [edit: I hope the link is right -- I lost the original link, reconstructed the URL, and that was the commit that was tested]. I missed squashing after the latest fixup I mentioned in #16833 (comment) (e4279bd). Squashing that in and skipping builds/tests due to the pre- and post-squash having identical tree hashes.

@chrysn chrysn added CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs and removed CI: run tests If set, CI server will run tests on hardware for the labeled PR labels Jul 10, 2022
@chrysn chrysn enabled auto-merge July 10, 2022 19:37
@chrysn chrysn merged commit d9879c9 into RIOT-OS:master Jul 10, 2022
@chrysn chrysn deleted the rust-lib branch July 10, 2022 19:41
@kaspar030
Copy link
Contributor

Nice!

@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: build system Area: Build system Area: doc Area: Documentation Area: drivers Area: Device drivers Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: Rust Area: Rust wrapper Area: SAUL Area: Sensor/Actuator Uber Layer Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants