When I compile around 1700 files using make -j, it takes 13 minutes on an 8-core PC with 100% CPU load, whereas on a 56-core server, it takes 7 minutes but with only 10% CPU load.
Use MINGW64, PowerShell, CMD, all the same result.
This is my makefile target and command section fragment:
#######################################
# build the application
#######################################
all: all-build
@(
tTime=$$(($$(date +%s) - $(START_TIME)));
if [ $$tTime -lt 60 ]; then
echo "Build Finished (took $$(($$tTime))s)";
else
echo "Build Finished (took $$(($$tTime / 60))m:$$(($$tTime % 60))s)";
fi
)
@echo ' '
all-build:
$(MAKE) -f $(THIS_MAKEFILE) --no-print-directory $(BUILD_DIR)/$(TARGET)
$(BUILD_DIR)/$(TARGET_BASENAME).elf: $(BUILD_DIR)/ld.args
@mkdir -p $(@D)
@echo '[LD]: $@'
$(CC) "@$(BUILD_DIR)/ld.args" -o $@
@echo 'Finished building target: $@'
@echo ' '
ifneq (, $(DST_DIR))
ifneq (, $(DST_JSON))
$(MAKE) -f $(THIS_MAKEFILE) --no-print-directory post-build-elf
endif
endif
@echo '[SZ]: $@'
$(SZ) --format=berkeley $@
@echo ' '
$(BUILD_DIR)/%.o: $(CURDIR)/%.c $(BUILD_DIR)/cc.args
@mkdir -p $(@D)
@echo '[CC]: $<'
$(CC) "@$(BUILD_DIR)/cc.args" -MD -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
$(BUILD_DIR)/%.o: $(CURDIR)/%.s $(BUILD_DIR)/as.args
@mkdir -p $(@D)
@echo '[AS]: $<'
$(CC) "@$(BUILD_DIR)/as.args" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
$(BUILD_DIR):
@mkdir -p $@
post-build-elf:
ifneq ($(CC_BIN), ccarm)
$(dir $(CURDIR)/$(THIS_MAKEFILE))/PostBuild.bat
$(DST_DIR) $(DST_JSON) $(BUILD_DIR)/ $(TARGET_BASENAME) $(CC_PATH) $(PREFIX) $(user_postbuild) $(arg_postbuild)
else
$(dir $(CURDIR)/$(THIS_MAKEFILE))/PostBuild.bat
$(DST_DIR) $(DST_JSON) $(BUILD_DIR)/ $(TARGET_BASENAME) $(CC_PATH_s32k3xx_gcc) $(PREFIX) $(user_postbuild) $(arg_postbuild)
endif
@echo ' '
8-core PC cpu load
56-core server cpu load