Skip to content

Commit 0235f6b

Browse files
authored
Unrolled build for rust-lang#122342
Rollup merge of rust-lang#122342 - ChrisDenton:defautlib, r=petrochenkov Update /NODEFAUTLIB comment for msvc I've tried to explain a bit more about the effects of `/NODEFAULTLIB` when using msvc link.exe (or compatible) as they're different from `-nodefaultlib` on gnu. I also removed the part about licensing as I'm not sure licensing is an issue? Or rather, it's no more or less of an issue no matter how you link msvc libraries. The license is the one you get if using VS at all and even dynamic linking includes static code (e.g. startup/shutdown code, etc). r? petrochenkov
2 parents 0fa7fea + aeec0d1 commit 0235f6b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

compiler/rustc_target/src/spec/base/windows_msvc.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ pub fn opts() -> TargetOptions {
1717
crt_static_allows_dylibs: true,
1818
crt_static_respected: true,
1919
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.
2523
//
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.
2933
no_default_libraries: false,
3034
has_thread_local: true,
3135

0 commit comments

Comments
 (0)