From 9e558ca32c759ec6ae31f726b3f6f639d93da398 Mon Sep 17 00:00:00 2001 From: LepilkinaElena Date: Tue, 21 Jan 2020 14:15:18 +0300 Subject: [PATCH] Fixes of mimalloc warnings (#3765) --- .../native/interop/gen/jvm/CommandLine.kt | 4 ++-- .../org/jetbrains/kotlin/CompileToBitcode.kt | 2 +- .../mimalloc/c/include/mimalloc-internal.h | 23 ++++++++++++++----- .../utilities/GeneratePlatformLibraries.kt | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt index 53a425fbda6..dd59c807af0 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt @@ -70,7 +70,7 @@ open class CommonInteropArguments(val argParser: ArgParser) { class CInteropArguments(argParser: ArgParser = ArgParser("cinterop", - prefixStyle = ArgParser.OPTION_PREFIX_STYLE.JVM)): CommonInteropArguments(argParser) { + prefixStyle = ArgParser.OptionPrefixStyle.JVM)): CommonInteropArguments(argParser) { val target by argParser.option(ArgType.String, description = "native target to compile to").default("host") val def by argParser.option(ArgType.String, description = "the library definition file") val header by argParser.option(ArgType.String, description = "header file to produce kotlin bindings for") @@ -99,7 +99,7 @@ class CInteropArguments(argParser: ArgParser = } class JSInteropArguments(argParser: ArgParser = ArgParser("jsinterop", - prefixStyle = ArgParser.OPTION_PREFIX_STYLE.JVM)): CommonInteropArguments(argParser) { + prefixStyle = ArgParser.OptionPrefixStyle.JVM)): CommonInteropArguments(argParser) { val target by argParser.option(ArgType.Choice(listOf("wasm32")), description = "wasm target to compile to").default("wasm32") } diff --git a/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompileToBitcode.kt b/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompileToBitcode.kt index 18e8c23da3a..a7bc1938e8d 100644 --- a/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompileToBitcode.kt +++ b/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompileToBitcode.kt @@ -65,7 +65,7 @@ open class CompileToBitcode @Inject constructor(@InputDirectory val srcRoot: Fil Language.C -> Triple("clang", // Used flags provided by original build of allocator C code. commonFlags + listOf("-std=gnu11", "-O3", "-Wall", "-Wextra", "-Wno-unknown-pragmas", - "-ftls-model=initial-exec"), + "-Werror", "-ftls-model=initial-exec", "-Wno-unused-function"), listOf("**/*.c")) Language.CPP -> Triple("clang++", commonFlags + listOfNotNull("-std=c++14", "-Werror", "-O2", diff --git a/runtime/src/mimalloc/c/include/mimalloc-internal.h b/runtime/src/mimalloc/c/include/mimalloc-internal.h index b0997d1e3bd..f27589ba5eb 100644 --- a/runtime/src/mimalloc/c/include/mimalloc-internal.h +++ b/runtime/src/mimalloc/c/include/mimalloc-internal.h @@ -163,12 +163,23 @@ bool _mi_page_is_valid(mi_page_t* page); static inline bool mi_mul_overflow(size_t count, size_t size, size_t* total) { #if __has_builtin(__builtin_umul_overflow) || __GNUC__ >= 5 #include // UINT_MAX, ULONG_MAX -#if (SIZE_MAX == UINT_MAX) - return __builtin_umul_overflow(count, size, total); -#elif (SIZE_MAX == ULONG_MAX) - return __builtin_umull_overflow(count, size, total); +// Changed order for armv7 (ULONG_MAX == UINT_MAX, but size_t = unsigned long) +#if defined(__MACH__) && KONAN_MI_MALLOC + #if (SIZE_MAX == ULONG_MAX) + return __builtin_umull_overflow(count, size, total); + #elif (SIZE_MAX == UINT_MAX) + return __builtin_umul_overflow(count, size, total); + #else + return __builtin_umulll_overflow(count, size, total); + #endif #else - return __builtin_umulll_overflow(count, size, total); + #if (SIZE_MAX == UINT_MAX) + return __builtin_umul_overflow(count, size, total); + #elif (SIZE_MAX == ULONG_MAX) + return __builtin_umull_overflow(count, size, total); + #else + return __builtin_umulll_overflow(count, size, total); + #endif #endif #else /* __builtin_umul_overflow is unavailable */ *total = count * size; @@ -471,7 +482,7 @@ static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept { #if KONAN_MI_MALLOC #include #if TARGET_OS_EMBEDDED // iOS/tvOS/watchOS devices. - tid = pthread_self(); + tid = pthread_mach_thread_np(pthread_self()); #else __asm__("movq %%gs:0, %0" : "=r" (tid) : : ); // x86_64 macOS uses GS #endif diff --git a/utilities/src/main/kotlin/org/jetbrains/kotlin/cli/utilities/GeneratePlatformLibraries.kt b/utilities/src/main/kotlin/org/jetbrains/kotlin/cli/utilities/GeneratePlatformLibraries.kt index ef4d95f0483..b3bf8f92be8 100644 --- a/utilities/src/main/kotlin/org/jetbrains/kotlin/cli/utilities/GeneratePlatformLibraries.kt +++ b/utilities/src/main/kotlin/org/jetbrains/kotlin/cli/utilities/GeneratePlatformLibraries.kt @@ -11,7 +11,7 @@ import java.util.concurrent.* import kotlinx.cli.* fun generatePlatformLibraries(args: Array) { - val argParser = ArgParser("generate-platform", prefixStyle = ArgParser.OPTION_PREFIX_STYLE.JVM) + val argParser = ArgParser("generate-platform", prefixStyle = ArgParser.OptionPrefixStyle.JVM) val inputDirectoryPath by argParser.option( ArgType.String, "input-directory", "i", "Input directory").required() val outputDirectoryPath by argParser.option(