From 7293dd6d65e2470972733e860c056eaf19021491 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Thu, 15 Sep 2022 17:19:58 +0200 Subject: [PATCH] [K/N] Require small binaries for all watchos targets --- kotlin-native/runtime/src/main/cpp/Common.h | 2 +- kotlin-native/runtime/src/main/cpp/Memory.h | 2 +- .../kotlin/org/jetbrains/kotlin/konan/target/ClangArgs.kt | 2 +- .../jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kotlin-native/runtime/src/main/cpp/Common.h b/kotlin-native/runtime/src/main/cpp/Common.h index 30bdedbca21..100ca01c95e 100644 --- a/kotlin-native/runtime/src/main/cpp/Common.h +++ b/kotlin-native/runtime/src/main/cpp/Common.h @@ -25,7 +25,7 @@ #define RUNTIME_WEAK __attribute__((weak)) #define RUNTIME_NODEBUG __attribute__((nodebug)) -#if KONAN_NEAD_SMALL_BINARY +#if KONAN_NEED_SMALL_BINARY // On the one hand, ALWAYS_INLINE forces many performance-critical function to be, well, // inlined. Which is good for performance, of course. // On the other hand, 32-bit Mach-O object files can't be really big. diff --git a/kotlin-native/runtime/src/main/cpp/Memory.h b/kotlin-native/runtime/src/main/cpp/Memory.h index 898e211118b..9bb053bfedd 100644 --- a/kotlin-native/runtime/src/main/cpp/Memory.h +++ b/kotlin-native/runtime/src/main/cpp/Memory.h @@ -26,7 +26,7 @@ #include "PointerBits.h" #include "Utils.hpp" -#if KONAN_NEAD_SMALL_BINARY +#if KONAN_NEED_SMALL_BINARY // Currently, codegen places a lot of unnecessary calls to MM functions. // By forcing NO_INLINE on these functions we keep binaries from growing too big. #define CODEGEN_INLINE_POLICY NO_INLINE diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/ClangArgs.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/ClangArgs.kt index 0dec6440262..0148d8ca317 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/ClangArgs.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/ClangArgs.kt @@ -54,7 +54,7 @@ sealed class ClangArgs( "HAS_FOUNDATION_FRAMEWORK".takeIf { target.hasFoundationFramework() }, "HAS_UIKIT_FRAMEWORK".takeIf { target.hasUIKitFramework() }, "REPORT_BACKTRACE_TO_IOS_CRASH_LOG".takeIf { target.supportsIosCrashLog() }, - "NEAD_SMALL_BINARY".takeIf { target.needSmallBinary() }, + "NEED_SMALL_BINARY".takeIf { target.needSmallBinary() }, "TARGET_HAS_ADDRESS_DEPENDENCY".takeIf { target.hasAddressDependencyInMemoryModel() }, ).map { "KONAN_$it=1" } val otherOptions = listOfNotNull( diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt index bf7472e2f0a..a24c35dd5b4 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt @@ -143,7 +143,11 @@ fun KonanTarget.supportsUnalignedAccess(): Boolean = when (architecture) { Architecture.X86, Architecture.ARM64, Architecture.X64 -> true } && this != KonanTarget.WATCHOS_ARM64 -fun KonanTarget.needSmallBinary() = (architecture == Architecture.ARM32 && family.isAppleFamily) +fun KonanTarget.needSmallBinary() = when { + family == Family.WATCHOS -> true + family.isAppleFamily -> architecture == Architecture.ARM32 + else -> false +} fun KonanTarget.supportedSanitizers(): List = when(this) {