File tree 3 files changed +24
-1
lines changed
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -1084,6 +1084,17 @@ fn link_args(sess: Session,
1084
1084
args. push ( metadata. as_str ( ) . unwrap ( ) . to_owned ( ) ) ;
1085
1085
}
1086
1086
1087
+ // We want to prevent the compiler from accidentally leaking in any system
1088
+ // libraries, so we explicitly ask gcc to not link to any libraries by
1089
+ // default. Note that this does not happen for windows because windows pulls
1090
+ // in some large number of libraries and I couldn't quite figure out which
1091
+ // subset we wanted.
1092
+ //
1093
+ // FIXME(#11937) we should invoke the system linker directly
1094
+ if sess. targ_cfg . os != abi:: OsWin32 {
1095
+ args. push ( ~"-nodefaultlibs") ;
1096
+ }
1097
+
1087
1098
if sess. targ_cfg . os == abi:: OsLinux {
1088
1099
// GNU-style linkers will use this to omit linking to libraries which
1089
1100
// don't actually fulfill any relocations, but only for libraries which
Original file line number Diff line number Diff line change @@ -143,6 +143,16 @@ mod libunwind {
143
143
pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn ( unwind_code : _Unwind_Reason_Code ,
144
144
exception : * _Unwind_Exception ) ;
145
145
146
+ #[ cfg( target_os = "linux" ) ]
147
+ #[ cfg( target_os = "freebsd" ) ]
148
+ #[ cfg( target_os = "win32" ) ]
149
+ #[ link( name = "gcc_s" ) ]
150
+ extern { }
151
+
152
+ #[ cfg( target_os = "android" ) ]
153
+ #[ link( name = "gcc" ) ]
154
+ extern { }
155
+
146
156
extern "C" {
147
157
pub fn _Unwind_RaiseException ( exception : * _Unwind_Exception ) -> _Unwind_Reason_Code ;
148
158
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" ) ]
@@ -31,6 +32,7 @@ extern {}
31
32
#[ link( name = "dl" ) ]
32
33
#[ link( name = "log" ) ]
33
34
#[ link( name = "m" ) ]
35
+ #[ link( name = "c" ) ]
34
36
extern { }
35
37
36
38
#[ cfg( target_os = "freebsd" ) ]
@@ -39,5 +41,5 @@ extern {}
39
41
extern { }
40
42
41
43
#[ cfg( target_os = "macos" ) ]
42
- #[ link( name = "pthread " ) ]
44
+ #[ link( name = "System " ) ]
43
45
extern { }
You can’t perform that action at this time.
0 commit comments