Add llvm linker detection to configure

https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01240.html

This is currently only used for webengine, where link time really matters.

New configure options:
* force 'lld'  '-linker lld' or' --linker=lld'
* force 'gold' '-linker gold' or '--linker=gold'
* force 'bfd' '-linker bfd' or '--linker=bfd'

Note before by default gold was always forced (if supported) now default linker
is system default one.

[ChangeLog][Tools][configure & build system] Added --linker=[bfg,lld,gold] configure flag.

Change-Id: Idaa13510da70243c6176b96db846d629cd65c7af
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Michal Klocek 2019-01-17 15:39:32 +01:00 committed by Liang Qi
parent 5133e22ae2
commit 7910dd0a54
6 changed files with 74 additions and 6 deletions

View File

@ -167,7 +167,8 @@ Build options:
-pch ................. Use precompiled headers [auto]
-ltcg ................ Use Link Time Code Generation [no]
-use-gold-linker ..... Use the GNU gold linker [auto]
-linker [bfd,gold,lld] Force use of the GNU ld, GNU gold or LLVM/LLD linker
instead of default one (GCC only)
-incredibuild-xge .... Use the IncrediBuild XGE [no] (Windows only)
-ccache .............. Use the ccache compiler cache [no] (Unix only)
-make-tool <tool> .... Use <tool> to build qmake [nmake] (Windows only)

View File

