xiyurain/UltraOS

编译失败-proc_macro2依赖项出错

jklincn opened this issue · 15 comments

猜测还是版本问题?查了一下 proc_macro::Literal::from_str
#[stable(feature = "proc_macro_literal_parse", since = "1.54.0")]

终端输出:

error[E0599]: no function or associated item named from_str found for struct proc_macro::Literal in the current scope
--> /home/lin/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-1.0.36/src/wrapper.rs:943:30
|
943 | proc_macro::Literal::from_str(repr).map_err(LexError::Compiler)
| ^^^^^^^^ function or associated item not found in proc_macro::Literal

error: aborting due to previous error

For more information about this error, try rustc --explain E0599.
error: could not compile proc-macro2

This looks like it is caused by version compatibility issue, as you expected. And I will follow your advice to lock the version and push to the repo.

First, could you please input the command make runos in the root directory and show me your output?

First, could you please input the command make runos in the root directory and show me your output?

error[E0599]: no function or associated item named `from_str` found for struct `proc_macro::Literal` in the current scope
   --> /home/lin/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-1.0.36/src/wrapper.rs:943:30
    |
943 |         proc_macro::Literal::from_str(repr).map_err(LexError::Compiler)
    |                              ^^^^^^^^ function or associated item not found in `proc_macro::Literal`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `proc-macro2`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-binutils v0.2.0`, intermediate artifacts can be found at `/tmp/cargo-installsXw4ZA`

Caused by:
  build failed
Makefile:55: recipe for target 'env' failed
make[1]: *** [env] Error 101
make[1]: Leaving directory '/home/lin/code/origin/UltraOS/codes/os'
Makefile:12: recipe for target 'runos' failed
make: *** [runos] Error 2

It says in codes/os, the Makefile:55 caused an error. What command is it? Is it rustup override set nightly-2021-05-10 or cargo install cargo-binutils --version 0.2.0.

It says in codes/os, the Makefile:55 caused an error. What command is it? Is it rustup override set nightly-2021-05-10 or cargo install cargo-binutils --version 0.2.0.

line 55 : rustup override set nightly-2021-05-10

Pull the newest commit, and then run make env in the root directory of this project.

Note: The Readme.md is changed for environment config.

Pull the newest commit, and then run make env in the root directory of this project.

Note: The Readme.md is changed for environment config.

The error output just changes failed to compile cargo-binutils v0.2.0 to failed to compile cargo-binutils v0.3.5

error[E0599]: no function or associated item named `from_str` found for struct `proc_macro::Literal` in the current scope
   --> /home/lin/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-1.0.36/src/wrapper.rs:943:30
    |
943 |         proc_macro::Literal::from_str(repr).map_err(LexError::Compiler)
    |                              ^^^^^^^^ function or associated item not found in `proc_macro::Literal`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `proc-macro2`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-binutils v0.3.5`, intermediate artifacts can be found at `/tmp/cargo-installpvCe5l`

Caused by:
  build failed
Makefile:55: recipe for target 'env' failed
make[1]: *** [env] Error 101
make[1]: Leaving directory '/home/lin/code/origin/UltraOS/codes/os'
Makefile:7: recipe for target 'env' failed
make: *** [env] Error 2

It seems like you didn't push your Cargo.lock to repository. I can't find it in /codes/os directory.

It's the problem from rust toolchain config. I've successfully repeated the problem. It may take some time to fix it.

Pull and run again. The rust compiler management from rustup has confused me a lot.

Pull and run again. The rust compiler management from rustup has confused me a lot.

Kernal can be built successfully. But rust-objcopy seems to go wrong.

    Finished release [optimized] target(s) in 0.37s
Failed to execute tool: objcopy
No such file or directory (os error 2)
Makefile:71: recipe for target 'target/riscv64imac-unknown-none-elf/release/UltraOS.bin' failed
make[1]: *** [target/riscv64imac-unknown-none-elf/release/UltraOS.bin] Error 101
make[1]: Leaving directory '/home/lin/code/origin/UltraOS/codes/os'
Makefile:13: recipe for target 'run' failed
make: *** [run] Error 2

I try to do this manually, but it occurs the same.

$rust-objcopy --binary-architecture=riscv64 target/riscv64imac-unknown-none-elf/release/UltraOS --strip-all -O binary target/riscv64imac-unknown-none-elf/release/UltraOS.bin
Failed to execute tool: objcopy
No such file or directory (os error 2)

But using riscv64-unknown-elf-objcopy can resolve the problem like:

riscv64-unknown-elf-objcopy  target/riscv64imac-unknown-none-elf/release/UltraOS --strip-all -O binary target/riscv64imac-unknown-none-elf/release/UltraOS.bin

Now, I can run UltraOS in qemu.

Did you run make env at the root directory of this project?

This error exists because you didn't install cargo-binutils, which should be installed here.

This error exists because you didn't install cargo-binutils, which should be installed here.

That's right. I just simply make run at the root directory of the project. Now it can enter qemu successfully after make env and make run at the root directory.

Thanks a lot for your kind bug feedback. You can contact me if you have any problems in the future.