[K/N] Fix building mimalloc with TSAN

This commit is contained in:
Elena Lepilkina
2021-12-09 11:26:26 +03:00
committed by Space
parent 0e6762acc3
commit 611c402e59
2 changed files with 15 additions and 4 deletions
@@ -102,6 +102,9 @@ abstract class CompileToBitcode @Inject constructor(
@Input @Optional
var sanitizer: SanitizerKind? = null
@Input @Optional
val extraSanitizerArgs = mutableMapOf<SanitizerKind, List<String>>()
private val targetDir: File
get() {
val sanitizerSuffix = when (sanitizer) {
@@ -136,11 +139,18 @@ abstract class CompileToBitcode @Inject constructor(
null -> listOf()
SanitizerKind.ADDRESS -> listOf("-fsanitize=address")
SanitizerKind.THREAD -> listOf("-fsanitize=thread")
}
} + (extraSanitizerArgs[sanitizer] ?: emptyList())
val languageFlags = when (language) {
Language.C ->
// Used flags provided by original build of allocator C code.
listOf("-std=gnu11", "-O3", "-Wall", "-Wextra", "-Werror")
Language.C -> {
listOf("-std=gnu11", "-Wall", "-Wextra", "-Werror") +
if (sanitizer != SanitizerKind.THREAD) {
// Used flags provided by original build of allocator C code.
listOf("-O3")
} else {
// Building with TSAN needs turning off extra optimizations.
listOf("-O1")
}
}
Language.CPP ->
listOfNotNull("-std=c++17", "-Werror", "-O2",
"-fno-aligned-allocation", // TODO: Remove when all targets support aligned allocation in C++ runtime.
+1
View File
@@ -77,6 +77,7 @@ bitcode {
compilerArgs.addAll(listOf("-DKONAN_MI_MALLOC=1", "-Wno-unknown-pragmas", "-ftls-model=initial-exec",
"-Wno-unused-function", "-Wno-error=atomic-alignment",
"-Wno-unused-parameter" /* for windows 32*/))
extraSanitizerArgs[SanitizerKind.THREAD] = listOf("-DMI_TSAN=1")
headersDirs = files("$srcRoot/c/include")
onlyIf { targetSupportsMimallocAllocator(target) }