(Re)Compile only what is changed

43 views
Skip to first unread message

Emanuele Palombo

unread,
Jan 15, 2015, 6:38:02 AM1/15/15
to emscripte...@googlegroups.com
I have a huge C++ project and the compilation time is too long.

Can I recompile only the file that I change?

I have find old Static Linking (https://github.com/kripken/emscripten/wiki/Linking)...but I think is not a good solution.

Alon Zakai

unread,
Jan 15, 2015, 4:11:27 PM1/15/15
to emscripte...@googlegroups.com
Compiling bitcode to JS is done as a whole. There isn't an option currently to build to separate JS files.
in particular, recent emscripten versions are much faster thanks to the native optimizer mentioned there, so worth verifying you are on a recent version and that the native optimizer is in effect (see faq entry).

- Alon


--
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-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emanuele Palombo

unread,
Jan 16, 2015, 3:51:34 AM1/16/15
to emscripte...@googlegroups.com
Thanks for your reply and explanation!

I already follow all suggestions on the faq you have linked...and I compile on a i7 with 4+4 core.

I think that my project is really huge, the final js file compiled is 24MB (without optimization).

I'll wait the needed compile time (2-3 min)

thanks again
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Jan 16, 2015, 2:59:06 PM1/16/15
to emscripte...@googlegroups.com
2-3 minutes does seem quite high. If you want, paste the output of EMCC_DEBUG=1 when building to JS, perhaps the timing info there will show something surprising to me.

- Alon


To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Emanuele Palombo

unread,
Jan 16, 2015, 3:42:25 PM1/16/15
to emscripte...@googlegroups.com
Again, the project is quite big, I'm trying to compile OGDF lib + Coin-OF

---------------------------------debug log stripped----------------------------
[...]
DEBUG    root: emcc step "bitcodeize inputs" took 198.11 seconds
DEBUG    root: emcc step "process inputs" took 0.00 seconds
DEBUG    root: will generate JavaScript
DEBUG    root: including libcxx
DEBUG    root: including libcextra
DEBUG    root: including libcxxabi
DEBUG    root: including libc
DEBUG    root: emcc step "calculate system libraries" took 4.38 seconds
[...]
DEBUG    root: using response file for llvm-link
DEBUG    root: emcc step "link" took 4.71 seconds
DEBUG    root: saving intermediate processing steps to /tmp/emscripten_temp
DEBUG    root: emcc: LLVM opts: -strip-debug -disable-internalize -internalize -internalize-public-api-list=main,malloc,free,malloc,free,__cxa_can_catch,__cxa_is_pointer_type,malloc,malloc,free,malloc -std-link-opts -disable-vectorize
DEBUG    root: emcc: LLVM opts: -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt -enable-emscripten-cxx-exceptions -disable-vectorize
DEBUG    root: emcc step "post-link" took 26.40 seconds
DEBUG    root: LLVM => JS
DEBUG    root: PYTHON not defined in ~/.emscripten, using "/usr/bin/python2"
DEBUG    root: JAVA not defined in ~/.emscripten, using "java"
[...]
DEBUG    root:   emscript: glue took 0.324043989182 seconds
DEBUG    root: asm text sizes[[26897513, 19044, 25], 56695, 1555, 19376, 0, 17620, 984398, 3600, 234, 17495, 16231]
DEBUG    root:   emscript: final python processing took 0.419142961502 seconds
DEBUG    root: emcc step "emscript (llvm=>js)" took 4.79 seconds
DEBUG    root: optimizing memory initialization
DEBUG    root: emcc step "source transforms" took 0.17 seconds
DEBUG    root: emcc step "js opts" took 0.00 seconds
DEBUG    root: emcc step "final emitting" took 0.06 seconds
DEBUG    root: total time: 238.64 seconds

Ciao!

You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/YVJgSx9OXiA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

Emanuele Palombo

unread,
Jan 16, 2015, 3:42:36 PM1/16/15
to emscripte...@googlegroups.com
thanks!

On 16 January 2015 at 20:59, Alon Zakai <alon...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/YVJgSx9OXiA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

Emanuele Palombo

unread,
Jan 16, 2015, 3:44:03 PM1/16/15
to emscripte...@googlegroups.com
On Friday, 16 January 2015 20:59:06 UTC+1, Alon Zakai wrote:
2-3 minutes does seem quite high. If you want, paste the output of EMCC_DEBUG=1 when building to JS, perhaps the timing info there will show something surprising to me.

- Alon

On Fri, Jan 16, 2015 at 12:51 AM, Emanuele Palombo <emanuele...@gmail.com> wrote:
Thanks for your reply and explanation!

I already follow all suggestions on the faq you have linked...and I compile on a i7 with 4+4 core.

I think that my project is really huge, the final js file compiled is 24MB (without optimization).

I'll wait the needed compile time (2-3 min)

thanks again

On Thursday, 15 January 2015 22:11:27 UTC+1, Alon Zakai wrote:
Compiling bitcode to JS is done as a whole. There isn't an option currently to build to separate JS files.
in particular, recent emscripten versions are much faster thanks to the native optimizer mentioned there, so worth verifying you are on a recent version and that the native optimizer is in effect (see faq entry).

- Alon

On Thu, Jan 15, 2015 at 3:38 AM, Emanuele Palombo <emanuele...@gmail.com> wrote:
I have a huge C++ project and the compilation time is too long.

Can I recompile only the file that I change?

I have find old Static Linking (https://github.com/kripken/emscripten/wiki/Linking)...but I think is not a good solution.

--
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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Alon Zakai

unread,
Jan 16, 2015, 5:55:08 PM1/16/15
to emscripte...@googlegroups.com
Almost all the time is spent in bitcodeize inputs. That means turning C or C++ source into bitcode. Are you running a command like this

emcc a.cpp b.cpp c.cpp ...   -o out.js

? If so, that explains why it's slow. Instead, create a makefile (or use cmake etc.), so you only compile source to bitcode if the source file actually changed. Then the final command should be

emcc a.o b.o c.o ... -o out.js

- Alon


Emanuele Palombo

unread,
Jan 17, 2015, 6:11:22 AM1/17/15
to emscripte...@googlegroups.com
Great!

...but I'm noob on this stuffs.

Correct an suggest me if you can...With *.o file, will I use static linking during compilation time?

I have try to read: http://kripken.github.io/emscripten-site/docs/compiling/Building-Projects.html, but OGDF (the C++ project that I'm trying to compile) don't have ./configure, and generate the make file through a "magic" python script (makeMakefile.py).

I don't understand, *.o file should be compiled with emcc or can I compile it with OGDF built-in make file and use after with emcc?

Could you post me some links to understand better?


To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@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+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/YVJgSx9OXiA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Emanuele Palombo

unread,
Jan 17, 2015, 9:57:46 AM1/17/15
to emscripte...@googlegroups.com
I have created this makefile (I have to refine it):

COIN_CPP=src/coin/Cgl/CglAllDifferent.cpp src/coin/Cgl/CglClique.cpp [...] src/coin/OsiClp/OsiClpSolverInterface.cpp
OGDF_CPP=src/ogdf/basic/Math.cpp src/ogdf/basic/Graph.cpp [...] src/ogdf/energybased/MAARPacking.cpp
COIN_OBJECT=$(COIN_CPP:.cpp=.o)
OGDF_OBJECT=$(OGDF_CPP:.cpp=.o)
OTPIMIZATION = -O3
ifeq ($(NOPT),1)
  OTPIMIZATION=
endif

all: coin ogdf bind
coin: $(COIN_CPP)
$(foreach cpp,$(COIN_CPP),$(CC) --bind $(OTPIMIZATION) --memory-init-file 0 $(COIN_PREPOCESSOR_DIRECTIVES) $(COIN_INCLUDE_PATH) $(cpp) -c -o $(cpp:.cpp=.o);)
ogdf:
@$(foreach cpp,$(OGDF_CPP),$(CC) --bind $(OTPIMIZATION) --memory-init-file 0 $(OGDF_PREPOCESSOR_DIRECTIVES) $(OGDF_INCLUDE_PATH) $(cpp) -c -o $(cpp:.cpp=.o);)
bind: $(COIN_OBJECT) $(OGDF_OBJECT)
$(CC) --bind $(OTPIMIZATION) --memory-init-file 0 $(COIN_OBJECT) $(OGDF_OBJECT) src/ogdf.js/bindings/bindings.cpp $(OGDF_INCLUDE_PATH) -o $(OUTPUT_JS)
clean:
@echo "Cleaning Coin..."
@$(foreach object,$(COIN_OBJECT),rm -f $(object))
@echo "Cleaning OGDF..."
@$(foreach object,$(OGDF_OBJECT),rm -f $(object))
@rm -f $(OUTPUT_JS)


but I continue to think that it's not the right way...

Alon Zakai

unread,
Jan 17, 2015, 4:16:55 PM1/17/15
to emscripte...@googlegroups.com
That is the best link on the topic.

This is basically the same as native building, except your .o files contain bitcode instead of native object code. But you can still link them (emcc a.o b.o -o c.o links a and b into c) and so forth - you can basically forget that they contain bitcode. So a build system can track when source files it needs to build to .o and which are unchanged, exactly the same as a native build. In fact you can usually use the exact same makefile and so forth, only changing the compiler to use emcc, and adding a final command to compile the final linked bitcode file containing everything into JS.

- Alon


To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Emanuele Palombo

unread,
Jan 18, 2015, 5:15:42 AM1/18/15
to emscripte...@googlegroups.com
Thanks Alon for your time and explanation...now it's all more clear!

p.s. I thought, could  be more clear if the output of "emcc a.cpp -c" will be a.bc (and not a.o as default)
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/YVJgSx9OXiA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages