I agree it makes more sense that way. This would be less surprising for new users, but it is a change for existing users, which worries me a little. But, still worth doing I think, I pushed it to incoming.
To summarize for other people reading this, the change is that -Os and -Oz when compiling to JS will now do our very best to reduce code size, including running slow js optimizer passes that reduce code size. This means that people building to JS with -Os or -Oz will get reduced code size, at the cost of slower compilation speed, similar to -O3 when compiling to JS. Unchanged is the behavior of -Os and -Oz when building source to object/bitcode, those tell LLVM to reduce size. - Alon On Fri, Feb 27, 2015 at 11:41 AM, Boris Gjenero <boris.gjen...@gmail.com> wrote: > Since -Oz is documented as the option for optimizing for smaller code > size, I would expect it to produce smaller JS than -O3. Instead, the > following usage consistently produces the smallest JS size: > emcc -Oz -c file.c -o file.o > emcc -O3 file.o -o file.html > (This is just an example for clarification. I was testing with projects > containing many source files.) > > The -O3 size decrease is due to use of 'registerizeHarder' instead of > 'registerize'. I assume this is the "better regalloc" you mentioned. > > On 2015-02-26 06:56 PM, Alon Zakai wrote: > >> Ah, are you saying that you would expect -Oz to produce smaller JS than >> -O3? That's a good point. Right now we have -Oz as equal to -O2, plus >> some size reducing stuff (I think none of which matters at link time). >> But -O3 adds better regalloc, which does reduce code size. So perhaps >> during link we should have -Os and -Oz also apply the better regalloc? >> >> - Alon >> >> >> On Thu, Feb 26, 2015 at 8:38 AM, Boris Gjenero <boris.gjen...@gmail.com >> <mailto:boris.gjen...@gmail.com>> wrote: >> >> I tried building several different programs with memory growth >> enabled and disabled, and there were no surprises. The biggest >> increase was 0.57% with Acidwarp, which is small. Big stuff is >> increased by around 0.15%. >> >> There was another surprise however. Smallest code size is produced >> by compiling to bytecode with -Oz and doing the final link with -O3. >> Typically this should be possible if you put -Oz in CFLAGS/CXXFLAGS >> and -O3 in LDFLAGS, because LDFLAGS come later in the command line >> and will override the -Oz. Using -Oz for the final link produces >> larger JS than -O3. With --closure 1, JS is even smaller, but that >> breaks stuff. >> > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to emscripten-discuss+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.