gcc {
    # on Windows, MinGW's support for -flto=N is broken
    intel_icc {
        QMAKE_LFLAGS_LTCG ~= s/-ipo/-ipo=$$QMAKE_HOST.cpu_count/
    } else: !clang:!equals(QMAKE_HOST.os, Windows):greaterThan(QMAKE_HOST.cpu_count, 1) {
        # Override LTO number of jobs
        QMAKE_LFLAGS_LTCG ~= s/^-flto$/-flto=$$QMAKE_HOST.cpu_count/
    }

    # When doing link-time code generation, we need to pass the compiler
    # flags during linking the stage too. This file is processed after
    # default_post.prf, so the QMAKE_CXXFLAGS already contains
    # QMAKE_CXXFLAGS_DEBUG or _RELEASE.
    use_c_linker {
        # use_c_linker.prf is in effect, use the C flags
        QMAKE_LFLAGS_LTCG += $$QMAKE_CFLAGS $$QMAKE_CFLAGS_LTCG
        QMAKE_LFLAGS_APP += $$QMAKE_CFLAGS_APP
        QMAKE_LFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB
        QMAKE_LFLAGS_PLUGIN += $$QMAKE_CFLAGS_SHLIB
    } else {
        QMAKE_LFLAGS_LTCG = $$QMAKE_CXXFLAGS $$QMAKE_LFLAGS_LTCG
        QMAKE_LFLAGS_APP += $$QMAKE_CXXFLAGS_APP
        QMAKE_LFLAGS_SHLIB += $$QMAKE_CXXFLAGS_SHLIB
        QMAKE_LFLAGS_PLUGIN += $$QMAKE_CFLAGS_SHLIB
    }
}
