Skip to content

Cannot test bug fixes of dependencies of libcore/libstd on targets where -Zbuild-std is required. #77

Closed
@cr1901

Description

@cr1901

Problem

As of last week, CI for an msp430 firmware I test against nightly began failing. compiler-builtins, which is a dependency of libcore/libstd was updated in rust-lang/rust@88f1bf7, and broke a few platforms, including msp430. I figured out the problem, opened an issue, and have attempted to create a local fix that I wish to test.

Unfortunately, I am not able to test locally, because it appears that there's no way to override Rust's internal Cargo.lock for testing bug fixes to compiler-builtins. Targets which provide libstd/libcore don't have this problem because providing libstd/libcore means Rust thinks those dependencies are always up to date. My fix probably works, but I'm not comfortable submitting a PR until I have tested locally. Is it possible to provide provisions for overriding Rust's Cargo.lock and internal cargo manifests for the purpose of testing bug fixes?

I've elaborated on the problem in another issue. I'm reproducing it here for convenience:

Issue #441

I have a fix locally for #441. Unfortunately I can't get -Zbuild-std=core to choose the correct version of compiler_builtins with my changes, so that I can test... compilation of compiler_builtins with my changes.

patching compiler-builtins

diff --git a/Cargo.toml b/Cargo.toml
index d4348fb..61cfab6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -80,3 +80,6 @@ panic = 'abort'
 
 [profile.dev]
 panic = 'abort'
+
+[patch.crates-io]
+compiler_builtins = { version="0.1.52", path = '.' }

This patch appears to do nothing (although I may have specified it incorrectly, tbf):

william@xubuntu-dtrain:~/Projects/toolchains/compiler-builtins$ cargo +msp430-fix build --target=msp430-none-elf -Zbuild-std=core
   Compiling compiler_builtins v0.1.52
   Compiling compiler_builtins v0.1.53 (/home/william/Projects/toolchains/compiler-builtins)
warning: an associated function with this name may be added to the standard library in the future
 --> src/float/pow.rs:8:19
  |
8 |     let mut pow = i32::abs_diff(b, 0);
  |                   ^^^^^^^^^^^^^
  |
  = note: `#[warn(unstable_name_collisions)]` on by default
  = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
  = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
  = help: call with fully qualified syntax `Int::abs_diff(...)` to keep using the current
method
  = help: add `#![feature(int_abs_diff)]` to the crate attributes to enable `num::<impl i32>::abs_diff`

LLVM ERROR: Cannot select: t14: i16,ch = AtomicLoad<(load unordered (s16) from %ir.188)> t13:1, t13, /home/william/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.52/src/mem/impls.rs:65:29 @[ /home/william/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.52/src/mem/impls.rs:109:13 @[ /home/william/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.52/src/mem/mod.rs:25:5 ] ]
  t13: i16,ch = load<(dereferenceable load (s16) from %ir.28)> t12, FrameIndex:i16<24>, undef:i16, /home/william/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.52/src/mem/impls.rs:65:69 @[ /home/william/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.52/src/mem/impls.rs:109:13 @[ /home/william/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.52/src/mem/mod.rs:25:5 ] ]
    t11: i16 = FrameIndex<24>
    t5: i16 = undef
In function: memcpy
error: could not compile `compiler_builtins`
warning: build failed, waiting for other jobs to finish...
LLVM ERROR: Cannot select: t14: i16,ch = AtomicLoad<(load unordered (s16) from %ir.188)> t13:1, t13, src/mem/impls.rs:65:29 @[ src/mem/impls.rs:109:13 @[ src/mem/mod.rs:25:5 ] ]
  t13: i16,ch = load<(dereferenceable load (s16) from %ir.28)> t12, FrameIndex:i16<24>, undef:i16, src/mem/impls.rs:65:69 @[ src/mem/impls.rs:109:13 @[ src/mem/mod.rs:25:5 ] ]
    t11: i16 = FrameIndex<24>
    t5: i16 = undef
In function: memcpy
warning: `compiler_builtins` (lib) generated 1 warning
error: build failed
william@xubuntu-dtrain:~/Projects/toolchains/compiler-builtins$

patching rust

diff --git a/Cargo.lock b/Cargo.lock
index 51ed441d0db..74623c9d602 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -676,16 +676,6 @@ dependencies = [
  "libc",
 ]

-[[package]]
-name = "compiler_builtins"
-version = "0.1.52"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6591c2442ee984e2b264638a8b5e7ae44fd47b32d28e3a08e2e9c3cdb0c2fb0"
-dependencies = [
- "cc",
- "rustc-std-workspace-core",
-]
-
 [[package]]
 name = "compiletest"
 version = "0.0.0"
diff --git a/library/backtrace b/library/backtrace
--- a/library/backtrace
+++ b/library/backtrace
@@ -1 +1 @@
-Subproject commit b02ed04a7e915659eea6fb1607df469b84a30638
+Subproject commit b02ed04a7e915659eea6fb1607df469b84a30638-dirty
diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
index 8f43e902a87..70147631270 100644
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -16,7 +16,7 @@ panic_unwind = { path = "../panic_unwind", optional = true }
 panic_abort = { path = "../panic_abort" }
 core = { path = "../core" }
 libc = { version = "0.2.106", default-features = false, features = ['rustc-dep-of-std'] }
-compiler_builtins = { version = "0.1.52" }
+compiler_builtins = { path="/home/william/Projects/toolchains/compiler-builtins", version = "0.1.53" }
 profiler_builtins = { path = "../profiler_builtins", optional = true }
 unwind = { path = "../unwind" }
 hashbrown = { version = "0.11", default-features = false, features = ['rustc-dep-of-std'] }

I genuinely don't understand the resulting error. You say 0.1.53 meets the requirements to be chosen and simultaneously isn't acceptable. So which is it?:

william@xubuntu-dtrain:~/Projects/toolchains/compiler-builtins$ cargo +msp430-fix build --target=msp430-none-elf -Zbuild-std=core
    Updating crates.io index
error: failed to select a version for `compiler_builtins`.
    ... required by package `alloc v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/alloc)`
    ... which satisfies path dependency `alloc` of package `panic_abort v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/panic_abort)`
    ... which satisfies path dependency `panic_abort` of package `std v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/std)`
    ... which satisfies path dependency `std` of package `proc_macro v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/proc_macro)`
    ... which satisfies path dependency `proc_macro` (locked to 0.0.0) of package `test v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/test)`
versions that meet the requirements `^0.1.40` are: 0.1.53, 0.1.52, 0.1.51, 0.1.50, 0.1.49, 0.1.48, 0.1.47, 0.1.46, 0.1.45, 0.1.44, 0.1.43, 0.1.42, 0.1.41, 0.1.40

the package `compiler_builtins` links to the native library `compiler-rt`, but it conflicts with a previous package which links to `compiler-rt` as well:
package `compiler_builtins v0.1.53 (/home/william/Projects/toolchains/compiler-builtins)`
    ... which satisfies path dependency `compiler_builtins` of package `std v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/std)`
    ... which satisfies path dependency `std` of package `proc_macro v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/proc_macro)`
    ... which satisfies path dependency `proc_macro` (locked to 0.0.0) of package `test v0.0.0 (/home/william/Projects/toolchains/build-llvm-toolchain/build-rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/test)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='compiler_builtins' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `compiler_builtins` which could resolve this conflict

Other Remarks

In addition, libcore doesn't list compiler_builtins as a dependency, so why is -Zbuild-std=core trying to build it anyway?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions