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

Set Up Rust - Compiling Issue with rlibc #414

Closed
fabienpesquerel opened this issue Mar 11, 2018 · 12 comments
Closed

Set Up Rust - Compiling Issue with rlibc #414

fabienpesquerel opened this issue Mar 11, 2018 · 12 comments

Comments

@fabienpesquerel
Copy link

First I would like to thank you so much for your work since it is very helpful and allows beginner (like me) to be introduce to OS programming. I am currently following a course in the topics of OS and I have to write a mini OS as an assignment. I decided to do it using Rust since we had to write a compiler for a Rust fragment last semester. Before I go to do my own little OS I try to catch as many infos as I can and that's how I discovered your awesome work. So again thanks a lot !

Here is my issue. I am currently in the Set Up Rust and everything compile just fine up to the moment rlibc decides to get involved. I get this message :
err01

To be sure that I made no obvious mistakes, I downloaded and run your final version of the set up rust part and it seems that I get the same message :
err02

So I guess that I somewhat messed up somewhere but I really can't find where. If anyone can enlighten me, I would be so happy !

P.S. : while reading the set up rust part I remark that the Makefile changes when you introduce xargo :
xargo

Above in this part, and instead of writing xargo, you create a kernel instruction in the makefile.

@stumpylog
Copy link

I'm also experiencing this issue while following along. I wonder if xargo being in maintenance mode has anything to do with it? Maybe a feature has changed that's needed?

rustc 1.26.0-nightly (2789b067d 2018-03-06)
cargo 0.26.0-nightly (1d6dfea44 2018-01-26)
xargo 0.3.11

@fabienpesquerel
Copy link
Author

fabienpesquerel commented Mar 13, 2018

I am fairly new to Rust and OS programming and I think you might be right. I don't know for you but it could be that newest version of nightly makes the bug.
See : #379
It seems here that in order to make things work, one should override the version of nightly (2018-03-06) with nightly-2017-11-29.
However, I don't think that I know how to do that...

@fabienpesquerel
Copy link
Author

I tried what is said in this issue but it only gets me :
err03

If anyone has an idea, I would be very thankful

@stumpylog
Copy link

@fabienpesquerel I'm assuming you ran rustup override set nightly-2017-11-29? You'll need to do rustup component add rust-src to get the source. But it runs into other issues, as least for me, where it appears the override didn't correctly take or download something?

Compiling core v0.0.0 (file:///home/user/.rustup/toolchains/nightly-2017-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
Finished release [optimized] target(s) in 16.91 secs
error: intermittent IO error while iterating directory `/home/user/.rustup/toolchains/nightly-2017-11-29-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin`
caused by: IO error for operation on /home/user/.rustup/toolchains/nightly-2017-11-29-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin: No such file or directory (os error 2)
caused by: No such file or directory (os error 2)
note: run with `RUST_BACKTRACE=1` for a backtrace
make: *** [Makefile:37: kernel] Error 1

The location it's looking for definitly doesn't exist for me. Not sure if it's another component missing?

@phil-opp
Copy link
Owner

@fabienpesquerel is correct: It is a bug in rustc: rust-lang/cargo#4905. To work around you can either by using an older nightly (see @stumpylog's comment) or set the RUST_TARGET_PATH environment variable to the current working directory when invoking xargo:

> RUST_TARGET_PATH=$(pwd) xargo build --target […]

You can also update your Makefile:

 cargo:
-	@xargo build --target $(target)
+	@RUST_TARGET_PATH="$(pwd)" xargo build --target $(target)

@phil-opp
Copy link
Owner

But it runs into other issues, as least for me, where it appears the override didn't correctly take or download something?

The newest version of xargo only works on recent nightlies. The error you're seeing comes from japaric/xargo#200, where the new bin directory (added in newer compilers) is copied to the target sysroot. So either use a recent nightly with the RUST_TARGET_PATH workaround or downgrade xargo to version 0.3.10.

@phil-opp
Copy link
Owner

@fabienpesquerel

First I would like to thank you so much for your work since it is very helpful and allows beginner (like me) to be introduce to OS programming. I am currently following a course in the topics of OS and I have to write a mini OS as an assignment. I decided to do it using Rust since we had to write a compiler for a Rust fragment last semester. Before I go to do my own little OS I try to catch as many infos as I can and that's how I discovered your awesome work. So again thanks a lot !

Awesome! Really cool that you decided to use Rust! Feel free to ask questions here or in our gitter channel.

@phil-opp
Copy link
Owner

I added the RUST_TARGET_PATH workaround to the post: #416

@fabienpesquerel
Copy link
Author

Ok, thanks you very much, everything seems to work again ! (except that I have to do the RUST_TARGET_PATH=$PATH xargo build --target=x86_64... via command line and that it won't work in the Makefile, even if I do an export RUST_TARGET_PATH=$PATH beforehand)

@phil-opp
Copy link
Owner

It should be $(pwd), not $PATH.

@fabienpesquerel
Copy link
Author

Yes, sorry for the typo. I don't know why, but $(pwd) didn't work. However double-dollar $$PWD makes it just fine in the Makefile.

@phil-opp
Copy link
Owner

phil-opp commented Mar 14, 2018

I don't know about $$PWD, but $(shell pwd) and $(CURDIR) should also work. I updated the Makefile in the post to $(shell pwd) too: 8d31229.

Seems like we can close this issue then. Thanks a lot for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants