-
Notifications
You must be signed in to change notification settings - Fork 13.3k
program without libc (without std lib) leads to cryptic error #17346
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
Comments
I also encountered this error in Rust 0.13 nightly, and it prevents me from continuing. |
The It's not likely that Rust will support running in a hosted environment without the platform's usual entry point. It does support freestanding usage, but in that environment the programmer is responsible for providing the entry code. |
So, if I understand correctly, |
Those functions are provided by the C runtime and it's not trivial to replicate all of the functionality yourself. You need to handle differences between Linux kernel versions and set up stuff like the vdso yourself. It would be a much better idea to use a C standard library implementation like musl... I can't see an advantage to reinventing this wheel. |
Anyway, you really don't want to be calling the raw system calls yourself. For example, the |
If you want to write an OS Kernel or something like that compile your crate as a staticlib and link it manually with some entry code (that provides a stack and sets the stack limit in fs:XY). Not sure if there's a better way to do this but at least it works :) |
Thanks, I indeed intended to try my hand at writing an operating system kernel, which is why I was looking at freestanding Rust. I'll look into |
This doesn't seem to be an actual bug, then. |
@steveklabnik maybe the real bug is how cryptic the error is? |
@LilRed this issue was opened a very long time ago, does the same thing happen today? I've been doing osdev and I haven't run into it. |
Just a quick brain dump since I'm on mobile right now: I think I ran into this error back then when I tried to build a I think the main problem is that an The error message is so cryptic because it is an error from the linker. I'm not sure if it can be improved easily. |
Yes, this is my fear as well. Hrm. |
Re-opening just in case, and re-tagging diagnostics. |
This still happens today:
|
This is still a problem. @phil-opp suggested this was due to Rust not clearly defining what an executable is in a freestanding environment. This also seems to happen when invoking New working playpen: https://play.rust-lang.org/?gist=3291629081e07458e1dae21bf12660f7&version=nightly&mode=debug |
It seems like the C runtime is always linked when compiling for the host OS, even without a |
I did manage to get a Rust program to link with
|
Just figured out, you can avoid this warning by putting
into |
Changed package.json so vscode extension settings have submenus There are a lot of options that are a part of rust-analyzer, sometimes it can be hard to find an option that you are looking for. To fix this I have put all configurations into categories based on their names. I have also changed the schema in `crates/rust-analyzer/src/config.rs` to reflect this. Currently for each generated entry the title is redeclared, this does function but I am prepared to change this if it is a problem.
The code at http://doc.rust-lang.org/guide-unsafe.html#avoiding-the-standard-library requires libc. It isn't possible to remove this line or to replace it with the platform independent rlibc. The following error occurs (playpen: http://is.gd/GWl8YT):
I want to use libcore, that doesn't require libc (http://doc.rust-lang.org/core/). The libcore code example in the guide (http://doc.rust-lang.org/guide-unsafe.html#using-libcore) has no libc dependency, but the playpen link in the top right of the code example reinserts it and removing it leads to the same error as above (http://is.gd/sxVAr0).
The text was updated successfully, but these errors were encountered: