Using `-flto` on clang without using the gold linker produces the error: ```main.o: file not recognized: File format not recognized``` https://github.com/android/ndk/issues/242 `gold` seems to be faster than `ld`, and decently tested even in 2010: https://stackoverflow.com/questions/3476093/replacing-ld-with-gold-any-experience Qmake will still append `-Wl,-O1` even though higher optimization levels are used. Removing this in order to keep the compile command as short as possible, and to reduce weird issues down the line. Ref topic: https://stackoverflow.com/questions/53384988/why-qmake-passes-wl-o1-to-gcc-when-linking-and-will-it-harm-lto
37 lines
997 B
Plaintext
37 lines
997 B
Plaintext
GCC_VERSION = $$system("g++ -dumpversion")
|
|
greaterThan(GCC_VERSION, 6) {
|
|
message('g++' version is above 6. Using regular g++.)
|
|
}
|
|
else {
|
|
message('g++' version is not above 6. Attempting to use highest specific version.)
|
|
system(g++-7 --version) {
|
|
message('g++-7' found.)
|
|
QMAKE_CXX = g++-7
|
|
}
|
|
system(g++-8 --version) {
|
|
message('g++-8' found.)
|
|
QMAKE_CXX = g++-8
|
|
}
|
|
system(g++-9 --version) {
|
|
message('g++-9' found.)
|
|
QMAKE_CXX = g++-9
|
|
}
|
|
}
|
|
|
|
include(clang-gcc-common-switches.pri)
|
|
|
|
QMAKE_CXXFLAGS += -Wpedantic
|
|
|
|
QMAKE_CXXFLAGS += -Werror
|
|
|
|
# GCC only switches
|
|
QMAKE_CXXFLAGS += -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Wrestrict -Wnull-dereference
|
|
|
|
# Sign conversion warns on auto generated Qt MOC files.
|
|
QMAKE_CXXFLAGS += -Wconversion -Wno-sign-conversion
|
|
|
|
QMAKE_CXXFLAGS += -Wzero-as-null-pointer-constant
|
|
|
|
# Qmake will append this even though higher optimization levels are used.
|
|
QMAKE_LFLAGS_RELEASE -= -Wl,-O1
|