From 9052e08e59fd2f601b0af35a0e0f643c226fa76b Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Fri, 17 Feb 2017 17:26:23 +0700 Subject: [PATCH] build: fix compilation on Linux when using libclang --- .../org/jetbrains/kotlin/NativeInteropPlugin.groovy | 8 ++++++++ dependencies/build.gradle | 2 +- gradle.properties | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy index 5e2bcd47ab0..cf95d07fafa 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -203,6 +203,14 @@ class NamedNativeInteropConfig implements Named { environment['PATH'] = project.files(project.clangPath).asPath + File.pathSeparator + environment['PATH'] + if (project.isLinux()) { + // StubGenerator passes the arguments to libclang which works not exactly the same way + // as the clang binary and (in particular) uses different default header search path. + // See e.g. http://lists.llvm.org/pipermail/cfe-dev/2013-November/033680.html + // Workaround the problem: + compilerOpts += ["-isystem", "${project.llvmDir}/lib/clang/${project.llvmVersion}/include"] + } + compilerOpts += project.hostClangArgs linkerOpts += project.hostClangArgs diff --git a/dependencies/build.gradle b/dependencies/build.gradle index 0175635a5dd..d0f3953244b 100644 --- a/dependencies/build.gradle +++ b/dependencies/build.gradle @@ -75,7 +75,7 @@ task libffi(type: TgzNativeDep) { } task llvm(type: TgzNativeDep) { - baseName = "clang+llvm-3.8.0-$host" + baseName = "clang+llvm-$llvmVersion-$host" } if (isLinux()) { diff --git a/gradle.properties b/gradle.properties index 458a1c16066..16d25a8f970 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ kotlin_version=1.1-M03 +llvmVersion = 3.8.0 #kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-SNAPSHOT kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20170217.175209-427 \ No newline at end of file