Skip to content

Commit a0f8765

Browse files
committed
Add option to use a single section for each function
1 parent e5437b6 commit a0f8765

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ function jit_calc() {
7070
object files when their content should have been changed by a change to cg_clif.</dd>
7171
<dt>CG_CLIF_DISPLAY_CG_TIME</dt>
7272
<dd>If "1", display the time it took to perform codegen for a crate</dd>
73+
<dt>CG_CLIF_FUNCTION_SECTIONS</dt>
74+
<dd>Use a single section for each function. This will often reduce the executable size at the
75+
cost of making linking significantly slower.</dd>
7376
</dl>
7477

7578
## Not yet supported

src/backend.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,17 @@ pub(crate) type Backend =
186186
impl cranelift_module::Backend<Product: AddConstructor + Emit + WriteDebugInfo>;
187187

188188
pub(crate) fn make_module(sess: &Session, name: String) -> Module<Backend> {
189+
let mut builder = ObjectBuilder::new(
190+
crate::build_isa(sess, true),
191+
name + ".o",
192+
cranelift_module::default_libcall_names(),
193+
)
194+
.unwrap();
195+
if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() {
196+
builder.per_function_section(true);
197+
}
189198
let module: Module<ObjectBackend> = Module::new(
190-
ObjectBuilder::new(
191-
crate::build_isa(sess, true),
192-
name + ".o",
193-
cranelift_module::default_libcall_names(),
194-
)
195-
.unwrap(),
199+
builder,
196200
);
197201
module
198202
}

0 commit comments

Comments
 (0)