Skip to content

Commit da12e56

Browse files
committed
Disable -Zfunction-sections by default on MSVC
To workaround a hang in link.exe.
1 parent a642651 commit da12e56

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/driver/aot.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,11 @@ fn make_module(sess: &Session, name: String) -> UnwindModule<ObjectModule> {
333333

334334
let mut builder =
335335
ObjectBuilder::new(isa, name + ".o", cranelift_module::default_libcall_names()).unwrap();
336+
// Disable function sections by default on MSVC as it causes significant with link.exe. Maybe
337+
// link.exe has exponential behavior when there are many sections with the same name?
338+
let default_function_sections = sess.target.function_sections && !sess.target.is_like_msvc;
336339
builder.per_function_section(
337-
sess.opts.unstable_opts.function_sections.unwrap_or(sess.target.function_sections),
340+
sess.opts.unstable_opts.function_sections.unwrap_or(default_function_sections),
338341
);
339342
UnwindModule::new(ObjectModule::new(builder), true)
340343
}

0 commit comments

Comments
 (0)