@ -90,6 +90,7 @@
"headersclean": "boolean",
"incredibuild-xge": { "type": "boolean", "name": "incredibuild_xge" },
"libudev": "boolean",
"linker": { "type": "optionalString", "values": [ "bfd", "gold", "lld" ] },
"ltcg": "boolean",
"make": { "type": "addString", "values": [ "examples", "libs", "tests", "tools" ] },
"make-tool": "string",
@ -131,7 +132,7 @@
"syncqt": "boolean",
"sysroot": "string",
"testcocoon": "boolean",
"use-gold-linker": { "type": "boolean", "name": "use_gold_linker" },
"use-gold-linker": { "type": "boolean", "name": "use_gold_linker_alias" },
"warnings-are-errors": { "type": "boolean", "name": "warnings_are_errors" },
"Werror": { "type": "boolean", "name": "warnings_are_errors" },
"widgets": "boolean",
@ -224,8 +225,8 @@
},
"testTypeDependencies": {
"linkerSupportsFlag": [ "use_gold_linker" ],
"verifySpec": [ "shared", "use_gold_linker", "compiler-flags", "qmakeargs", "commit" ],
"linkerSupportsFlag": [ "use_bfd_linker", "use_gold_linker", "use_lld_linker" ],
"verifySpec": [ "shared", "use_bfd_linker", "use_gold_linker", "use_lld_linker", "compiler-flags", "qmakeargs", "commit" ],
"compile": [ "verifyspec" ],
"detectPkgConfig": [ "cross_compile", "machineTuple" ],
"library": [ "pkg-config", "compiler-flags" ],
@ -357,11 +358,21 @@
]
}
},
"use_bfd_linker": {
"label": "bfd linker",
"type": "compilerSupportsFlag",
"flag": "-fuse-ld=bfd"
},
"use_gold_linker": {
"label": "gold linker",
"type": "compilerSupportsFlag",
"flag": "-fuse-ld=gold"
},
"use_lld_linker" : {
"label": "lld linker",
"type": "compilerSupportsFlag",
"flag": "-fuse-ld=lld"
},
"optimize_debug": {
"label": "-Og support",
"type": "compilerSupportsFlag",
@ -649,11 +660,34 @@
"output": [ "qmakeArgs" ],
"condition": "input.qmakeArgs != ''"
},
"use_bfd_linker": {
"label": "bfd",
"autoDetect": "false",
"enable" : "input.linker == 'bfd'",
"disable" : "input.linker == 'gold' || input.linker == 'lld'",
"condition": "!config.win32 && !config.integrity && !config.wasm && tests.use_bfd_linker",
"output": [ "privateConfig", "useBFDLinker" ]
},
"use_gold_linker_alias": {
"autoDetect": "false",
"condition": "!config.win32 && !config.integrity && !config.wasm && tests.use_gold_linker"
},
"use_gold_linker": {
"label": "Using gold linker",
"label": "gold",
"autoDetect": "false",
"enable" : "input.linker == 'gold' || features.use_gold_linker_alias" ,
"disable" : "input.linker == 'bfd' || input.linker == 'lld'",
"condition": "!config.win32 && !config.integrity && !config.wasm && tests.use_gold_linker",
"output": [ "privateConfig", "useGoldLinker" ]
},
"use_lld_linker": {
"label": "lld",
"autoDetect": "false",
"enable" : "input.linker == 'lld'",
"disable" : "input.linker == 'bfd' || input.linker == 'gold'",
"condition": "!config.win32 && !config.integrity && !config.wasm && tests.use_lld_linker",
"output": [ "privateConfig", "useLLDLinker" ]
},
"optimize_debug": {
"label": "Optimize debug build",
"condition": "!config.msvc && !config.clang && (features.debug || features.debug_and_release) && tests.optimize_debug",
@ -1386,7 +1420,12 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
"args": "ccache",
"condition": "config.unix"
},
"use_gold_linker",
{
"message": "Linker",
"type": "firstAvailableFeature",
"args": "use_bfd_linker use_gold_linker use_lld_linker",
"condition": "features.use_bfd_linker || features.use_gold_linker || features.use_lld_linker"
},
{
"type": "feature",
"args": "enable_new_dtags",

View File

@ -1026,6 +1026,14 @@ defineTest(qtConfOutput_crossCompile) {
export(CONFIG)
}
defineTest(qtConfOutput_useBFDLinker) {
!$${2}: return()
# We need to preempt the output here, so that qtConfTest_linkerSupportsFlag can work properly in qtbase
CONFIG += use_bfd_linker
export(CONFIG)
}
defineTest(qtConfOutput_useGoldLinker) {
!$${2}: return()
@ -1034,6 +1042,14 @@ defineTest(qtConfOutput_useGoldLinker) {
export(CONFIG)
}
defineTest(qtConfOutput_useLLDLinker) {
!$${2}: return()
# We need to preempt the output here, so that qtConfTest_linkerSupportsFlag can work properly in qtbase
CONFIG += use_lld_linker
export(CONFIG)
}
defineTest(qtConfOutput_debugAndRelease) {
$$qtConfEvaluate("features.debug") {
qtConfOutputVar(append, "publicPro", "CONFIG", "debug")

View File

@ -20,7 +20,9 @@ QMAKE_LFLAGS_RPATH = -Wl,-rpath,
QMAKE_LFLAGS_RPATHLINK = -Wl,-rpath-link,
QMAKE_LFLAGS_NEW_DTAGS = -Wl,--enable-new-dtags
QMAKE_LFLAGS_GDB_INDEX = -Wl,--gdb-index
QMAKE_LFLAGS_USE_BFD = -fuse-ld=bfd
QMAKE_LFLAGS_USE_GOLD = -fuse-ld=gold
QMAKE_LFLAGS_USE_LLD = -fuse-ld=lld
# -Bsymbolic-functions (ld) support
QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions

View File

@ -78,7 +78,9 @@ stack_protector_strong {
# disable special linker flags for host builds (no proper test for host support yet)
!host_build|!cross_compile {
use_bfd_linker: QMAKE_LFLAGS += $$QMAKE_LFLAGS_USE_BFD
use_gold_linker: QMAKE_LFLAGS += $$QMAKE_LFLAGS_USE_GOLD
use_lld_linker: QMAKE_LFLAGS += $$QMAKE_LFLAGS_USE_LLD
enable_new_dtags: QMAKE_LFLAGS += $$QMAKE_LFLAGS_NEW_DTAGS
enable_gdb_index: QMAKE_LFLAGS += $$QMAKE_LFLAGS_GDB_INDEX
}

View File

@ -368,8 +368,12 @@ defineTest(qtConfTest_compilerSupportsFlag) {
defineTest(qtConfTest_linkerSupportsFlag) {
flag = $$eval($${1}.flag)
use_bfd_linker: \
LFLAGS = -fuse-ld=bfd
use_gold_linker: \
LFLAGS = -fuse-ld=gold
use_lld_linker: \
LFLAGS = -fuse-ld=lld
return($$qtConfToolchainSupportsFlag($$LFLAGS "-Wl,$$flag"))
}
@ -1220,8 +1224,12 @@ defineTest(qtConfTest_compile) {
else: \
qmake_configs = "static"
use_bfd_linker: \
qmake_configs += "use_bfd_linker"
use_gold_linker: \
qmake_configs += "use_gold_linker"
use_lld_linker: \
qmake_configs += "use_lld_linker"
# disable warnings from the builds, since they're just noise at this point.
qmake_configs += "warn_off"