1
Fork 0

Implement -Zfunction-sections

This commit is contained in:
bjorn3 2020-10-31 10:13:35 +01:00
parent 114be422ef
commit c067be07c1
2 changed files with 4 additions and 6 deletions

View file

@ -9,7 +9,4 @@
object files when their content should have been changed by a change to cg_clif.</dd> object files when their content should have been changed by a change to cg_clif.</dd>
<dt>CG_CLIF_DISPLAY_CG_TIME</dt> <dt>CG_CLIF_DISPLAY_CG_TIME</dt>
<dd>If "1", display the time it took to perform codegen for a crate</dd> <dd>If "1", display the time it took to perform codegen for a crate</dd>
<dt>CG_CLIF_FUNCTION_SECTIONS</dt>
<dd>Use a single section for each function. This will often reduce the executable size at the
cost of making linking significantly slower.</dd>
</dl> </dl>

View file

@ -198,8 +198,9 @@ pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule {
cranelift_module::default_libcall_names(), cranelift_module::default_libcall_names(),
) )
.unwrap(); .unwrap();
if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() { // Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
builder.per_function_section(true); // is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections
} // can easily double the amount of time necessary to perform linking.
builder.per_function_section(sess.opts.debugging_opts.function_sections.unwrap_or(false));
ObjectModule::new(builder) ObjectModule::new(builder)
} }