Clang: Fix providing clang directory with intrinsics

Opening a main.cpp of a Qt Widget Application project that is configured
with a GCC toolchain leads to errors [1] like

    /usr/lib/gcc/x86_64-linux-gnu/4.8/include/ia32intrin.h:41:10: \
    error: use of undeclared identifier '__builtin_ia32_bsrsi'

due to a wrong determination of the clang directory with intrinsics. The
directory was determined as

    $${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include

whereas $LLVM_VERSION was extracted as e.g. "3.5" from 'llvm-config
--version' instead of "3.5.0".

The path of clang intrinsics dir shipped with Qt Creator (as package)
does also match this version scheme:

    $QTC_INSTALL_DIR/share/qtcreator/cplusplus/clang/3.4.2/include

[1] Visible with qtc.clangcodemodel.verboserun=true

Change-Id: I1061912eef437a9889987e638915d2fabe208011
Reviewed-by: hjk <hjk@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-04-20 12:38:50 +02:00
parent 8e957f09c7
commit e488f10c7f
2 changed files with 9 additions and 8 deletions

View File

@@ -66,7 +66,7 @@ unix {
LLVM_CONFIG = $$findLLVMConfig() LLVM_CONFIG = $$findLLVMConfig()
LLVM_VERSION = $$system($$LLVM_CONFIG --version 2>/dev/null) LLVM_VERSION = $$system($$LLVM_CONFIG --version 2>/dev/null)
LLVM_VERSION = $$replace(LLVM_VERSION, ^(\\d+\\.\\d+).*$, \\1) LLVM_VERSION = $$replace(LLVM_VERSION, ^(\\d+\\.\\d+\\.\\d+).*$, \\1)
message("... version $$LLVM_VERSION") message("... version $$LLVM_VERSION")
LLVM_INCLUDEPATH = $$system($$LLVM_CONFIG --includedir 2>/dev/null) LLVM_INCLUDEPATH = $$system($$LLVM_CONFIG --includedir 2>/dev/null)

View File

@@ -151,6 +151,14 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind
maybeIncludeBorlandExtensions()); maybeIncludeBorlandExtensions());
result << CompilerOptionsBuilder::createDefineOptions(pPart->toolchainDefines); result << CompilerOptionsBuilder::createDefineOptions(pPart->toolchainDefines);
result << CompilerOptionsBuilder::createDefineOptions(pPart->projectDefines); result << CompilerOptionsBuilder::createDefineOptions(pPart->projectDefines);
static const QString resourceDir = getResourceDir();
if (!resourceDir.isEmpty()) {
result << QLatin1String("-nostdlibinc");
result << (QLatin1String("-I") + resourceDir);
result << QLatin1String("-undef");
}
result << CompilerOptionsBuilder::createHeaderPathOptions(pPart->headerPaths, isBlacklisted); result << CompilerOptionsBuilder::createHeaderPathOptions(pPart->headerPaths, isBlacklisted);
// Inject header file // Inject header file
@@ -164,13 +172,6 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind
if (!pPart->projectConfigFile.isEmpty()) if (!pPart->projectConfigFile.isEmpty())
result << QLatin1String("-include") << pPart->projectConfigFile; result << QLatin1String("-include") << pPart->projectConfigFile;
static const QString resourceDir = getResourceDir();
if (!resourceDir.isEmpty()) {
result << QLatin1String("-nostdlibinc");
result << (QLatin1String("-I") + resourceDir);
result << QLatin1String("-undef");
}
result << QLatin1String("-fmessage-length=0"); result << QLatin1String("-fmessage-length=0");
result << QLatin1String("-fdiagnostics-show-note-include-stack"); result << QLatin1String("-fdiagnostics-show-note-include-stack");
result << QLatin1String("-fmacro-backtrace-limit=0"); result << QLatin1String("-fmacro-backtrace-limit=0");