rust-in-action / code

Source code for the book Rust in Action
https://www.manning.com/books/rust-in-action?a_aid=rust&a_bid=0367c58f&chan=github
1.9k stars 445 forks source link

Ch11- Compilation Error #44

Open Flinner opened 3 years ago

Flinner commented 3 years ago

running cargo +nightly run on ch11/ch11-fledge-os-0 returns the following:

error[E0557]: feature has been removed
 --> /home/username/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/x86_64-0.13.5/src/lib.rs:5:43
  |
5 | #![cfg_attr(feature = "const_fn", feature(const_fn))] // Needed for generic access to associated consts
  |                                           ^^^^^^^^ feature has been removed
  |
  = note: split into finer-grained feature gates

For more information about this error, try `rustc --explain E0557`.

no issues opened for this in https://github.com/rust-osdev/x86_64, related https://github.com/rust-lang/rust/issues/84510

any help appriciated!

timClicks commented 3 years ago

Thanks for raising this @Flinner. It looks like this changed in Rust 1.54. I will investigate and get back to you.

ArshiAAkhavan commented 3 years ago

i have the same problem is there any updates?

bongjunj commented 3 years ago

! My system is macOS Big Sur 11.5.2.

In Cargo.toml, I updated x86_64 crate to "0.14" and it worked.

So the dependencies should be like,

[dependencies]
bootloader = "0.9"
x86_64 = "0.14"

I also tried to updated bootloader to "0.10", but there is a change that it does not use bootimage crate any more. So I just leave to be "0.9". (Seems like there be more configuration to run that in 0.10)

ArshiAAkhavan commented 3 years ago

works for me too! thanks

ocampeau commented 3 years ago

Thanks! It solved my issue too!

RobWalt commented 2 years ago

I'm still having this issue, the fix @bonjune posted doesn't work on my system (Manjaro) or isn't up to date anymore due to newer versions of rust. (I suppose)

RobWalt commented 2 years ago

Ok, so I found the final workaround. You should add this to the manuscript @timClicks

Due to the rapid evolution of rust, installing nightly breaks your example. Because of this, I suggest installing a specific nightly version. This was the only fix that worked for me at least. I installed a pretty random version, before the error of this issue here popped up.

$ rustup toolchain install nightly-2021-03-01

This corresponds to v1.52.0-nightly. You might be able to install a newer version before v1.56.0-nightly.

After that, You have to make it default, as written in the book

$ rustup default nightly-2021-03-01

And then install the components

$ rustup component add rust-src
$ rustup component add llvm-tools-preview

This should do the trick for the future for everyone.

timClicks commented 2 years ago

I did wonder if using an untagged nightly would end up biting readers. Sorry for putting through everyone through so much hassle.

I will investigate how best to recommend using the fixed nightly that works..

RobWalt commented 2 years ago

I also stumbled upon an issue considering the dependencies versions. I tested some combinations. The one with the latest versions which was still compiling and executing fine was:

bootloader = "<=0.9.18"
x86_64 = "<0.14.0"
mattfite commented 2 years ago

Hi. I've tried the suggestions to use the specific nightly, and I've also tried the suggestions to update the dependencies in Cargo.toml but I still get the original error. Additionally, I receive many errors that the macro 'asm' can't be found. I'm running on macOS Monterey 12.2.

ewenmcneill commented 1 year ago

For anyone else finding this issue, see also #88, which has a working solution, using these versions:

[dependencies]
bootloader = "0.9.22"
x86_64 = "0.14.10"

and clearing the cargo cache. (It then built for me in an Ubuntu 22.04 LTS VM, with rust nightly of 2023-01-13.)

FTR, I found that trying to use the latest bootloader / x86_64 caused a different set of build problems, presumably because there are larger changes between bootloader 0.9.x and 0.11.x (in particular it seemed to be dragging in dependencies which needed std::lib not just std::core).

FTR, to get qemu working on Ubuntu 22.04 LTS I also needed:

sudo apt-get install qemu qemu-system-x86 libgl1-mesa-dri

to be able to run the GUI qemu and see the console (at least when displayed via Forwarded X11 over SSH).

ETA: A similar fix also works for the other ch11 examples, which use a random variety of other bootloader / x86_64 crates as shipped. ch11-fledgeos-2 also needs the qemu startup parameters set in Cargo.toml.

Ewen

jumzzz commented 1 year ago

While the solutions written in this thread are correct, there's something missing in my case. In case you run with similar issue like mine, these steps might be worth taking.

It turns out my cargo registry got messed up so I was forced to do this

rm -rf ~/.cargo/registry/index/*

Also following the dependency setting at Cargo.toml which was also mentioned above

[dependencies]
bootloader = "0.9"
x86_64 = "0.14"

Additional Note If you also like to start with cargo new, make sure that you don't forget adding .cargo/config.toml with the following configuration

[build]
target = "fledge.json"

[unstable]
build-std = ["core", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"]

[target.'cfg(target_os = "none")']
runner = "bootimage runner"