]> git.lizzy.rs Git - rust.git/commitdiff
add -Z pre-link-arg{,s} to rustc
authorJorge Aparicio <jorge@japaric.io>
Sat, 13 May 2017 13:21:24 +0000 (08:21 -0500)
committerJorge Aparicio <jorge@japaric.io>
Sat, 13 May 2017 14:26:55 +0000 (09:26 -0500)
This commit adds two unstable flags to `rustc`: `-Z pre-link-arg` and `-Z
pre-link-args`. These are the counterpart of the existing `-C link-arg{,s}`
flags and can be used to pass extra arguments at the *beginning* of the linker
invocation, before the Rust object files are passed.

src/librustc/session/config.rs
src/librustc_trans/back/link.rs

index 884a71f0d32d4b24c983cb9049ca4ba819a9f26d..79bb20599ca1a741ae33364fae8048bd762c8465 100644 (file)
@@ -824,9 +824,9 @@ fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) ->
     linker: Option<String> = (None, parse_opt_string, [UNTRACKED],
         "system linker to link outputs with"),
     link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
-        "a single extra argument to pass to the linker (can be used several times)"),
+        "a single extra argument to append to the linker invocation (can be used several times)"),
     link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
-        "extra arguments to pass to the linker (space separated)"),
+        "extra arguments to append to the linker invocation (space separated)"),
     link_dead_code: bool = (false, parse_bool, [UNTRACKED],
         "don't let linker strip dead code (turning it on can be used for code coverage)"),
     lto: bool = (false, parse_bool, [TRACKED],
@@ -1029,6 +1029,10 @@ fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) ->
         "add a mapping target to the file path remapping config"),
     force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
         "force all crates to be `rustc_private` unstable"),
+    pre_link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
+        "a single extra argument to prepend the linker invocation (can be used several times)"),
+    pre_link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
+        "extra arguments to prepend to the linker invocation (space separated)"),
 }
 
 pub fn default_lib_output() -> CrateType {
index e42e69d2a76e27979718317626a86ee2a51df1de..d1000a574b526a8290cd97460666c621e04d13de 100644 (file)
@@ -714,6 +714,10 @@ fn link_natively(sess: &Session,
     if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) {
         cmd.args(args);
     }
+    if let Some(ref args) = sess.opts.debugging_opts.pre_link_args {
+        cmd.args(args);
+    }
+    cmd.args(&sess.opts.debugging_opts.pre_link_arg);
 
     let pre_link_objects = if crate_type == config::CrateTypeExecutable {
         &sess.target.target.options.pre_link_objects_exe