[K/N] Move llvm interop generation to kotlin-native/llvmInterop/
This commit is contained in:
committed by
Space Team
parent
ab62632a85
commit
bce550dce4
@@ -4,9 +4,7 @@
|
||||
*/
|
||||
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||
import org.jetbrains.kotlin.PlatformInfo
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.tools.NativePluginKt
|
||||
|
||||
|
||||
buildscript {
|
||||
@@ -15,7 +13,6 @@ buildscript {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: "native-interop-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
sourceSets {
|
||||
@@ -41,45 +38,15 @@ compileCompilerKotlin {
|
||||
compilerOptions.freeCompilerArgs.add('-Xskip-prerelease-check')
|
||||
}
|
||||
|
||||
def tasksWithoutOptInUsage = [
|
||||
"compileLlvmInteropStubsKotlin"
|
||||
]
|
||||
tasks.withType(KotlinCompilationTask.class).configureEach {
|
||||
if (!tasksWithoutOptInUsage.contains(name)) {
|
||||
compilerOptions.optIn.add("org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI")
|
||||
}
|
||||
}
|
||||
|
||||
compileCli_bcKotlin {
|
||||
compilerOptions.freeCompilerArgs.add('-Xskip-prerelease-check')
|
||||
}
|
||||
|
||||
kotlinNativeInterop {
|
||||
llvm {
|
||||
|
||||
dependsOn ":kotlin-native:llvmDebugInfoC:${NativePluginKt.lib("debugInfo")}"
|
||||
dependsOn ":kotlin-native:libllvmext:${NativePluginKt.lib("llvmext")}"
|
||||
defFile 'llvm.def'
|
||||
compilerOpts "-I$llvmDir/include", "-I${rootProject.project(':kotlin-native:llvmDebugInfoC').projectDir}/src/main/include", "-I${rootProject.project(':kotlin-native:libllvmext').projectDir}/src/main/include"
|
||||
if (PlatformInfo.isMac()) {
|
||||
// $llvmDir/lib contains libc++.1.dylib too, and it seems to be preferred by the linker
|
||||
// over the sysroot-provided one.
|
||||
// As a result, libllvmstubs.dylib gets linked with $llvmDir/lib/libc++.1.dylib.
|
||||
// It has install_name = @rpath/libc++.1.dylib, which won't work for us, because
|
||||
// dynamic loader won't be able to find libc++ when loading libllvmstubs.
|
||||
// For some reason, this worked fine before macOS 12.3.
|
||||
//
|
||||
// To enforce linking with proper libc++, pass the default path explicitly:
|
||||
linkerOpts "-L${hostPlatform.absoluteTargetSysRoot}/usr/lib"
|
||||
}
|
||||
linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').layout.buildDirectory.get().asFile}", "-L${rootProject.project(':kotlin-native:libllvmext').layout.buildDirectory.get().asFile}"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
compilerApi {
|
||||
extendsFrom kotlinNativeInterop['llvm'].configuration
|
||||
}
|
||||
kotlin_compiler_jar
|
||||
kotlin_stdlib_jar
|
||||
kotlin_reflect_jar
|
||||
@@ -111,6 +78,7 @@ dependencies {
|
||||
compilerApi project(":native:objcexport-header-generator-k1")
|
||||
compilerApi project(":native:base")
|
||||
|
||||
compilerApi project(path: ":kotlin-native:llvmInterop", configuration: "llvmInteropStubs")
|
||||
compilerApi project(":native:kotlin-native-utils")
|
||||
compilerApi project(":core:descriptors")
|
||||
compilerApi project(":core:compiler.common.native")
|
||||
@@ -144,8 +112,7 @@ classes.dependsOn 'compilerClasses', 'cli_bcClasses'
|
||||
|
||||
tasks.named("jar") {
|
||||
from sourceSets.cli_bc.output,
|
||||
sourceSets.compiler.output,
|
||||
sourceSets.llvmInteropStubs.output
|
||||
sourceSets.compiler.output
|
||||
|
||||
dependsOn 'external_jars'
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@ dependencies {
|
||||
objcExportApi project(":kotlin-native:runtime")
|
||||
embeddableJar project(path: ':kotlin-native:prepare:kotlin-native-compiler-embeddable', configuration: 'runtimeElements')
|
||||
nativeLibs project(path: ':kotlin-native:common', configuration: 'nativeLibs')
|
||||
nativeLibs project(path: ':kotlin-native:llvmInterop', configuration: 'nativeLibs')
|
||||
}
|
||||
|
||||
apply plugin: GitClangFormatPlugin
|
||||
@@ -279,10 +280,6 @@ tasks.register("distCompiler", Copy) {
|
||||
|
||||
destinationDir distDir
|
||||
|
||||
from(project(':kotlin-native:backend.native').file("build/nativelibs/$hostName")) {
|
||||
into('konan/nativelib')
|
||||
}
|
||||
|
||||
from(configurations.nativeLibs) {
|
||||
into('konan/nativelib')
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import org.jetbrains.kotlin.PlatformInfo
|
||||
import org.jetbrains.kotlin.konan.target.TargetWithSanitizer
|
||||
import org.jetbrains.kotlin.tools.lib
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("native-interop-plugin")
|
||||
}
|
||||
|
||||
kotlinNativeInterop {
|
||||
create("llvm") {
|
||||
dependsOn(":kotlin-native:llvmDebugInfoC:${lib("debugInfo")}")
|
||||
dependsOn(":kotlin-native:libllvmext:${lib("llvmext")}")
|
||||
defFile("llvm.def")
|
||||
compilerOpts("-I$llvmDir/include", "-I${rootProject.project(":kotlin-native:llvmDebugInfoC").projectDir}/src/main/include", "-I${rootProject.project(":kotlin-native:libllvmext").projectDir}/src/main/include")
|
||||
if (PlatformInfo.isMac()) {
|
||||
// $llvmDir/lib contains libc++.1.dylib too, and it seems to be preferred by the linker
|
||||
// over the sysroot-provided one.
|
||||
// As a result, libllvmstubs.dylib gets linked with $llvmDir/lib/libc++.1.dylib.
|
||||
// It has install_name = @rpath/libc++.1.dylib, which won't work for us, because
|
||||
// dynamic loader won't be able to find libc++ when loading libllvmstubs.
|
||||
// For some reason, this worked fine before macOS 12.3.
|
||||
//
|
||||
// To enforce linking with proper libc++, pass the default path explicitly:
|
||||
linkerOpts("-L${hostPlatform.absoluteTargetSysRoot}/usr/lib")
|
||||
}
|
||||
linkerOpts("-L$llvmDir/lib", "-L${rootProject.project(":kotlin-native:llvmDebugInfoC").layout.buildDirectory.get().asFile}", "-L${rootProject.project(":kotlin-native:libllvmext").layout.buildDirectory.get().asFile}")
|
||||
}
|
||||
}
|
||||
|
||||
val nativeLibs by configurations.creating {
|
||||
isCanBeConsumed = true
|
||||
isCanBeResolved = false
|
||||
attributes {
|
||||
attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE)
|
||||
attribute(TargetWithSanitizer.TARGET_ATTRIBUTE, TargetWithSanitizer.host)
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
add(nativeLibs.name, layout.buildDirectory.dir("nativelibs/${TargetWithSanitizer.host}")) {
|
||||
builtBy(kotlinNativeInterop["llvm"].genTask)
|
||||
}
|
||||
}
|
||||
@@ -895,6 +895,7 @@ if (buildProperties.isKotlinNativeEnabled) {
|
||||
include ':kotlin-native:utilities'
|
||||
include ':kotlin-native:platformLibs'
|
||||
include ':kotlin-native:libclangext'
|
||||
include ':kotlin-native:llvmInterop'
|
||||
include ':kotlin-native:backend.native:tests'
|
||||
include ':kotlin-native:prepare:kotlin-native-compiler-embeddable'
|
||||
include ':native:kotlin-test-native-xctest'
|
||||
|
||||
Reference in New Issue
Block a user