File tree 3 files changed +19
-1
lines changed
3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1091,6 +1091,17 @@ fn link_args(sess: Session,
1091
1091
args. push ( metadata. as_str ( ) . unwrap ( ) . to_owned ( ) ) ;
1092
1092
}
1093
1093
1094
+ // We want to prevent the compiler from accidentally leaking in any system
1095
+ // libraries, so we explicitly ask gcc to not link to any libraries by
1096
+ // default. Note that this does not happen for windows because windows pulls
1097
+ // in some large number of libraries and I couldn't quite figure out which
1098
+ // subset we wanted.
1099
+ //
1100
+ // FIXME(#11937) we should invoke the system linker directly
1101
+ if sess. targ_cfg . os != abi:: OsWin32 {
1102
+ args. push ( ~"-nodefaultlibs") ;
1103
+ }
1104
+
1094
1105
if sess. targ_cfg . os == abi:: OsLinux {
1095
1106
// GNU-style linkers will use this to omit linking to libraries which
1096
1107
// don't actually fulfill any relocations, but only for libraries which
Original file line number Diff line number Diff line change @@ -142,6 +142,12 @@ mod libunwind {
142
142
pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn ( unwind_code : _Unwind_Reason_Code ,
143
143
exception : * _Unwind_Exception ) ;
144
144
145
+ #[ cfg( target_os = "linux" ) ]
146
+ #[ cfg( target_os = "freebsd" ) ]
147
+ #[ cfg( target_os = "win32" ) ]
148
+ #[ link( name = "gcc_s" ) ]
149
+ extern { }
150
+
145
151
extern "C" {
146
152
pub fn _Unwind_RaiseException ( exception : * _Unwind_Exception ) -> _Unwind_Reason_Code ;
147
153
pub fn _Unwind_DeleteException ( exception : * _Unwind_Exception ) ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ extern {}
22
22
// On linux librt and libdl are indirect dependencies via rustrt,
23
23
// and binutils 2.22+ won't add them automatically
24
24
#[ cfg( target_os = "linux" ) ]
25
+ #[ link( name = "c" ) ]
25
26
#[ link( name = "dl" ) ]
26
27
#[ link( name = "m" ) ]
27
28
#[ link( name = "pthread" ) ]
@@ -39,5 +40,5 @@ extern {}
39
40
extern { }
40
41
41
42
#[ cfg( target_os = "macos" ) ]
42
- #[ link( name = "pthread " ) ]
43
+ #[ link( name = "System " ) ]
43
44
extern { }
You can’t perform that action at this time.
0 commit comments