rust-osdev / cargo-xbuild

Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.
Apache License 2.0
258 stars 25 forks source link

mem flag not honored #89

Closed steveyko closed 4 years ago

steveyko commented 4 years ago

I am cross-compiling a Rust library for aarch64-unknown-none-softfloat and it does not look like 'memcpy = false' in Cargo.toml is honored anymore. I have a libc that I'm using for my platform. Now when I'm linking things together my build script throws 'multiple definition of `memcpy'' etc.

This was working a few months ago (probably March or April) but now I came back to it, it does not work anymore.

I have updated my toolchain to the latest nightly as follows:

rustup 1.22.1 (2020-07-08) rustc 1.47.0-nightly (2020-07-26) cargo 1.47.0-nightly (2020-07-23)

Unfortunately, I don't have a log of which versions I was using when it was working.

I have tried different versions of cargo-xbuild, v0.5.20, v0.5.35, v0.6.0, etc.

v0.6.0 fails for a different reason (#88), but other versions all seem to include memcpy, etc.

I don't know if this is an issue with cargo-xbuild or compiler-builtins as it looks like compiler-builtins v0.1.32 is used now, which is probably a different version from what I was using before (though I don't know which version I was using when it was working for me).

Any help on this would be much appreciated.

phil-opp commented 4 years ago

If you don't need the mem feature: Have you tried using cargo's own build-std flag? It already works great for most projects, so maybe it works for you too. See https://github.com/rust-osdev/cargo-xbuild#alternative-the-build-std-feature-of-cargo for migration instructions.

I don't know what could cause the issue you're seeing. Our implementation still honors the memcpy flag when enabling the features of compiler_builtins: https://github.com/rust-osdev/cargo-xbuild/blob/master/src/sysroot.rs#L175-L179 . The mem feature of compiler_builtins is still no default feature on the latest version and it's not enabled by any other features: https://github.com/rust-lang/compiler-builtins/blob/f4c7940d3b13ec879c9fdc218812f71a65149123/Cargo.toml#L51 . So I see no reason why the feature should be enabled.

To debug this issue, it would help if you could post the full compilation log, post the code of your project, and ideally try to find out which cargo-xbuild release introduced the problem.

steveyko commented 4 years ago

Thanks for your answer. I actually found the reason: https://github.com/rust-lang/compiler-builtins/pull/357/commits/03001f2d5b36ec440c1cad704d2b13ece805d0db. My target contains '-none' and it automatically enables the mem feature. It's an issue from compiler-builtins, so I'll close this.