Skip to content

Commit

Permalink
Update /NODEFAUTLIB comment for msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Mar 11, 2024
1 parent 65cd843 commit aeec0d1
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions compiler/rustc_target/src/spec/base/windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit aeec0d1

Please sign in to comment.