-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
The thumb* target family (which have newlib libc) are not supported #375
Comments
While it is possible to make a "bare metal" program with nothing but Rust and a linker, the |
This is pretty standard for most new platforms, I think. I don't think liblibc will ever compile for an arbitrary new platform because it has to know what the actual definitions are. The theory is that the backing libc implementation will almost always have bindings, however. (although right now we don't have newlib bindings in tree) |
Any chance of newlib support being added at some point? |
The newlib API surface is going to be quite small compared to other libc implementations, but I'm guessing the answer would be yes so long as people are willing to contribute and it can be tested by CI. I have used newlib on embedded systems before and can see cases where having libc provide access would be useful. For pure-rust embedded systems, you might want to check out rlibc which provides bare bones required functions: https://github.com/alexcrichton/rlibc |
Trying to clean-up issues: is this still an issue @SimonSapin ? (Thanks for your work on Servo!) |
Yes. The Compiling libc v0.2.37
error[E0412]: cannot find type `c_char` in this scope
--> /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.37/src/lib.rs:171:43
|
171 | pub fn fopen(filename: *const c_char,
| ^^^^^^ did you mean `c_schar`?
error[E0412]: cannot find type `c_char` in this scope
--> /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.37/src/lib.rs:172:39
|
172 | mode: *const c_char) -> *mut FILE;
| ^^^^^^ did you mean `c_schar`? […] error[E0412]: cannot find type `c_long` in this scope
--> /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.37/src/lib.rs:278:39
|
278 | pub fn labs(i: c_long) -> c_long;
| ^^^^^^ not found in this scope
error: aborting due to 76 previous errors
If you want more information on this error, try using "rustc --explain E0412"
error: Could not compile `libc`. |
There are some newlib bindings in-tree for ARM targets now, which should get selected if you compile with the |
A first step would be defining |
Is there someone tackling this issue ? This is a blocking issue for an embedded project. If it is just defining type aliases I can take care of it 😄 |
Since this issue was opened, some |
Yes I will try to tackle this issue within the end of this week ! |
@FenrirWolf In this repository, @gbip Steps to reproduce, in this repository: rustup target add thumbv7em-none-eabi
cargo build --target thumbv7em-none-eabi --no-default-features You should see a bunch of errors like: error[E0412]: cannot find type `c_char` in this scope
--> /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.43/src/lib.rs:172:43
|
172 | pub fn fopen(filename: *const c_char,
| ^^^^^^ did you mean `c_schar`? They are all caused by Lines 298 to 320 in 41944d5
https://doc.rust-lang.org/reference/attributes.html#conditional-compilation documents what’s available to |
I’ve filed rust-embedded/wg#238 to ask for guidance from the Embedded WG. |
Yeah, it probably would make sense to move the |
It seems like that all the newlib stuff isn't really related to bare metals programs. |
newlib exists in a funny spot. its default configuration is aimed towards bare-metal systems without OS features, but it's also designed to have its functionality extended by end-users to support things like stdio and file io for systems where those make sense. the main place I've encountered newlib is in toolchains for game console homebrew, and those target everything from the Game Boy Advance (basically bare metal) to the Nintendo Switch (not bare metal at all). |
I think if we go with Would you be ok if I create an arm module containing the none module with type aliases for bare metals arm plateforms. If someone would like to add features for game consoles (or any arm based plateform) they would just have to create a new module next to the none one and they could start working. |
I'm completely fine with that. I'd only added the existing bindings under |
Maybe it is better suited to leave them there and to create a |
That might work. To clarify, my own case is running homebrew on the Nintendo 3DS, and while the system itself isn't actually a unix-alike, the newlib-based toolchain that I use in tandem with Rust code has extensions for things like file systems, stdout, network IO, and some other functionality that makes it so you can interact with the system with a very unix-like interface. And @ischeinkman has been doing the same thing with a similar toolchain for the Nintendo Switch. So making a new set of bindings for |
Would it make sense to gate For example the |
I think this is a very good way to do it. |
suit the advices provided in rust-lang#375.
This might be a dumb question, but couldn't we just add a That might be something that's easier to support from libc in the sense that we wouldn't be making up stuff for |
My question was whether it is a dumb idea to just add a bare-metal target that has |
Usually the libc variant corresponds to |
Ah yeah what @gnzlbg mentioned is what we've done historically, although we don't need to necessarily add a target to rustc. We can add support in the libc crate for |
@gbip what's your use case? If you only need type aliases for the C types (e.g. for bindgen) you can use the
Supporting arm+newlib for custom targets like the GBA and the DS makes total sense but sounds like a separate issue. |
Thanks a lot, I was not aware that this crate existed ! |
Where does this happen? The If anything, |
So I'm going to close this issue for two reasons:
|
I have embedded hardware without an OS. I build Rust code for it with
--target thumbv7em-none-eabi
and thisthumbv7em-none-eabi.json
file:If I add a Cargo dependency on the
libc
crate and build with this target, I get many build errors. The first and last are below. The entire thing is at https://gist.github.com/anonymous/780fe74b2ae2834fc9c738dbff60acc0The text was updated successfully, but these errors were encountered: