This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +23
-19
lines changed
librustc_codegen_ssa/back Expand file tree Collapse file tree 5 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -1532,13 +1532,8 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
1532
1532
cmd. debuginfo ( ) ;
1533
1533
1534
1534
// OBJECT-FILES-NO, AUDIT-ORDER
1535
- // We want to, by default, prevent the compiler from accidentally leaking in
1536
- // any system libraries, so we may explicitly ask linkers to not link to any
1537
- // libraries by default. Note that this does not happen for windows because
1538
- // windows pulls in some large number of libraries and I couldn't quite
1539
- // figure out which subset we wanted.
1540
- //
1541
- // This is all naturally configurable via the standard methods as well.
1535
+ // We want to prevent the compiler from accidentally leaking in any system libraries,
1536
+ // so by default we tell linkers not to link to any default libraries.
1542
1537
if !sess. opts . cg . default_linker_libraries . unwrap_or ( false )
1543
1538
&& sess. target . target . options . no_default_libraries
1544
1539
{
Original file line number Diff line number Diff line change @@ -631,15 +631,7 @@ impl<'a> Linker for MsvcLinker<'a> {
631
631
}
632
632
633
633
fn no_default_libraries ( & mut self ) {
634
- // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC
635
- // as there's been trouble in the past of linking the C++ standard
636
- // library required by LLVM. This likely needs to happen one day, but
637
- // in general Windows is also a more controlled environment than
638
- // Unix, so it's not necessarily as critical that this be implemented.
639
- //
640
- // Note that there are also some licensing worries about statically
641
- // linking some libraries which require a specific agreement, so it may
642
- // not ever be possible for us to pass this flag.
634
+ self . cmd . arg ( "/NODEFAULTLIB" ) ;
643
635
}
644
636
645
637
fn include_path ( & mut self , path : & Path ) {
Original file line number Diff line number Diff line change @@ -23,9 +23,6 @@ pub fn opts() -> TargetOptions {
23
23
// will fail if the compiler ever tries placing code on the stack (e.g., trampoline
24
24
// constructs and alike).
25
25
"/NXCOMPAT" . to_string( ) ,
26
- // There is no runtime for UEFI targets, prevent them from being linked. UEFI targets
27
- // must be freestanding.
28
- "/nodefaultlib" . to_string( ) ,
29
26
// Non-standard subsystems have no default entry-point in PE+ files. We have to define
30
27
// one. "efi_main" seems to be a common choice amongst other implementations and the
31
28
// spec.
Original file line number Diff line number Diff line change @@ -30,6 +30,16 @@ pub fn opts() -> TargetOptions {
30
30
abi_return_struct_as_int : true ,
31
31
emit_debug_gdb_scripts : false ,
32
32
requires_uwtable : true ,
33
+ // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC
34
+ // as there's been trouble in the past of linking the C++ standard
35
+ // library required by LLVM. This likely needs to happen one day, but
36
+ // in general Windows is also a more controlled environment than
37
+ // Unix, so it's not necessarily as critical that this be implemented.
38
+ //
39
+ // Note that there are also some licensing worries about statically
40
+ // linking some libraries which require a specific agreement, so it may
41
+ // not ever be possible for us to pass this flag.
42
+ no_default_libraries : false ,
33
43
34
44
..Default :: default ( )
35
45
}
Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ pub fn opts() -> TargetOptions {
31
31
emit_debug_gdb_scripts : false ,
32
32
requires_uwtable : true ,
33
33
lld_flavor : LldFlavor :: Link ,
34
+ // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC
35
+ // as there's been trouble in the past of linking the C++ standard
36
+ // library required by LLVM. This likely needs to happen one day, but
37
+ // in general Windows is also a more controlled environment than
38
+ // Unix, so it's not necessarily as critical that this be implemented.
39
+ //
40
+ // Note that there are also some licensing worries about statically
41
+ // linking some libraries which require a specific agreement, so it may
42
+ // not ever be possible for us to pass this flag.
43
+ no_default_libraries : false ,
34
44
35
45
..Default :: default ( )
36
46
}
You can’t perform that action at this time.
0 commit comments