"system linker to link outputs with"),
link_args: Option<Vec<String>> = (None, parse_opt_list,
"extra arguments to pass to the linker (space separated)"),
+ link_dead_code: bool = (false, parse_bool,
+ "let the linker strip dead coded (turning it on can be used for code coverage)"),
lto: bool = (false, parse_bool,
"perform LLVM link-time optimizations"),
target_cpu: Option<String> = (None, parse_opt_string,
// Try to strip as much out of the generated object by removing unused
// sections if possible. See more comments in linker.rs
- cmd.gc_sections(dylib);
+ if !sess.opts.cg.link_dead_code {
+ cmd.gc_sections(dylib);
+ }
let used_link_args = sess.cstore.used_link_args();
$(RUSTC) -C lto=foo dummy.rs 2>&1 | \
grep 'codegen option `lto` takes no value'
$(RUSTC) -C lto dummy.rs
+
+ # Should not link dead code...
+ $(RUSTC) -Z print-link-args dummy.rs 2>&1 | \
+ grep -e '--gc-sections\|-dead_strip\|/OPT:REF,ICF'
+ # ... unless you specifically ask to keep it
+ $(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \
+ (! grep -e '--gc-sections\|-dead_strip\|/OPT:REF,ICF')