diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-08-01 15:08:51 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-08-28 08:40:16 +0000 |
commit | 40787b4d077eea1211f43d9f247c560957bd6887 (patch) | |
tree | 5e44c225aa4eddbb3c22ca0481524f6c875c3a5d /share/qbs/modules/cpp/gcc.js | |
parent | d36064bc2e486d81e8403e45ddf91311aa066fdb (diff) | |
download | qbs-40787b4d077eea1211f43d9f247c560957bd6887.tar.gz |
Introduce the cpufeatures module
Provides an abstraction for the respective compiler flags. The initial
set of properties is the superset of what Qt can configure and what MSVC
supports.
Change-Id: I1be90361f2f104a55d2a784a69625396680b0713
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'share/qbs/modules/cpp/gcc.js')
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index a0acc638a..873aea531 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -560,6 +560,46 @@ function qnxLangArgs(config, tag) { } } +function handleCpuFeatures(input, flags) { + function potentiallyAddFlagForFeature(propName, flagName) { + var propValue = input.cpufeatures[propName]; + if (propValue === true) + flags.push("-m" + flagName); + else if (propValue === false) + flags.push("-mno-" + flagName); + } + + if (!input.qbs.architecture) + return; + if (input.qbs.architecture.startsWith("x86")) { + potentiallyAddFlagForFeature("x86_avx", "avx"); + potentiallyAddFlagForFeature("x86_avx2", "avx2"); + potentiallyAddFlagForFeature("x86_avx512bw", "avx512bw"); + potentiallyAddFlagForFeature("x86_avx512cd", "avx512cd"); + potentiallyAddFlagForFeature("x86_avx512dq", "avx512dq"); + potentiallyAddFlagForFeature("x86_avx512er", "avx512er"); + potentiallyAddFlagForFeature("x86_avx512f", "avx512f"); + potentiallyAddFlagForFeature("x86_avx512ifma", "avx512ifma"); + potentiallyAddFlagForFeature("x86_avx512pf", "avx512pf"); + potentiallyAddFlagForFeature("x86_avx512vbmi", "avx512vbmi"); + potentiallyAddFlagForFeature("x86_avx512vl", "avx512vl"); + potentiallyAddFlagForFeature("x86_f16c", "f16c"); + potentiallyAddFlagForFeature("x86_sse2", "sse2"); + potentiallyAddFlagForFeature("x86_sse3", "sse3"); + potentiallyAddFlagForFeature("x86_sse4_1", "sse4.1"); + potentiallyAddFlagForFeature("x86_sse4_2", "sse4.2"); + potentiallyAddFlagForFeature("x86_ssse3", "ssse3"); + } else if (input.qbs.architecture.startsWith("arm")) { + if (input.cpufeatures.arm_neon === true) + flags.push("-mfpu=neon"); + if (input.cpufeatures.arm_vfpv4 === true) + flags.push("-mfpu=vfpv4"); + } else if (input.qbs.architecture.startsWith("mips")) { + potentiallyAddFlagForFeature("mips_dsp", "dsp"); + potentiallyAddFlagForFeature("mips_dspr2", "dspr2"); + } +} + function compilerFlags(project, product, input, output, explicitlyDependsOn) { var i; @@ -581,6 +621,7 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) { var args = additionalCompilerAndLinkerFlags(product); Array.prototype.push.apply(args, product.cpp.sysrootFlags); + handleCpuFeatures(input, args); if (input.cpp.debugInformation) args.push('-g'); |