Custom libcore.rs

Hi there! Lately I got an idea of extending libcore a little. First of all, I cloned rust/library/core. Then, I set the path in my Cargo.toml. Finally, I put

#![no_std]
#![no_core]
extern crate custom_core as core;
use core::prelude::*;

to my main.rs and… compiler told me that things defined in custom_core are already defined in the core…

I got the error while compiling custom_core, not the crate with main.rs.

What am I doing wrong? Must I specify -Z build-std or something?

Every involved crate must specify #![no_core]. I suspect your custom_core or a dependency of it does not specify #![no_core].

custom_core is just a clone of rust-lang/rust/library/core :frowning:

Do you have any other dependencies? Those need to use your fork too.

Hm… looks like the problem may occur because I am using std. Compiler throws an error while compiling custom_core, not my crate tho :face_with_monocle:

You mean you made custom_core depend on libstd? That won't work as libstd pulls in the original libcore. It has to as custom_core isn't compiled yet when libstd is compiled.

No, I didn’t :joy:

I’m not as stupid as you think (or maybe I am). I imported println from libstd in my crate that depends on custom_core. Custom core isn’t really custom

I see. You will have to compile libstd and all it's dependencies against the patched libcore too.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.