diff options
| author | Chris Denton <chris@chrisdenton.dev> | 2024-03-11 18:12:51 +0000 |
|---|---|---|
| committer | Chris Denton <chris@chrisdenton.dev> | 2024-03-11 18:31:50 +0000 |
| commit | aeec0d1269eebb5319d798d403bd3c78f2303a23 (patch) | |
| tree | 3a11fd33349ab540a5ea83dca80c1aa886862492 | |
| parent | 65cd843ae06ad00123c131a431ed5304e4cd577a (diff) | |
| download | rust-aeec0d1269eebb5319d798d403bd3c78f2303a23.tar.gz rust-aeec0d1269eebb5319d798d403bd3c78f2303a23.zip | |
Update /NODEFAUTLIB comment for msvc
| -rw-r--r-- | compiler/rustc_target/src/spec/base/windows_msvc.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/rustc_target/src/spec/base/windows_msvc.rs b/compiler/rustc_target/src/spec/base/windows_msvc.rs index e3cf9757219..bd0318f3183 100644 --- a/compiler/rustc_target/src/spec/base/windows_msvc.rs +++ b/compiler/rustc_target/src/spec/base/windows_msvc.rs @@ -17,15 +17,19 @@ pub fn opts() -> TargetOptions { crt_static_allows_dylibs: true, crt_static_respected: true, requires_uwtable: true, - // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC - // as there's been trouble in the past of linking the C++ standard - // library required by LLVM. This likely needs to happen one day, but - // in general Windows is also a more controlled environment than - // Unix, so it's not necessarily as critical that this be implemented. + // We don't pass the /NODEFAULTLIB flag to the linker on MSVC + // as that prevents linker directives embedded in object files from + // including other necessary libraries. // - // Note that there are also some licensing worries about statically - // linking some libraries which require a specific agreement, so it may - // not ever be possible for us to pass this flag. + // For example, msvcrt.lib embeds a linker directive like: + // /DEFAULTLIB:vcruntime.lib /DEFAULTLIB:ucrt.lib + // So that vcruntime.lib and ucrt.lib are included when the entry point + // in msvcrt.lib is used. Using /NODEFAULTLIB would mean having to + // manually add those two libraries and potentially further dependencies + // they bring in. + // + // See also https://learn.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-170#lib + // for documention on including library dependencies in C/C++ code. no_default_libraries: false, has_thread_local: true, |
