Building `alloc` does not work with included compiler_builtins
The compiler_builtins crate is now explicitly injected. When building the alloc crate via a [dependencies.alloc] key in the Xargo.toml, a “multiple matching crates for compiler_builtins” error occurs. The reason is that alloc defines its own compiler_builtins dependency. Thus compiler_builtins in compiled twice, once as version 0.0.0 and once as version 0.1.0.
With latest xargo and nightly rustc, I saw the same error.
To fix it, I removed all references to compiler_bultins in my Xargo.toml and src/lib.rs.
diff --git a/Xargo.toml b/Xargo.toml
index a16927a..cb49458 100644
--- a/Xargo.toml
+++ b/Xargo.toml
@@ -3,9 +3,3 @@ alloc = {}
[target.x86_64-rxinu.dependencies]
alloc = {}
-
-[dependencies.core]
-stage = 0
-
-[dependencies.compiler_builtins]
-stage = 1
diff --git a/src/lib.rs b/src/lib.rs
index dae5ba2..dc9ec7f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,7 +4,6 @@
#![feature(const_fn)]
#![feature(const_max_value)]
#![feature(const_unique_new, const_atomic_usize_new)]
-#![feature(compiler_builtins_lib)]
#![feature(const_fn)]
#![feature(lang_items)]
#![feature(naked_functions)]
@@ -25,7 +24,6 @@ extern crate lazy_static;
extern crate once;
extern crate bit_field;
-extern crate compiler_builtins;
extern crate linked_list_allocator;
extern crate multiboot2;
extern crate rlibc;
Current Xargo.toml
[target.i686-rxinu.dependencies]
alloc = {}
[target.x86_64-rxinu.dependencies]
alloc = {}
@robert-w-gries That's also what I did.
I see that my workaround does not work if you want to use the compiler_builtins mem feature.
My project uses the rlibc crate, which is why I could remove compiler_builtins from my Xargo.toml without issue.
I created a simplified fork of xargo at rust-osdev/cargo-xbuild, which just always compiles core, compiler_builtins and alloc without configuration ability. The advantage of hard-coding those is that we can hack the alloc compilation so that it uses compiler_builtins with the "mem" feature.
@lachlansneff @robert-w-gries Could you try if this works for you?
cargo install cargo-xbuild and cargo xbuild --target x86_64-rxinu.json worked without issue for me.
Was there anything else you wanted me to test? I'm not sure if I need to do something more on my end to make sure the following works:
The advantage of hard-coding those is that we can hack the alloc compilation so that it uses compiler_builtins with the "mem" feature.
Was there anything else you wanted me to test? I'm not sure if I need to do something more on my end to make sure the following works:
You should be able to remove the rlibc dependency.