about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-20 15:30:04 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-20 15:30:04 +0000
commitd740a3f06a4e32b72383bdf3b60d9855fa80bb61 (patch)
tree8069ab3c653a49d91c7650d2b6eaa06268f09566 /compiler/rustc_codegen_cranelift/src
parentb5741a36a897dd93936d31ea0c1688f1399a2e06 (diff)
parent728bc27f32c05ac8a9b5eb33fd101e479072984f (diff)
downloadrust-d740a3f06a4e32b72383bdf3b60d9855fa80bb61.tar.gz
rust-d740a3f06a4e32b72383bdf3b60d9855fa80bb61.zip
Merge commit '728bc27f32c05ac8a9b5eb33fd101e479072984f' into sync_cg_clif-2025-01-20
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src')
-rw-r--r--compiler/rustc_codegen_cranelift/src/driver/aot.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs
index fe578e44770..7d5592daac1 100644
--- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs
+++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs
@@ -333,9 +333,17 @@ fn make_module(sess: &Session, name: String) -> UnwindModule<ObjectModule> {
 
     let mut builder =
         ObjectBuilder::new(isa, name + ".o", cranelift_module::default_libcall_names()).unwrap();
+
+    // Disable function sections by default on MSVC as it causes significant slowdowns with link.exe.
+    // Maybe link.exe has exponential behavior when there are many sections with the same name? Also
+    // explicitly disable it on MinGW as rustc already disables it by default on MinGW and as such
+    // isn't tested. If rustc enables it in the future on MinGW, we can re-enable it too once it has
+    // been on MinGW.
+    let default_function_sections = sess.target.function_sections && !sess.target.is_like_windows;
     builder.per_function_section(
-        sess.opts.unstable_opts.function_sections.unwrap_or(sess.target.function_sections),
+        sess.opts.unstable_opts.function_sections.unwrap_or(default_function_sections),
     );
+
     UnwindModule::new(ObjectModule::new(builder), true)
 }