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

Leave choosing msvcrt up to the C/C++ CMake code #537

Merged
merged 2 commits into from
Jun 23, 2024

Conversation

jschwe
Copy link
Collaborator

@jschwe jschwe commented Jun 22, 2024

It's difficult for Corrosion to correctly choose the right msvcrt version. CMake has a target property for it, and we also don't know which build configurations the user CMake code expectes to be Debug related.

The previous code actually already removed the linking against msvcrt in all cases except "Debug" builds. This was not intentional, but indicates that removing the library entirely from the link list, and leaving it up to the C/C++ code to link it in, should work well in practice.

It's difficult for Corrosion to correctly choose the right
msvcrt version. CMake has a target property for it, and we
also don't know which build configurations the user CMake
code expectes to be Debug related.

The previous code actually already removed the linking
against `msvcrt` in all cases except "Debug" builds.
This was not intentional, but indicates that removing
the library entirely from the link list, and leaving
it up to the C/C++ code to link it in, should work
well in practice.
@jschwe
Copy link
Collaborator Author

jschwe commented Jun 22, 2024

@Billyzou0741326 could you test this PR? I haven't tested this on a windows machine, but I believe we don't even need to specify msvcrt on the link line, since we should be able to rely on CMake adding msvcrt to the link line of the C/++ executable or shared library, that we link our Rust static library into.

@Billyzou0741326
Copy link
Contributor

Billyzou0741326 commented Jun 22, 2024

I'm no longer seeing either msvcrt or msvcrtd being specified at all in the generated build scripts (checked both Ninja and the VS generator).

Not sure if this change will have other unintended effects, as I only tested via a trivial add method in the extern "C" style. At least that built just fine with no warnings

Co-authored-by: kotoriのねこ <minamiktr@outlook.com>
@jschwe jschwe merged commit b45275c into corrosion-rs:master Jun 23, 2024
36 checks passed
@jschwe jschwe deleted the jschwender/msvcrt_link branch June 23, 2024 09:36
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 this pull request may close these issues.

2 participants