Clean up ltcg.prf with variables, including a new static mode

By using the special "ar" and "ranlib" tools, the symbol table is made
visible, so we don't need fat LTO binaries. Since we need to store the
new tool names, we may as well clean up ltcg.prf with variable names for
the fat mode too.

Change-Id: I7e53af0c74a3d069313f38500b72538af1d61128
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Thiago Macieira 2014-11-14 19:27:46 -08:00
parent d7795559a7
commit 0f569f5900
4 changed files with 35 additions and 18 deletions

View File

@ -28,3 +28,8 @@ QMAKE_CXXFLAGS_CXX11 = -std=c++11
QMAKE_LFLAGS_CXX11 =
QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
# Wrapper tools that understand .o/.a files with LLVM bytecode instead of machine code
QMAKE_AR_LTCG = llvm-ar cqs
QMAKE_NM_LTCG = gcc-nm -P
QMAKE_RANLIB_LTCG = true # No need to run, since llvm-ar has "s"

View File

@ -48,7 +48,8 @@ QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses
QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden
QMAKE_CFLAGS_EXCEPTIONS_OFF += -fno-exceptions
QMAKE_CFLAGS_SPLIT_SECTIONS += -ffunction-sections
QMAKE_CFLAGS_LTCG = -flto
QMAKE_CFLAGS_LTCG = -flto -fno-fat-lto-objects
QMAKE_CFLAGS_LTCG_FATOBJECTS = -ffat-lto-objects
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS
@ -64,6 +65,7 @@ QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
QMAKE_CXXFLAGS_EXCEPTIONS_OFF += $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_CXXFLAGS_SPLIT_SECTIONS += $$QMAKE_CFLAGS_SPLIT_SECTIONS
QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS
QMAKE_LFLAGS +=
QMAKE_LFLAGS_DEBUG +=
@ -81,4 +83,9 @@ QMAKE_CFLAGS_AVX += -mavx
QMAKE_CFLAGS_AVX2 += -mavx2
QMAKE_CFLAGS_NEON += -mfpu=neon
# Wrapper tools that understand .o/.a files with GIMPLE instead of machine code
QMAKE_AR_LTCG = gcc-ar cqs
QMAKE_NM_LTCG = gcc-nm -P
QMAKE_RANLIB_LTCG = true # No need to run since gcc-ar has "s"
include(sanitize.conf)

View File

@ -1,4 +1,9 @@
gcc {
!clang:!intel_icc: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

View File

@ -1,32 +1,32 @@
CONFIG(release, debug|release) {
# We need fat object files when creating static libraries on some platforms
# so the linker will know to load a particular object from the library
# in the first place. With GCC, we have -ffat-lto-objects. MSVC
# seems to work just fine. For other compilers, we disable LTCG
# in the first place. On others, we have special ar and nm to create the symbol
# tables so the linker will know better. For other compilers, we disable LTCG
# for static libraries.
msvc {
# Nothing to do
} else: gcc {
!clang:!intel_icc {
static|fat-lto {
QMAKE_CFLAGS_LTCG += -ffat-lto-objects
QMAKE_CXXFLAGS_LTCG += -ffat-lto-objects
} else {
QMAKE_CFLAGS_LTCG += -fno-fat-lto-objects
QMAKE_CXXFLAGS_LTCG += -fno-fat-lto-objects
}
greaterThan(QMAKE_HOST.cpu_count, 1) {
# Override LTO number of jobs
QMAKE_LFLAGS_LTCG -= -flto
QMAKE_LFLAGS_LTCG += -flto=$$QMAKE_HOST.cpu_count
}
} else: static {
} else {
!isEmpty(QMAKE_AR_LTCG): QMAKE_AR = $$QMAKE_AR_LTCG
!isEmpty(QMAKE_NM_LTCG): QMAKE_NM = $$QMAKE_NM_LTCG
equals(QMAKE_RANLIB_LTCG, true): QMAKE_RANLIB =
else: !isEmpty(QMAKE_RANLIB_LTCG): QMAKE_RANLIB = $$QMAKE_RANLIB_LTCG
static:isEmpty(QMAKE_AR_LTCG):isEmpty(QMAKE_RANLIB_LTCG) {
# We don't know how to create symbol tables for static libs with this
# compiler, so disable LTCG
QMAKE_CFLAGS_LTCG =
QMAKE_CXXFLAGS_LTCG =
QMAKE_LFLAGS_LTCG =
}
}
fat-lto {
QMAKE_CFLAGS_LTCG += $$QMAKE_CFLAGS_LTCG_FATOBJECTS
QMAKE_CXXFLAGS_LTCG += $$QMAKE_CXXFLAGS_LTCG_FATOBJECTS
}
load(link_ltcg)
QMAKE_CFLAGS *= $$QMAKE_CFLAGS_LTCG
QMAKE_CXXFLAGS *= $$QMAKE_CXXFLAGS_LTCG