Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for MSVC -MTd and -MDd #1230

Closed
crumblingstatue opened this issue Oct 5, 2024 · 7 comments · Fixed by #1231
Closed

Support for MSVC -MTd and -MDd #1230

crumblingstatue opened this issue Oct 5, 2024 · 7 comments · Fixed by #1231

Comments

@crumblingstatue
Copy link

The CMake documentation lists additional debug variants
for these MSVC flags, but as far as I can tell, the cc crate doesn't support the debug variants.

NobodyXu added a commit that referenced this issue Oct 6, 2024
* Use debug version of MSVC runtime library on debug

Fixed #1230

* Fix clippy
@retep998
Copy link
Member

retep998 commented Oct 6, 2024

It doesn't support it because the rest of the rust ecosystem doesn't either. Fixing this would require a much more coordinated effort across multiple repos, and still would have an ugly transition period.

@NobodyXu
Copy link
Collaborator

NobodyXu commented Oct 6, 2024

Yeah I tried it and have to revert it, as it breaks rust compilation

@ChrisDenton
Copy link
Member

The core issue is that rustc doesn't support this so there's no way for cc to know if this was wanted. cc could have a function for overriding the CRT libraries if someone really knows what they're doing but it is a bit of a footgun because it's super important that everything uses the same C runtime libraries.

To recap, this is the current state of affairs:

C/C++ rustc Native libs
/MT +crt-static libcmt, libvcruntime, libucrt
/MTd libcmtd, libvcruntimed, libucrtd
/MD -crt-static msvcrt, vcruntime, ucrt
/MDd msvcrtd, vcruntimed, ucrtd

So compiling using rustc only has two options. You can override Rust's choices by using a linker argument. E.g. /NODEFAULTLIB:msvcrt /DEFAULTLIB:msvcrtd to use the debug libraries. But you need some way to coordinate that choice with everyone and everything else.

@NobodyXu
Copy link
Collaborator

NobodyXu commented Oct 6, 2024

So compiling using rustc only has two options. You can override Rust's choices by using a linker argument. E.g. /NODEFAULTLIB:msvcrt /DEFAULTLIB:msvcrtd to use the debug libraries.

If it is possible to override using a linker argument, then maybe we can add a new flag/env to use the debug version of msvc runtime?

@retep998
Copy link
Member

retep998 commented Oct 6, 2024

Related issue: rust-lang/rust#39016

@ChrisDenton
Copy link
Member

An environment variable might work to keep it consistent across the whole build.

We also need to keep in mind a future where rustc hopefully gains support for the debug CRTs. Then we'd just need to query it the same way we do crt-static.

@crumblingstatue
Copy link
Author

crumblingstatue commented Oct 6, 2024

Thank you for the information everyone!
I guess in my case I'll just have to force my CMake C++ dependency to build without debug support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants