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

HELP error: unknown --json option future-incompat #1097

Closed
kaixinbaba opened this issue Mar 26, 2022 · 21 comments
Closed

HELP error: unknown --json option future-incompat #1097

kaixinbaba opened this issue Mar 26, 2022 · 21 comments

Comments

@kaixinbaba
Copy link

When I start study VGA Text Mode and add dependency for volatile, My project start got error like this

 │WARNING: You're currently building for the host system. This is likely an error and will cause build scripts of dependencies to break.
 │
 │To build for the target system either pass a `--target` argument or set the build.target configuration key in a `.cargo/config` file.
 │
 │   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
 │   Compiling compiler_builtins v0.1.70
 │error: unknown `--json` option `future-incompat`
 │error: unknown `--json` option `future-incompat`
 │error: unknown `--json` option `future-incompat`
 │
 │
 │
 │error: could not compile `compiler_builtins`
 │warning: build failed, waiting for other jobs to finish...
 │error: build failed

Even if I delete the volatile dependency, or even delete the entire project and start all over again, it will not return to normal, and my project can successfully print characters in pemu before the volatile event follows the tutorial

Please HELP~
My .cargo/config.toml in project

cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-nostartfiles"]

[target.'cfg(target_os = "windows")']
rustflags = ["-C", "link-args=/ENTRY:_start /SUBSYSTEM:console"]

[target.'cfg(target_os = "macos")']
rustflags = ["-C", "link-args=-e __start -static -nostartfiles"]

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

[build]
target = "x86_64-blog_os.json"

My main.rs

#![no_std]
#![no_main]

use core::panic::PanicInfo;


#[panic_handler]
fn panic(_info: &PanicInfo) -> ! { 
    loop {}
}


#[no_mangle]
pub extern "C" fn _start() -> ! {
    loop {}
}

My Cargo.toml

[package]
name = "blog_os_study"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]



[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

my json

{
    "llvm-target": "x86_64-unknown-none",
    "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
    "arch": "x86_64",
    "target-endian": "little",
    "target-pointer-width": "64",
    "target-c-int-width": "32",
    "os": "none",
    "executables": true,
    "linker-flavor": "ld.lld",
    "linker": "rust-lld",
    "panic-strategy": "abort",
    "disable-redzone": true,
    "features": "-mmx,-sse, soft-float"
}

What confuse me the most was the error: unknown '--json' option 'future-incompat' this error, which I had never seen before and did not get much help from searching

My computer is Macbook Pro

Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64

macOS Monterey 12.21

By the way, A Freestanding Rust Binary This chapter is consistent with the tutorial and the correct output

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 26, 2022

Which rustc and cargo version are you using? You can see this with rustc -V and cargo -V.

@kaixinbaba
Copy link
Author

$ rustc -V --verbose
rustc 1.61.0-nightly (63b8f01bb 2022-03-24)
binary: rustc
commit-hash: 63b8f01bb5ca277e7df8d7efe094ed4244c1790c
commit-date: 2022-03-24
host: x86_64-apple-darwin
release: 1.61.0-nightly
LLVM version: 14.0.0


$ cargo -V --verbose
cargo 1.61.0-nightly (109bfbd05 2022-03-17)
release: 1.61.0-nightly
commit-hash: 109bfbd055325ef87a6e7f63d67da7e838f8300b
commit-date: 2022-03-17
host: x86_64-apple-darwin
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.77.0 (sys:0.4.51 curl-7.80.0 system ssl:(SecureTransport) LibreSSL/2.8.3)
os: Mac OS 12.2.1 [64-bit]


$ rustup -V
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.61.0-nightly (63b8f01bb 2022-03-24)`

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 26, 2022

What is the exact command you are using to build it?

@kaixinbaba
Copy link
Author

What is the exact command you are using to build it?

just follow the tutorial, use cargo build --target x86_64-blog_os.json

@kaixinbaba
Copy link
Author

$ cargo build --target x86_64-blog_os.json
   Compiling compiler_builtins v0.1.70
   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
error: unknown `--json` option `future-incompat`
error: unknown `--json` option `future-incompat`


error: could not compile `compiler_builtins`
warning: build failed, waiting for other jobs to finish...
error: build failed

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 26, 2022

rustc --json future-incompat was introduced four months ago in rust-lang/rust#91535 which is part of rustc 1.59. What does cat target/.rustc_info.json show? That should show which rustc version is actually used by cargo.

@kaixinbaba
Copy link
Author

$ cat target/.rustc_info.json
{
    "rustc_fingerprint":10704764349668684348,
    "outputs":{
        "931469667778813386":{
            "success":true,
            "status":"",
            "code":0,
            "stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"llvm14-builtins-abi\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"apple\"\nunix\n",
            "stderr":""
        },
        "1412545348552125361":{
            "success":false,
            "status":"exit status: 1",
            "code":1,
            "stdout":"",
            "stderr":"error: `-Csplit-debuginfo` is unstable on this platform\n\n"
        },
        "1825251703565484386":{
            "success":true,
            "status":"",
            "code":0,
            "stdout":"___\nlib___.rlib\nlib___.a\n/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin\ndebug_assertions\npanic=\"abort\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_feature=\"llvm14-builtins-abi\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"none\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\n",
            "stderr":"warning: dropping unsupported crate type `dylib` for target `x86_64-blog_os-14647065019002254224`\n\nwarning: dropping unsupported crate type `cdylib` for target `x86_64-blog_os-14647065019002254224`\n\nwarning: dropping unsupported crate type `proc-macro` for target `x86_64-blog_os-14647065019002254224`\n\nwarning: 3 warnings emitted\n\n"
        },
        "17598535894874457435":{
            "success":true,
            "status":"",
            "code":0,
            "stdout":"rustc 1.61.0-nightly (63b8f01bb 2022-03-24)\nbinary: rustc\ncommit-hash: 63b8f01bb5ca277e7df8d7efe094ed4244c1790c\ncommit-date: 2022-03-24\nhost: x86_64-apple-darwin\nrelease: 1.61.0-nightly\nLLVM version: 14.0.0\n",
            "stderr":""
        },
        "2797684049618456168":{
            "success":true,
            "status":"",
            "code":0,
            "stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n",
            "stderr":""
        }
    },
    "successes":{

    }
}

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 26, 2022

😕

@kaixinbaba
Copy link
Author

😕

How's that...Please help

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 26, 2022

I have no clue what the issue is unfortunately.

@kaixinbaba
Copy link
Author

It's a regrettable, but still thank you for your REPLY!

@kaixinbaba
Copy link
Author

I just try to use the origin repo post-02 and follow the README.md
but still got this as follow

$ rustup update nightly --force
info: syncing channel updates for 'nightly-x86_64-apple-darwin'

  nightly-x86_64-apple-darwin unchanged - rustc 1.61.0-nightly (d53246fed 2022-03-25)

info: checking for self-updates

$ cargo build
   Compiling compiler_builtins v0.1.53
   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
error: unknown `--json` option `future-incompat`
error: unknown `--json` option `future-incompat`


error: could not compile `compiler_builtins`
warning: build failed, waiting for other jobs to finish...
error: build failed

$ cargo install bootimage
    Updating `ustc` index
error: failed to update replaced source registry `crates-io`

Caused by:
  failed to fetch `git://mirrors.ustc.edu.cn/crates.io-index`

Caused by:
  process didn't exit successfully: `git fetch --force --update-head-ok 'git://mirrors.ustc.edu.cn/crates.io-index' ' HEAD:refs/remotes/origin/HEAD'` (exit status: 128)
  --- stderr
  fatal: read error: Connection reset by peer

$ cargo bootimage
WARNING: `CARGO_MANIFEST_DIR` env variable not set
Building kernel
   Compiling compiler_builtins v0.1.53
   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
error: unknown `--json` option `future-incompat`
error: unknown `--json` option `future-incompat`


error: could not compile `core`
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Kernel build failed.
Stderr:

I felt like I was going to surrender

It's too much of a blow to self-confidence

The point is that the code from yesterday's second lesson still ran successfully

@phil-opp
Copy link
Owner

@kaixinbaba Could you try running cargo clean and then cargo b -vv? This should give you verbose output, where we see the exact rustc command that is being invoked.

@kaixinbaba
Copy link
Author

@phil-opp Thank you for REPLY!
Here is my output for code from post-02 branch

$ cargo b -vv
   Compiling compiler_builtins v0.1.70
   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
     Running `CARGO=/usr/local/bin/cargo CARGO_CRATE_NAME=build_script_build 
CARGO_MANIFEST_DIR=/Users/xunjunjie/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/compiler_builtins-0.1.70 
CARGO_PKG_AUTHORS='Jorge Aparicio <[email protected]>' 
CARGO_PKG_DESCRIPTION='Compiler intrinsics used by the Rust compiler. Also available for other targets
if necessary'\!'
' 
CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/compiler-builtins' 
CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' 
CARGO_PKG_NAME=compiler_builtins 
CARGO_PKG_REPOSITORY='https://github.com/rust-lang/compiler-builtins' 
CARGO_PKG_VERSION=0.1.70 
CARGO_PKG_VERSION_MAJOR=0 
CARGO_PKG_VERSION_MINOR=1 
CARGO_PKG_VERSION_PATCH=70 
CARGO_PKG_VERSION_PRE='' 
DYLD_FALLBACK_LIBRARY_PATH='/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps:/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib:/Users/xunjunjie/lib:/usr/local/lib:/usr/lib' 
RUSTC_BOOTSTRAP=1 rustc --crate-name build_script_build /Users/xunjunjie/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/compiler_builtins-0.1.70/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="mem"' --cfg 'feature="rustc-dep-of-std"' -C metadata=c7a24f5a423a70c0 -C extra-filename=-c7a24f5a423a70c0 --out-dir /Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/build/compiler_builtins-c7a24f5a423a70c0 -Z force-unstable-if-unmarked -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps --cap-lints warn`
     Running `CARGO=/usr/local/bin/cargo 
CARGO_CRATE_NAME=core 
CARGO_MANIFEST_DIR=/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core 
CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='The Rust Core Library' 
CARGO_PKG_HOMEPAGE='' 
CARGO_PKG_LICENSE='MIT OR Apache-2.0' 
CARGO_PKG_LICENSE_FILE='' 
CARGO_PKG_NAME=core 
CARGO_PKG_REPOSITORY='https://github.com/rust-lang/rust.git' 
CARGO_PKG_VERSION=0.0.0 
CARGO_PKG_VERSION_MAJOR=0 
CARGO_PKG_VERSION_MINOR=0 
CARGO_PKG_VERSION_PATCH=0 
CARGO_PKG_VERSION_PRE='' 
DYLD_FALLBACK_LIBRARY_PATH='/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps:/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib:/Users/xunjunjie/lib:/usr/local/lib:/usr/lib' 
RUSTC_BOOTSTRAP=1 rustc --crate-name core --edition=2021 /Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=dea57f7448780fea -C extra-filename=-dea57f7448780fea --out-dir /Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps --target /Users/xunjunjie/IdeaProjects/RustHome/blog_os/x86_64-blog_os.json -Z force-unstable-if-unmarked -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps --cap-lints warn`
error: unknown `--json` option `future-incompat`
error: unknown `--json` option `future-incompat`


error: could not compile `core`

Caused by:
  process didn't exit successfully: `CARGO=/usr/local/bin/cargo 
CARGO_CRATE_NAME=core 
CARGO_MANIFEST_DIR=/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core CARGO_PKG_AUTHORS='' 
CARGO_PKG_DESCRIPTION='The Rust Core Library' 
CARGO_PKG_HOMEPAGE='' 
CARGO_PKG_LICENSE='MIT OR Apache-2.0' 
CARGO_PKG_LICENSE_FILE='' 
CARGO_PKG_NAME=core 
CARGO_PKG_REPOSITORY='https://github.com/rust-lang/rust.git' 
CARGO_PKG_VERSION=0.0.0 
CARGO_PKG_VERSION_MAJOR=0 
CARGO_PKG_VERSION_MINOR=0 
CARGO_PKG_VERSION_PATCH=0 
CARGO_PKG_VERSION_PRE='' 
DYLD_FALLBACK_LIBRARY_PATH='/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps:/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib:/Users/xunjunjie/lib:/usr/local/lib:/usr/lib' RUSTC_BOOTSTRAP=1 rustc --crate-name core --edition=2021 /Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=dea57f7448780fea -C extra-filename=-dea57f7448780fea --out-dir /Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps --target /Users/xunjunjie/IdeaProjects/RustHome/blog_os/x86_64-blog_os.json -Z force-unstable-if-unmarked -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps --cap-lints warn` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed

@phil-opp
Copy link
Owner

Thanks! Could you try running the first rust command manually. I.e. run the following in your shell:

rustc --crate-name core --edition=2021 /Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=dea57f7448780fea -C extra-filename=-dea57f7448780fea --out-dir /Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps --target /Users/xunjunjie/IdeaProjects/RustHome/blog_os/x86_64-blog_os.json -Z force-unstable-if-unmarked -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps --cap-lints warn

If it still throws the "unknown --json option" error, then try running rustc --version again in the same directory to see whether it is invoking the right rustc.

@kaixinbaba
Copy link
Author

Thanks! Could you try running the first rust command manually. I.e. run the following in your shell:

rustc --crate-name core --edition=2021 /Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=dea57f7448780fea -C extra-filename=-dea57f7448780fea --out-dir /Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps --target /Users/xunjunjie/IdeaProjects/RustHome/blog_os/x86_64-blog_os.json -Z force-unstable-if-unmarked -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps --cap-lints warn

If it still throws the "unknown --json option" error, then try running rustc --version again in the same directory to see whether it is invoking the right rustc.


It return

{"artifact":"/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps/core-dea57f7448780fea.d","emit":"dep-info"}
{"artifact":"/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps/libcore-dea57f7448780fea.rmeta","emit":"metadata"}
{"artifact":"/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/x86_64-blog_os/debug/deps/libcore-dea57f7448780fea.rlib","emit":"link"}

@kaixinbaba
Copy link
Author

And I try another rust command

rustc --crate-name build_script_build /Users/xunjunjie/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/compiler_builtins-0.1.70/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="mem"' --cfg 'feature="rustc-dep-of-std"' -C metadata=c7a24f5a423a70c0 -C extra-filename=-c7a24f5a423a70c0 --out-dir /Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/build/compiler_builtins-c7a24f5a423a70c0 -Z force-unstable-if-unmarked -L dependency=/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/deps --cap-lints warn

and it return

{"artifact":"/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/build/compiler_builtins-c7a24f5a423a70c0/build_script_build-c7a24f5a423a70c0.d","emit":"dep-info"}
{"artifact":"/Users/xunjunjie/IdeaProjects/RustHome/blog_os/target/debug/build/compiler_builtins-c7a24f5a423a70c0/build_script_build-c7a24f5a423a70c0","emit":"link"}

What's these two mean? Ask for guidance
@phil-opp Thank you for REPLY~

@phil-opp
Copy link
Owner

phil-opp commented Mar 27, 2022

The output shows that the rustc version that you invoked manually understands the future-incompat JSON option, which makes sense as your rustc --version output seems to be new enough for that. So something seems to go wrong when cargo invokes rustc, not sure why.

Could you try running RUSTFLAGS="--version -v" cargo b and paste the output here?

@kaixinbaba
Copy link
Author

The output is

RUSTFLAGS="--version --verbose" cargo build
error: output of --print=file-names has changed in the compiler, cannot parse
command was: `rustc - --crate-name ___ --print=file-names --version --verbose --target /Users/xunjunjie/IdeaProjects/RustHome/blog_os/x86_64-blog_os.json --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg`

--- stdout
rustc 1.61.0-nightly (d53246fed 2022-03-25)
binary: rustc
commit-hash: d53246fedde4c193eae8a003546a8f0f9f85d223
commit-date: 2022-03-25
host: x86_64-apple-darwin
release: 1.61.0-nightly
LLVM version: 14.0.0

@elaforma
Copy link

elaforma commented Mar 28, 2022

I'm not familiar with the way Rustup works on MacOS. On Linux and Windows, it would usually install binaries in your home directory (in ~/.cargo).

From the output above, however, it seems like cargo is being invoked from /usr/local/bin.

Do you have any other versions of Rust installed, e.g. through Homebrew? Maybe that's causing the weird behavior.

@kaixinbaba
Copy link
Author

$ whereis cargo 
# there is noting output

$ which cargo
/usr/local/bin/cargo

$ cargo -V
cargo 1.61.0-nightly (109bfbd05 2022-03-17)

$ cargo build
   Compiling compiler_builtins v0.1.70
   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
error: unknown `--json` option `future-incompat`
error: unknown `--json` option `future-incompat`

Then I try to use $HOME/.cargo/bin/cargo

$ ~/.cargo/bin/cargo build
   Compiling compiler_builtins v0.1.70
   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
   Compiling bootloader v0.9.21
   Compiling rustc-std-workspace-core v1.99.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling blog_os v0.1.0 (/Users/xunjunjie/IdeaProjects/RustHome/blog_os)
    Finished dev [unoptimized   debuginfo] target(s) in 14.90s

AMAZING!
Then I add ~/.cargo/bin to PATH at first manually

$ cargo build
   Compiling compiler_builtins v0.1.70
   Compiling core v0.0.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
   Compiling bootloader v0.9.21
   Compiling rustc-std-workspace-core v1.99.0 (/Users/xunjunjie/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling blog_os v0.1.0 (/Users/xunjunjie/IdeaProjects/RustHome/blog_os)
    Finished dev [unoptimized   debuginfo] target(s) in 15.15s

I think this issue resolved!

THANK YOU!
@phil-opp

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

4 participants