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

The MSVC CRT library is not overrideable by other build systems #107570

Open
ChrisDenton opened this issue Feb 1, 2023 · 1 comment
Open

The MSVC CRT library is not overrideable by other build systems #107570

ChrisDenton opened this issue Feb 1, 2023 · 1 comment
Labels
A-linkage Area: linking into static, shared libraries and binaries O-windows-msvc Toolchain: MSVC, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@ChrisDenton
Copy link
Member

For -windows-msvc targets linking the C runtime (e.g. C main, etc) is done in the libc crate which then hard codes the CRT startup libraries to use, which means they can't be overridden (without hacks or no_std) except to choose between dynamic or static linking. This makes it difficult to select the right CRT for certain builds. This matters particularly when integrating Rust alongside existing C/C++ build systems. The same CRT must be used in all cases.

I would propose that rustc should behave more like cl (the MSVC compiler) in this case. We should use /DEFAULTLIB: to link the CRT so the library is overridable rather than hard coded. This also means it can work with existing tools rather than needing anything custom for rustc.

@ChrisDenton ChrisDenton added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-windows-msvc Toolchain: MSVC, Operating system: Windows and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 1, 2023
@ChrisDenton ChrisDenton added A-linkage Area: linking into static, shared libraries and binaries T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 11, 2023
@spangaer
Copy link

spangaer commented Dec 5, 2024

It looks like you figured this out yourself?
#39016 (comment)

Though I've noticed it doesn't seem to work with 1.79, but does with 1.83
#39016 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries O-windows-msvc Toolchain: MSVC, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants