@@ -17,15 +17,19 @@ pub fn opts() -> TargetOptions {
17
17
crt_static_allows_dylibs : true ,
18
18
crt_static_respected : true ,
19
19
requires_uwtable : true ,
20
- // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC
21
- // as there's been trouble in the past of linking the C++ standard
22
- // library required by LLVM. This likely needs to happen one day, but
23
- // in general Windows is also a more controlled environment than
24
- // Unix, so it's not necessarily as critical that this be implemented.
20
+ // We don't pass the /NODEFAULTLIB flag to the linker on MSVC
21
+ // as that prevents linker directives embedded in object files from
22
+ // including other necessary libraries.
25
23
//
26
- // Note that there are also some licensing worries about statically
27
- // linking some libraries which require a specific agreement, so it may
28
- // not ever be possible for us to pass this flag.
24
+ // For example, msvcrt.lib embeds a linker directive like:
25
+ // /DEFAULTLIB:vcruntime.lib /DEFAULTLIB:ucrt.lib
26
+ // So that vcruntime.lib and ucrt.lib are included when the entry point
27
+ // in msvcrt.lib is used. Using /NODEFAULTLIB would mean having to
28
+ // manually add those two libraries and potentially further dependencies
29
+ // they bring in.
30
+ //
31
+ // See also https://learn.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-170#lib
32
+ // for documention on including library dependencies in C/C++ code.
29
33
no_default_libraries : false ,
30
34
has_thread_local : true ,
31
35
0 commit comments