From b4cbe703cd593217fd30449aba0b6ede288ceb13 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Wed, 2 Feb 2022 18:15:49 +0300 Subject: [PATCH] [K/N] Test for KT-50970 --- .../backend.native/tests/build.gradle | 16 ++++++++++++++- .../filecheck/force_arm_instruction_set.kt | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 kotlin-native/backend.native/tests/filecheck/force_arm_instruction_set.kt diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index e247b339b4e..5bdcbbe6e25 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -178,6 +178,7 @@ run { // Add regular gradle test tasks dependsOn(tasksOf(Test)) dependsOn(tasksOf(CoverageTest)) + dependsOn(tasksOf(FileCheckTest)) dependsOn(":kotlin-native:Interop:Indexer:check") } @@ -195,7 +196,10 @@ task sanity { // Add regular gradle test tasks dependsOn(tasksOf(Test)) dependsOn(tasksOf(CoverageTest)) - dependsOn(tasksOf(FileCheckTest)) + dependsOn(tasksOf(FileCheckTest) { task -> + // Avoid cross-compilation in a sanity run. + task.targetName == project.target.name + }) dependsOn(":kotlin-native:Interop:Indexer:check") dependsOn(":kotlin-native:Interop:StubGenerator:check") } @@ -5945,6 +5949,16 @@ fileCheckTest("filecheck_smoke0") { annotatedSource = project.file('filecheck/smoke0.kt') } +if (HostManager.@Companion.hostIsMac) { + fileCheckTest("filecheck_force_arm_instruction_set") { + annotatedSource = project.file('filecheck/force_arm_instruction_set.kt') + targetName = "watchos_arm32" + // Perform check after optimization pipeline because + // LLVM might infer attributes. + phaseToCheck = "BitcodeOptimization" + } +} + fileCheckTest("filecheck_replace_invoke_with_call") { annotatedSource = project.file('filecheck/replace_invoke_with_call.kt') } diff --git a/kotlin-native/backend.native/tests/filecheck/force_arm_instruction_set.kt b/kotlin-native/backend.native/tests/filecheck/force_arm_instruction_set.kt new file mode 100644 index 00000000000..d48719b83dc --- /dev/null +++ b/kotlin-native/backend.native/tests/filecheck/force_arm_instruction_set.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +// NB: This is not a good test. +// What we actually want to check is that Kotlin/Native compiler is able to produce "big" +// binaries for 32-bit Apple Watch target. The problem is that such test is very-very-very +// slow to compile (~20 min on a local machine) which is not acceptable for CI. +// +// Instead, here we check that none of the module's functions are compiled in the Thumb mode. +// BL instructions in thumb mode have smaller ranges which causes "relocation out of range" failure. + +// CHECK: target triple = "armv7k-apple-watchos{{.+}}" + +fun main() { + println("hello") +} + +// CHECK-NOT: attributes #{{[0-9]+}} = { {{.+}}+thumb-mode{{.+}} } \ No newline at end of file