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

Indicate which version of MSVC Rust was built with #26258

Open
retep998 opened this issue Jun 12, 2015 · 5 comments
Open

Indicate which version of MSVC Rust was built with #26258

retep998 opened this issue Jun 12, 2015 · 5 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. O-windows-msvc Toolchain: MSVC, Operating system: Windows

Comments

@retep998
Copy link
Member

When linking to the CRT on Windows, all code that is statically linked together needs to use the same version of the CRT. Different versions of the CRT (aka they have different DLL names) are not ABI compatible, so msvcrt120.dll and msvcrt110.dll are not ABI compatible. In particular, almost all Rust code links statically to libstd, so the version of the CRT that libstd uses needs to be same version of the CRT that Rust code using that libstd is using.

For the gnu version of Rust, it relies on msvcrt.dll and since all versions of MinGW will link to msvcrt.dll everything is fine and dandy.

However, for the MSVC version of Rust, it is linked against a specific versioned CRT such as msvcrt120.dll. Since the version of the CRT depends on which version of MSVC you build your code with, there is a possibility for you to use a different version of the CRT than libstd was built with, causing room for potential ABI issues. There's even separate debug/release versions of the CRT for each version, as well as static/dynamically linked versions of the CRT.

Therefore, to ensure that there is no ABI compatibility issues, distributions of the MSVC version of Rust should indicate exactly which version of MSVC and the CRT they were built with.

Note that this is purely an issue for developers using Rust to build their code with the msvc toolchain. End-users of binaries built by Rust merely need to have the appropriate redistributable installed and there's no ABI concerns there.

@alexcrichton
Copy link
Member

It sounds like our best option will be to avoid the CRT entirely. I highly doubt there's a "correct" CRT to depend on and whatever we choose will likely cause pain for someone at some point, so not depending on one at all seems best.

Apart from the standard library we also need to worry about the small bits of C code we link into the standard library, any object compiled with cl.exe embeds which CRT it was linked against, so we need to be able to avoid that entirely.

@cyplo
Copy link
Contributor

cyplo commented Aug 3, 2016

Hi !
Is this still an issue ?

@retep998
Copy link
Member Author

retep998 commented Aug 8, 2016

Rust still relies on things which are not guaranteed by Microsoft to remain stable across versions. Fortunately the stuff that Rust currently relies on hasn't changed between the versions of msvc that we currently support.

@Mark-Simulacrum
Copy link
Member

So I seem to recall an RFC and implementation recently regarding CRTs, does that fix this issue? Or at least update it in some way?

@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: not aware of changes that fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. O-windows-msvc Toolchain: MSVC, Operating system: Windows
Projects
None yet
Development

No branches or pull requests

5 participants