[K/N] Add libbacktrace
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.testing.native.*
|
||||
import org.jetbrains.kotlin.bitcode.CompileToBitcode
|
||||
import org.jetbrains.kotlin.bitcode.CompileToBitcodeExtension
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import org.jetbrains.kotlin.konan.target.Architecture as TargetArchitecture
|
||||
|
||||
plugins {
|
||||
id("compile-to-bitcode")
|
||||
@@ -32,6 +32,7 @@ bitcode {
|
||||
"${target}StdAlloc",
|
||||
"${target}OptAlloc",
|
||||
"${target}Mimalloc",
|
||||
"${target}Libbacktrace",
|
||||
"${target}Launcher",
|
||||
"${target}Debug",
|
||||
"${target}Release",
|
||||
@@ -63,6 +64,45 @@ bitcode {
|
||||
onlyIf { targetSupportsMimallocAllocator(target) }
|
||||
}
|
||||
|
||||
create("libbacktrace") {
|
||||
val targetInfo = HostManager().targetByName(target)
|
||||
language = CompileToBitcode.Language.C
|
||||
val useMachO = targetInfo.family.isAppleFamily
|
||||
val useElf = targetInfo.family in listOf(Family.LINUX, Family.ANDROID)
|
||||
includeFiles = listOfNotNull(
|
||||
"atomic.c",
|
||||
"backtrace.c",
|
||||
"dwarf.c",
|
||||
"elf.c".takeIf { useElf },
|
||||
"fileline.c",
|
||||
"macho.c".takeIf { useMachO },
|
||||
"mmap.c",
|
||||
"mmapio.c",
|
||||
"posix.c",
|
||||
"print.c",
|
||||
"simple.c",
|
||||
"sort.c",
|
||||
"state.c"
|
||||
)
|
||||
srcDirs = files("$srcRoot/c")
|
||||
val elfSize = when (targetInfo.architecture) {
|
||||
TargetArchitecture.X64, TargetArchitecture.ARM64 -> 64
|
||||
TargetArchitecture.X86, TargetArchitecture.ARM32,
|
||||
TargetArchitecture.MIPS32, TargetArchitecture.MIPSEL32,
|
||||
TargetArchitecture.WASM32 -> 32
|
||||
}
|
||||
compilerArgs.addAll(listOfNotNull(
|
||||
"-funwind-tables",
|
||||
"-W", "-Wall", "-Wwrite-strings", "-Wstrict-prototypes", "-Wmissing-prototypes",
|
||||
"-Wold-style-definition", "-Wmissing-format-attribute", "-Wcast-qual", "-O2",
|
||||
"-DBACKTRACE_ELF_SIZE=$elfSize".takeIf { useElf }
|
||||
))
|
||||
headersDirs = files("$srcRoot/c/include")
|
||||
|
||||
onlyIf { targetSupportsLibBacktrace(target) }
|
||||
}
|
||||
|
||||
|
||||
create("launcher") {
|
||||
includeRuntime()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user