Problems with no_std, rust, staticlib and compiler_builtins

Core requires that certain memory functions exist, which are normally provided by libc. These can be provided by compiler_builtins. For some reason compiler_builtins doesn’t always build the memory functions when using the -Z build_std. In order to get it work, you need to add -Z build-std-features=compiler-builtins-mem

Otherwise you’ll either get errors like:

multiple rlib candidates for `compiler_builtins` found

or that memcpy, strlen, etc are not defined.

There used to be (is?) code to automatically enable that feature on no_std targets, but for some reason it wasn’t working for me.

Leave a Reply

Your email address will not be published. Required fields are marked *