]> git.lizzy.rs Git - rust.git/commitdiff
Turn off Vectorization for Emscripten
authorChristopher Serr <christopher.serr@gmail.com>
Mon, 20 Feb 2017 22:20:06 +0000 (23:20 +0100)
committerChristopher Serr <christopher.serr@gmail.com>
Mon, 20 Feb 2017 22:29:02 +0000 (23:29 +0100)
When targeting Emscripten, rustc emits Vector Instructions by default.
However Web Assembly doesn't support Vector Instructions yet, which
causes Binaryen to fail converting the intermediate asm.js code to Web
Assembly. While asm.js kind of supports Vector Instructions, they
aren't supported by any browser other than Firefox, often meaning that
they need to be emulated very slowly. So it should just be turned off
for all Emscripten targets.

Fixes #38558

src/librustc_trans/back/write.rs

index b717254ef0d25aa6c35ccd27ff90aab06d2b928a..40a69721495b8394ec797c0bb09d3f265a6600a9 100644 (file)
@@ -315,11 +315,15 @@ fn set_flags(&mut self, sess: &Session, trans: &CrateTranslation) {
         // Copy what clang does by turning on loop vectorization at O2 and
         // slp vectorization at O3. Otherwise configure other optimization aspects
         // of this pass manager builder.
+        // Turn off vectorization for emscripten, as it's not very well supported.
         self.vectorize_loop = !sess.opts.cg.no_vectorize_loops &&
                              (sess.opts.optimize == config::OptLevel::Default ||
-                              sess.opts.optimize == config::OptLevel::Aggressive);
+                              sess.opts.optimize == config::OptLevel::Aggressive) &&
+                             !sess.target.target.options.is_like_emscripten;
+
         self.vectorize_slp = !sess.opts.cg.no_vectorize_slp &&
-                            sess.opts.optimize == config::OptLevel::Aggressive;
+                            sess.opts.optimize == config::OptLevel::Aggressive &&
+                            !sess.target.target.options.is_like_emscripten;
 
         self.merge_functions = sess.opts.optimize == config::OptLevel::Default ||
                                sess.opts.optimize == config::OptLevel::Aggressive;