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 initial libstd support for Xous #104101

Merged
merged 17 commits into from
Sep 19, 2023

Conversation

xobs
Copy link
Contributor

@xobs xobs commented Nov 7, 2022

This patchset adds some minimal support to the tier-3 target riscv32imac-unknown-xous-elf. The following features are supported:

  • alloc
  • thread creation and joining
  • thread sleeping
  • thread_local
  • panic_abort
  • mutex
  • condvar
  • stdout

Additionally, internal support for the various Xous primitives surrounding IPC have been added as part of the Xous FFI. These may be exposed as part of std::os::xous::ffi in the future, however for now they are not public.

This represents the minimum viable product. A future patchset will add support for networking and filesystem support.

@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2022

r? @m-ou-se

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 7, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@xobs
Copy link
Contributor Author

xobs commented Nov 7, 2022

Please let me know if there is anything I should do in order to make this merge easier, please let me know. This is my first relatively major change to libstd.

Note that this will not build unless you have the latest llvm-project which includes llvm/llvm-project@7c80e7a but it does not require any external dependencies beyond a C compiler capable of building RISC-V code.

@rustbot
Copy link
Collaborator

rustbot commented Nov 8, 2022

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

These commits modify compiler targets.
(See the Target Tier Policy.)

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @Folyd, @jsha

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

A change occurred in the Ayu theme.

cc @Cldfire

Some changes occurred in HTML/CSS themes.

cc @GuillaumeGomez

@xobs xobs force-pushed the xous-libstd-initial branch 2 times, most recently from f4db122 to 2664881 Compare November 9, 2022 02:26
@rustbot rustbot added the A-meta Area: Issues & PRs about the rust-lang/rust repository itself label Nov 9, 2022
@bors
Copy link
Contributor

bors commented Nov 9, 2022

☔ The latest upstream changes (presumably #103723) made this pull request unmergeable. Please resolve the merge conflicts.

@xobs
Copy link
Contributor Author

xobs commented Nov 13, 2022

I rebased to the latest master branch and incorporated the suggestions that were recommended.

@albertlarsan68
Copy link
Member

This does not affect the bootstrap code, do @rustbot label -A-bootstrap.

@rustbot rustbot removed the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jan 18, 2023
@xobs xobs marked this pull request as draft February 17, 2023 07:21
@xobs
Copy link
Contributor Author

xobs commented Feb 17, 2023

I'm in the process of reworking this so that it passes tests. I've gotten libunwind functioning, and now I can actually run the Rust libstd test suite.

I've discovered some issues in the TLS implementation, as well as potential issues in the Condvar or Mutex implementation. I will work on those issues and remove the Draft status once they are addressed.

@bors
Copy link
Contributor

bors commented Feb 25, 2023

☔ The latest upstream changes (presumably #107405) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC Dylan-DPC added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 17, 2023
@Dylan-DPC
Copy link
Member

@xobs any updates on this?

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jul 31, 2023
@xobs xobs marked this pull request as ready for review July 31, 2023 12:22
xobs added 13 commits August 22, 2023 20:25
The xous filesystem support is not yet ready for merging.

Signed-off-by: Sean Cross <sean@xobs.io>
Xous does not yet support spawning processes.

Signed-off-by: Sean Cross <sean@xobs.io>
Don't add the origin rpath when calling the linker. This is unnecessary
on Xous since there is no dynamic linker, and Xous can use an ordinary
bare-metal linker with no rpath options.

As part of this patch, the logic was inverted so that the "else" clause
contains everything except "windows" and "xous".

Signed-off-by: Sean Cross <sean@xobs.io>
Basic alloc support on Xous is supported by the `dlmalloc` crate. This
necessitates bumping the dlmalloc version to 0.2.4.

Signed-off-by: Sean Cross <sean@xobs.io>
Xous does not properly handle invalid instructions. Instead, call
`__rust_abort` and exit normally.

Signed-off-by: Sean Cross <sean@xobs.io>
Xous has a concept of `services` that provide various features.
Processes may connect to these services by name or by address. Most
services require a name server in order to connect.

Add a file with the most common services, and provide a way to connect
to a service by querying the name server.

Signed-off-by: Sean Cross <sean@xobs.io>
Add support for stdout. This enables basic console printing via
`println!()`. Output is written to the log server.

Signed-off-by: Sean Cross <sean@xobs.io>
Add support for determining the current time. This connects to the
ticktimer server in order to get the system uptime.

Signed-off-by: Sean Cross <sean@xobs.io>
Add initial support for threads on Xous. This includes thread creation
and joining.

Signed-off-by: Sean Cross <sean@xobs.io>
Add an implementation of thread local storage. This uses a container
that is pointed to by the otherwise-unsed `$tp` register. This container
is allocated on-demand, so threads that use no TLS will not allocate
this extra memory.

Signed-off-by: Sean Cross <sean@xobs.io>
Add support for Condvar, Mutex, and RWLock. These are all backed by the
ticktimer server.

Signed-off-by: Sean Cross <sean@xobs.io>
The Xous operating system has no libc, and relies on `compiler_builtins`
to supply basic functions such as `memcpy`. Bump the version to 0.1.101
to pull in a version of this crate with the flag enabled for Xous.

Signed-off-by: Sean Cross <sean@xobs.io>
Xous passes slice pointers around in order to manipulate memory.
This is feature-gated behind `slice_ptr_len`. Xous is currently
the only target to use this feature, so gate it behind an OS flag.

Signed-off-by: Sean Cross <sean@xobs.io>
@bjorn3

This comment was marked as resolved.

Copy link
Member

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

LGTM, but @m-ou-se may want to take a look at it too. If not r=me.

@xobs
Copy link
Contributor Author

xobs commented Sep 19, 2023

What are the next steps to getting this merged?

@bjorn3
Copy link
Member

bjorn3 commented Sep 19, 2023

Given that @m-ou-se hasn't taken a look yet:

@bors r+

@bors
Copy link
Contributor

bors commented Sep 19, 2023

📌 Commit 6c32a64 has been approved by bjorn3

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2023
@bors
Copy link
Contributor

bors commented Sep 19, 2023

⌛ Testing commit 6c32a64 with merge ae9c330...

@bors
Copy link
Contributor

bors commented Sep 19, 2023

☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing ae9c330 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 19, 2023
@bors bors merged commit ae9c330 into rust-lang:master Sep 19, 2023
12 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 19, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ae9c330): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.9% [1.9%, 1.9%] 1
Improvements ✅
(primary)
-2.6% [-4.1%, -1.0%] 2
Improvements ✅
(secondary)
-4.4% [-4.4%, -4.4%] 1
All ❌✅ (primary) -2.6% [-4.1%, -1.0%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 631.926s -> 631.537s (-0.06%)
Artifact size: 317.94 MiB -> 317.91 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.