thepowersgang / mrustc

Alternative rust compiler (re-implementation)
MIT License
2.18k stars 109 forks source link

A problem from beginner: Troubles with `core` and `std` paths when using mrustc #315

Closed Ghy0202 closed 1 year ago

Ghy0202 commented 1 year ago

I am a beginner in Rust, and I'm trying to write code using mrustc. However, it seems that the compiler is unable to locate the core and std paths. I am wondering if mrustc supports these two libraries and how to set the default paths via the command line. I tried this:

mrustc/bin/mrustc -L ./mrustc/rustc-1.29.0-src/src code.rs

and the code.rs looks like:

#![recursion_limit = "256"]
    #![feature(custom_mir, core_intrinsics, const_hash)]
    #![allow(unused_parens, unused_assignments, overflowing_literals)]
    extern crate core;
    use core::intrinsics::mir::*;

    use std::collections::hash_map::DefaultHasher;
    use std::hash::{Hash, Hasher};

    static mut H: DefaultHasher = DefaultHasher::new();

The error:

Setup: V V V
(0.00 s) Setup: DONE
Target Load: V V V
(0.00 s) Target Load: DONE
Parse: V V V
(0.05 s) Parse: DONE
LoadCrates: V V V
code.rs:4-5 error:0:Unable to locate crate 'core' in search directories
Aborted (core dumped)

I would be very happy if this question could be answered. (Perhaps this is a very basic question)🥲

Ghy0202 commented 1 year ago
image

It seems another problem, when I tried the stdlib path

thepowersgang commented 1 year ago

First off - mrustc isn't for beginners, it has had nowhere near the level of usablility polish rustc/cargo have.

With that said - you need to build the standard library first - use make LIBS in the mrustc source folder to build the 1.29 standard library to output. Then point mrustc at that using -L path/to/output

Ghy0202 commented 1 year ago

First off - mrustc isn't for beginners, it has had nowhere near the level of usablility polish rustc/cargo have.

With that said - you need to build the standard library first - use make LIBS in the mrustc source folder to build the 1.29 standard library to output. Then point mrustc at that using -L path/to/output

Hhh, thank u! I‘ve solved this problem after using -L path/to/output😉