File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -1072,6 +1072,13 @@ pub fn link_args(sess: Session,
1072
1072
args. push ( "-L" + path. as_str ( ) . unwrap ( ) . to_owned ( ) ) ;
1073
1073
}
1074
1074
1075
+ if sess. targ_cfg . os == abi:: OsLinux {
1076
+ // GNU-style linkers will use this to omit linking to libraries which don't actually fulfill
1077
+ // any relocations, but only for libraries which follow this flag. Thus, use it before
1078
+ // specifing libraries to link to.
1079
+ args. push ( ~"-Wl , --as-needed") ;
1080
+ }
1081
+
1075
1082
// The names of the extern libraries
1076
1083
let used_libs = cstore:: get_used_libraries ( cstore) ;
1077
1084
for l in used_libs. iter ( ) { args. push ( ~"-l" + * l) ; }
@@ -1091,6 +1098,12 @@ pub fn link_args(sess: Session,
1091
1098
// On linux librt and libdl are an indirect dependencies via rustrt,
1092
1099
// and binutils 2.22+ won't add them automatically
1093
1100
if sess. targ_cfg . os == abi:: OsLinux {
1101
+ // GNU-style linkers supports optimization with -O. --gc-sections removes metadata and
1102
+ // potentially other useful things, so don't include it.
1103
+ if sess. opts . optimize == session:: Default || sess. opts . optimize == session:: Aggressive {
1104
+ args. push ( ~"-Wl , -O ") ;
1105
+ }
1106
+
1094
1107
args. push_all ( [ ~"-lrt", ~"-ldl"] ) ;
1095
1108
1096
1109
// LLVM implements the `frem` instruction as a call to `fmod`,
You can’t perform that action at this time.
0 commit comments