Why does the IDE call avr-g++ 5 times in succession with the same parameters

I'm compiling the below test sketch for an Uno under IDE 1.6.6 on Win8 64 bit

void setup() {
  // put your setup code here, to run once:
  Serial.begin{9600);
  Serial.println("Hello world");

}

void loop() {
  // put your main code here, to run repeatedly:

}

The first few lines of the (verbose) output are

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\Wim Sturkenboom\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -vid-pid=0X2A03_0X0043 -ide-version=10606 -build-path "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Wim Sturkenboom\Documents\Arduino\sketch_jun17a\sketch_jun17a.ino"
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\Wim Sturkenboom\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -vid-pid=0X2A03_0X0043 -ide-version=10606 -build-path "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Wim Sturkenboom\Documents\Arduino\sketch_jun17a\sketch_jun17a.ino"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -M -MG -MP -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp\sketch\sketch_jun17a.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -M -MG -MP -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp\sketch\sketch_jun17a.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -M -MG -MP -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp\sketch\sketch_jun17a.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -M -MG -MP -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp\sketch\sketch_jun17a.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -M -MG -MP -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp\sketch\sketch_jun17a.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\WIMSTU~1\AppData\Local\Temp\build4ed00942a0b3b98f45de0f01f43a20ed.tmp\sketch\sketch_jun17a.ino.cpp"

Lines 3..7 are exactly the same. There might be other sections like that, but this was the obvious part in a 28k output.

Why does the IDE call avr-g++ 5 times with the same parameters?

If you need more info, please let me know.

PS: this happens for any sketch that I compile.

It's explained here: Redirecting to Google Groups

This is the technique used by arduino-builder(which was added in Arduino IDE 1.6.6) for detecting library dependencies.

As that thread states, the efficiency of this process was improved in IDE versions after 1.6.6 by adding the -E flag to avoid actually compiling in that step. I would recommend you to upgrade to IDE 1.6.9 if you want to use any version after 1.6.5-r5, the last pre-arduino-builder version.

Thanks pert,

at least it explains.