Add build parameter to build coroutines with JVM IR compiler (#2389)

* Add build parameters to enable JVM IR and disable native targets
    * enable_jvm_ir enables JVM IR compiler
    * disable_native_targets disables native targets in train builds
    * enable_jvm_ir_api_check enables JVM IR API check (works only if enable_jvm_ir is set)

* Fix "Return type must be specified in explicit API mode" in 1.4.20
diff --git a/build.gradle b/build.gradle
index 79c7f35..938d42e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -33,6 +33,10 @@
             throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
         }
     }
+    // These three flags are enabled in train builds for JVM IR compiler testing
+    ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
+    ext.jvm_ir_api_check_enabled = rootProject.properties['enable_jvm_ir_api_check'] != null
+    ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null
 
     // Determine if any project dependency is using a snapshot version
     ext.using_snapshot_version = build_snapshot_train
@@ -323,3 +327,12 @@
 }
 
 knitPrepare.dependsOn getTasksByName("dokka", true)
+
+// Disable binary compatibility check for JVM IR compiler output by default
+if (jvm_ir_enabled) {
+    subprojects { project ->
+        configure(tasks.matching { it.name == "apiCheck" }) {
+            enabled = enabled && jvm_ir_api_check_enabled
+        }
+    }
+}
\ No newline at end of file