I'm using nightly rust to compile this project GitHub - cpcsdk/rust.cpclib: [WIP] Rust libary that targets the creation of Amstrad CPC demos on Windows with the Microsoft toolchain.
I have not issues at all when compiling in debug mode.
However, in release node, there are big failures at the link step.
I don't think to have a special configuration for release profile.
I have no idea at all of how to fix this issue. So if someone has various ideas to help me where to look at, it would be great.
At the moment, I have no access to a Linux machine to check the behavior in release mode.
Among the 7k lines of code, there is this one that is probably important:
= note: C:\Users\giotr\Perso\CPC\rust.cpcdemotools\target\release\build\cpclib-basm-5e49886e96fe054b\out\MSVCRT.lib : warning
LNK4003: invalid library format; library ignored
LINK : error LNK2001: unresolved external symbol mainCRTStartup
this looks suspicious to me, so I checked the
cpclib-basm crate. it turns out the build script uses the
static_vcruntime crates, which might be the culprit.
but I have been used
static_vcruntime before, and didn't encounter any problem. are you cross compiling? or are your building for arm? I guess that "LNK4003: invalid library format; library ignored" error indicates there might be a architecture mismatch.
Thanks a lot for having looked. I do not crossdev at the moment and build on an intel CPU on windows.
If I remember well, I added static_vcruntime to cpclib-basm to make the executable works on other machines than mine.
This cpclib-basm crate compiles and run perfectly in release mode (I fixed a feature issue on the crate that was present before in the day).
Since your remark, I have added a build.rs (that does almost nothing) to my other executables and it solve the issues !
To remove the static_vcruntime of cpclib-basm allowed to compile cpclib-bndbuild ...
Totally random solution I do not understand, but at least I have no more issues ...
glad you found a solution
since you didn't show more details, I can only guess from the one line error message. since the
cpclib-basm package contains both a binary crate and library crate, I assume it is used by other crates as a dependency. because the build script used
static_vcruntime, which wrote a stub
msvcrt.lib in a in compatible format (for reasons I don't know) to
OUT_DIR, and the other crate that depends on
cpclib-basm picked up the invalid
msvcrt.lib so the linker get confused. it's just a guess though.
I'd suggest only emit the static vcruntime cargo directives for binary crates, not for libraries, otherwise your dependent might encounter link errors. but this also means if you want a binary to use
static_vcruntime, it needs to be in a separate package from the library, because there's no way in the build script to emit different linker flags for binaries and libraries of the same package, as far as I know.