How can I provide my own `compiler_builtins` implementation while using `-Zbuild-std`?

I am compiling my code with -Zbuild-std=core,alloc.

cargo automatically pulls compiler_builtins v0.1.70. I would like to replace compiler_builtins with my customized version, but I couldn't find a way to do that.

Is it possible to provide my own compiler_builtins implementation?

More background: I am compiling Rust code with segmented stack on ARM MCUs. Some __aeabi_* functions defined in compiler_builtins are written in inline assembly. I must patch these functions so that they respect segmented stack.

AFAIK -Zbuild-std currently doesn't support overriding any sources. You could try xargo instead.

However, note that xargo is basically unmaintained. I keep it just barely working for what Miri needs, but don't have time for anything beyond that.

1 Like

(I'm curious: what would Miri need from -Zbuild-std like functionality that isn't currently there to move off of xargo?)

(We need to build a sysroot, not just a library suited for a single workspace. The biggest technical hurdle I am aware of is that a sysroot contains both panic_abort and panic_unwind, to support crates that use either panic strategy. This currently requires passing very specific flags when building these 2 crates, which is only possible via a RUSTC wrapper that adjusts the flags between cargo and rustc.)

2 Likes