-
Notifications
You must be signed in to change notification settings - Fork 502
use debug version of C runtime with MSVC #717
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
Conversation
766e2c9
to
6dbb0ff
Compare
On a tangential note, there is a case to be made that when it comes to a library, Since cc-rs produces specifically libraries for Rust to link with, one can even argue that cc-rs should use |
That would be nice if that works. If you want to experiment with that, go for it. In the meantime this simple change solves my problem. |
It does work for me. And if it doesn't for you, I'd like to hear about it. Would you care to provide more details about the failure? At least who does the final linking, Rust or cl? |
I'm not clear what you're asking. I have not tested using |
Then why did you write "That would be nice if that works"? I mean it sounded like it didn't work for you. So I had to ask. It's ok if you don't want to entertain the idea, but then don't make it sound like it didn't work :-) |
Ping. I stumbled over this bug again trying to setup a Windows development environment. |
Hm, while this is certainly the easiest way to fix your specific issue, I'm not sure that this is a good general solution. This PR may be incorrect for many other use cases. Currently rustc (via libc) hard codes non-debug CRT for all Rust compiled code so it may cause conflicts depending on how it's used. While I absolutely want to see a solution to the problems with linking the right CRT, I think there is perhaps some design work that needs to be done first. |
Since #723 has been closed can this straightforward bug fix be merged? |
Just in case for reference. So that there is understanding of the scope. Since rustc effectively overrides references to C RT left by (*) The C++ problem more specifically. As for C-only, I [for one] would still recommend the |
I don't think this is a "straight forward bug fix". To be honest, I'm even more nervous about this now than I used to be. Changing the implicit behaviour of cc-rs has been causing issues with various build systems in recent releases. I do think there should be a way to use debug CRT versions, etc. But this should not be tied to an existing option. Solving one use case does not necessarily justify breaking others. If we can have a solution that doesn't break others then we should do that instead. |
Holding up this months old tiny bugfix over vague, unverified concerns is quite frustrating. If you have a better idea, please suggest it or implement it yourself. |
The issue is not vague, it's specific.
|
It's actually possible to override rustc's choice with |
Hi I'm experimenting rust integration with c++ on windows with msvc, and I find it annoying that the out of the box experience doesn't work to build code in Debug that is built by CMake when some code is also build by cc using the wrong crt library. From my limited knownledge this PR would be the best to fix the issue implictly for everyone. It only affect the code in Debug mode, so it shouldn't break any behavior in production code. Another idea would be to add a feature |
This may break production builds that use the debug setting. But even if it only broke some dev builds, that wouldn't be acceptable either. I'm closing this now as I don't think this approach can be made to work. Other approaches may have a greater chance of success if they're fully opt-in rather than potentially silently enabled. Though long term the proper fix would be to allow rustc to fully support the debug libraries in some way. Then everything can be made to "just work" by default in whatever configuration. |
An opt-in solution would not really be a solution because that still leaves debug builds broken unless downstreams are aware of the problem and opt in to the fix.
Could you elaborate? |
See rust-lang/rust#39016. I have just written a comment outlining a possible way forward and asking rustc compiler if this would be the approach they want. |
https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library
I encountered a link error when linking a Rust library with some C++ built by cc with other C++ code built by CMake because cc wasn't using the debug version of the C runtime.