Skip to content

Stage2 rustc cannot use stage2:sysroot artifacts #6

@yxdai-nju

Description

@yxdai-nju

I built stage2 rustc and sysroot artifacts with buck2 build stage2:rustc -m=riscv64 and buck2 build stage2:sysroot -m=riscv64, then combined them into a sysroot directory:

ubuntu@ubuntu:~$ tree ~/sysroot
/home/ubuntu/sysroot
├── bin
│   └── rustc
└── lib
    └── rustlib
        └── riscv64gc-unknown-linux-gnu
            └── lib
                ├── libaddr2line-007f1b3c.rlib
                ├── libadler2-481b1ea5.rlib
                ├── liballoc-7b36bf29.rlib
                ├── libcfg_if-6a1fcc32.rlib
                ├── libcompiler_builtins-1f7b3e51.rlib
                ├── libcore-18493fff.rlib
                ├── libgimli-37f06244.rlib
                ├── libhashbrown-1c741dd4.rlib
                ├── liblibc-4e784e9d.rlib
                ├── libmemchr-0c482414.rlib
                ├── libminiz_oxide-575b7770.rlib
                ├── libobject-75b0e44c.rlib
                ├── libpanic_unwind-40c529f7.rlib
                ├── librustc_demangle-29879389.rlib
                ├── librustc_std_workspace_alloc-297f18d9.rlib
                ├── librustc_std_workspace_core-1b4897cf.rlib
                ├── libstd-13a80529.rlib
                ├── libstd_detect-60746bac.rlib
                └── libunwind-4d6890c1.rlib

6 directories, 20 files

When trying to compile a hello world program:

ubuntu@ubuntu:~/src$ ~/sysroot/bin/rustc hello.rs
error[E0514]: found crate `std` compiled by an incompatible version of rustc
  |
  = note: the following crate versions were found:
          crate `std` compiled by rustc 1.86.0 (buckified stage1): /home/ubuntu/sysroot/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libstd-13a80529.rlib
          crate `std` compiled by rustc 1.86.0 (buckified stage1): /home/ubuntu/sysroot/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libstd_detect-60746bac.rlib
  = help: please recompile that crate using this compiler (rustc 1.86.0 (buckified stage2)) (consider running `cargo clean` first)

error: cannot find macro `println` in this scope
 --> hello.rs:2:5
  |
2 |     println!("hello, world");
  |     ^^^^^^^

error: requires `sized` lang_item

error: aborting due to 3 previous errors

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

The error shows that std libraries were compiled by "buckified stage1" while rustc is "buckified stage2".

Is there a correct way to build matching rustc and std artifacts? Or do I need to rebuild std with stage2 compiler?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions