Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c067be0

Browse files
committed
Implement -Zfunction-sections
1 parent 114be42 commit c067be0

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

docs/env_vars.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@
99
object files when their content should have been changed by a change to cg_clif.</dd>
1010
<dt>CG_CLIF_DISPLAY_CG_TIME</dt>
1111
<dd>If "1", display the time it took to perform codegen for a crate</dd>
12-
<dt>CG_CLIF_FUNCTION_SECTIONS</dt>
13-
<dd>Use a single section for each function. This will often reduce the executable size at the
14-
cost of making linking significantly slower.</dd>
1512
</dl>

src/backend.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule {
198198
cranelift_module::default_libcall_names(),
199199
)
200200
.unwrap();
201-
if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() {
202-
builder.per_function_section(true);
203-
}
201+
// Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
202+
// is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections
203+
// can easily double the amount of time necessary to perform linking.
204+
builder.per_function_section(sess.opts.debugging_opts.function_sections.unwrap_or(false));
204205
ObjectModule::new(builder)
205206
}

0 commit comments

Comments
 (0)