-
Notifications
You must be signed in to change notification settings - Fork 39
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
std-related patches review #57
Comments
@igrr, FYI: I have been reflecting a bit on the current set of STD patches and looking into the libc Rust crate, and I have come up with updated patches, where the changeset is distributed a bit differently across (a) Rust libStd, (b) the libc crate and (c) the ESP-IDF C code itself. Original plan:
New plan (and patch set):Idea is:
New patchset: Biggest remaining risks: |
Just a random guy how saw the blog post Rust on Espressif chips on reddit. I just wanted to say the Target Tier Policy of Rust state:
It has been stated before by Rust projects guys (I don't remember where) that the unsupported shims (always returning an error if unsupported) has been a really bad idea and that new targets will probably don't want to do that and simply don't provide the functions. I would suggest to simply don't provide the methods |
Thanks for the feedback! Unfortunately not providing the above-mentioned functionality is not that simple as that would mean polluting libStd code outside of Ditto for Also, this guy (used by the wasi and wasm) seems to keep growing and growing, and I think the Providing "not implemented" stubs also has the benefit that you have higher chances then in compiling off-the-shelf Rust crates (me running Rocket on the ESP-IDF in the past comes to mind as an example of a crate that does not compile if I do not stub out at least some of this stuff). And then you at least have some chances to be able to force the crate to not hit the not-implemented code-paths by configuration etc. But - you know, submission of the patches is kind of imminent now, so if Rust maintainers object, removing functionality would be the way forward, whether I like it or not. :) |
PRs submitted upstream: |
I agree that appreciable, but that's defeat the "if that's compile that's works" that so many people in the Rust community really appreciate. These kind of "not implemented" stubs are the opposite of that.
No problem that was just a suggestion from a random guy.
👍 |
@Urgau Your comments & suggestions are really appreciated - please keep sending those.
|
CI just complained about those targets missing from |
❤️ By talking about suggestion I have one more. You stated:
I think that you need to agree to both of them because the Rust project is dual licensed against MIT and Apache-2.0, this dual licensing impose contributors to agree on both licenses when doing a pull request but non-contributor (ie user) can choose which license they want: MIT or Apache-2.0. |
@Urgau Fixed :) |
Yes. |
(Migrated from espressif/rust repo)
@igrr Patches in https://github.com/ivmarkov/rust/commits/stable provide an std-capable environment on top of ESP-IDF.
Some of these patches work around the fact that ESP-IDF is not completely POSIX-compatible.
Here is a list of things that can be fixed in ESP-IDF to reduce the number of changes we need to make in rust:
Easy changes
memalign
function implementedIt can be done pretty easily, adding a C file with the following pattern:
sysconf
and_SC_PAGESIZE
. Can be a very simple implementation, returning constant value.kill
,signal
,exec
,wait
,spawn
, etc) — no meaningful implementation possible, but each can return -1 and set errno to ENOSYS.nanosleep
— can be a wrapper aroundusleep
More complex changes
vfs
component, not sure how complex this would be, and the semantics required by libstd.PTHREAD_COND_INITIALIZER
definition in IDF is non-standard:No changes
These changes in the current patch set do not seem to be necessary, need to find why they were needed.
getrandom
— it should be already supported by ESP-IDF.igrr:
@ivmarkov here is the summary after looking at the std-related patches. Most things can be solved in IDF pretty easily.
There are probably other things in the patchset that i haven't noticed yet, please feel free to add more items.
ivmarkov:
Hi @igrr,
Thanks for all the feedback so far.
Before commenting on details, let me state something generic, which is very important:
Using an API (function) implemented in ESP-IDF from Rust STD is really a two-step process:
The reason why we need (2) is because currently the whole Rust STD support is based around consuming "extern C" API definitions available in the libc crate from above, which are manually defined and maintained for the various libC libraries (msvcrt, glibc, newlib, musl etc.).
Currently, Rust STD does not know about our esp-idf-sys crate and therefore about all the Bindgen bindings generated by it. Letting STD know about esp-idf-sys might increase the STD patch size and its complexity, and decrease the chances of it being accepted so far.
Therefore, I think we should stick to consuming the libc crate instead of our own autogenerated bindings in the context of Rust STD (files, threads and networking/sockets).
That would imply that we might need to file patches against libc (the newlib sub-module specifically), so that it properly reflects the status quo on ESP-IDF.
That work has already started. For example, @reitermarkus, who started the STD-on-ESP32 effort originally was able to push these changes to the libc crate, which were key for having the initial ESP32 STD support for Rust.
I think we should just continue this for riscv, as well as for all "deviations" ESP-IDF has from the standard newlib - particularly in the pthread area.
Of course not everything needs to be in the libc crate so as to be usable from Rust STD. You can always put an "inline" "extern C" definition, as I did e.g. here. It is just that these should be a minority, I feel.
One more thing: I'm not implying that there will be a huge amount of changes to the libc crate. Just that there will be some, and whenever e.g. there is an API in ESP-IDF (like
posix_memalign
) that does not necessarily means that it is exposed in libc/newlib.As for the types of changes, see the riscv support here. Currently, a bit of a hack as it delegates to the "xtensa" support, even though I don't expect these to be different.
igrr:
igrr:
@ivmarkov Thanks for the explanation, I didn't know about newlib-specific things present in libc create, it makes a lot more sense now. I would appreciate if you could start the discussion with libstd maintainers regarding this existing patch set.
The text was updated successfully, but these errors were encountered: