M
M
Mercury132019-06-04 12:23:40
Command line
Mercury13, 2019-06-04 12:23:40

What set of optimization options in MinGW gives fast linking and no “optimized out”?

MinGW x64 9.1.0 installed via MSYS. A project of three hundred files.
-O1 gives linking in 50 seconds, but very difficult to debug, everything turns into <optimized out>.
-O0 gives a link in 2.5 minutes.

QMAKE_CXXFLAGS_DEBUG += -finline \
        -fauto-inc-dec  \
        -fbranch-count-reg  \
        -fcombine-stack-adjustments \
        -fcompare-elim \
        -fcprop-registers \
        -fdce \
        -fdefer-pop \
        -fdse \
        -fforward-propagate \
        -fguess-branch-probability \
        -fif-conversion \
        -fif-conversion2 \
        -finline-functions-called-once \
        -fipa-profile \
        -fipa-pure-const \
        -fipa-reference \
        -fipa-reference-addressable \
        -fmerge-constants \
        -fmove-loop-invariants \
        -fomit-frame-pointer \
        -freorder-blocks \
        -fshrink-wrap \
        -fshrink-wrap-separate \
        -fsplit-wide-types \
        -fssa-backprop \
        -fssa-phiopt \
        -ftree-bit-ccp \
        -ftree-ccp \
        -ftree-ch \
        -ftree-coalesce-vars \
        -ftree-copy-prop \
        -ftree-dce \
        -ftree-dominator-opts \
        -ftree-dse \
        -ftree-forwprop \
        -ftree-fre \
        -ftree-phiprop \
        -ftree-pta \
        -ftree-scev-cprop \
        -ftree-sink \
        -ftree-slsr \
        -ftree-sra \
        -ftree-ter \
        -funit-at-a-time \
        -static-libstdc++

This monster, which, in theory, should be equivalent to -O1, links in the same 2.5 minutes.
Here is how to debug?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2019-08-29
@Mercury13

Now it is much better to use the LLD linker for debugging. It is TENS times faster than LD.
Of course, the compilation settings must be set to the “most debugged” -O0.
I still didn’t understand how to put an icon and what about LTO - that’s why the release is still going through LD.
UPD 2022. And now LD is cool enough and nothing is needed!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question