Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable dumping KAPT processor performance stats #880

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions docs/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ kt_javac_options(<a href="#kt_javac_options-name">name</a>, <a href="#kt_javac_o

## kt_kotlinc_options

kt_kotlinc_options(<a href="#kt_kotlinc_options-name">name</a>, <a href="#kt_kotlinc_options-include_stdlibs">include_stdlibs</a>, <a href="#kt_kotlinc_options-java_parameters">java_parameters</a>, <a href="#kt_kotlinc_options-warn">warn</a>, <a href="#kt_kotlinc_options-x_allow_result_return_type">x_allow_result_return_type</a>,
kt_kotlinc_options(<a href="#kt_kotlinc_options-name">name</a>, <a href="#kt_kotlinc_options-include_stdlibs">include_stdlibs</a>, <a href="#kt_kotlinc_options-java_parameters">java_parameters</a>, <a href="#kt_kotlinc_options-warn">warn</a>, <a href="#kt_kotlinc_options-dump_processor_stats">dump_processor_stats</a>, <a href="#kt_kotlinc_options-x_allow_result_return_type">x_allow_result_return_type</a>,
<a href="#kt_kotlinc_options-x_backend_threads">x_backend_threads</a>, <a href="#kt_kotlinc_options-x_emit_jvm_type_annotations">x_emit_jvm_type_annotations</a>, <a href="#kt_kotlinc_options-x_explicit_api_mode">x_explicit_api_mode</a>,
<a href="#kt_kotlinc_options-x_inline_classes">x_inline_classes</a>, <a href="#kt_kotlinc_options-x_jvm_default">x_jvm_default</a>, <a href="#kt_kotlinc_options-x_lambdas">x_lambdas</a>, <a href="#kt_kotlinc_options-x_multi_platform">x_multi_platform</a>, <a href="#kt_kotlinc_options-x_no_call_assertions">x_no_call_assertions</a>,
<a href="#kt_kotlinc_options-x_no_optimize">x_no_optimize</a>, <a href="#kt_kotlinc_options-x_no_optimized_callable_references">x_no_optimized_callable_references</a>, <a href="#kt_kotlinc_options-x_no_param_assertions">x_no_param_assertions</a>,
Expand All @@ -406,30 +406,31 @@ kt_kotlinc_options(<a href="#kt_kotlinc_options-name">name</a>, <a href="#kt_kot
**ATTRIBUTES**


| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
|<a id="kt_kotlinc_options-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
|<a id="kt_kotlinc_options-include_stdlibs"></a>include_stdlibs | Don't automatically include the Kotlin standard libraries into the classpath (stdlib and reflect). | String | optional | "all" |
|<a id="kt_kotlinc_options-java_parameters"></a>java_parameters | Generate metadata for Java 1.8+ reflection on method parameters. | Boolean | optional | False |
|<a id="kt_kotlinc_options-warn"></a>warn | Control warning behaviour. | String | optional | "report" |
|<a id="kt_kotlinc_options-x_allow_result_return_type"></a>x_allow_result_return_type | Enable kotlin.Result as a return type | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_backend_threads"></a>x_backend_threads | When using the IR backend, run lowerings by file in N parallel threads. 0 means use a thread per processor core. Default value is 1. | Integer | optional | 1 |
|<a id="kt_kotlinc_options-x_emit_jvm_type_annotations"></a>x_emit_jvm_type_annotations | Basic support for type annotations in JVM bytecode. | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_explicit_api_mode"></a>x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | "off" |
|<a id="kt_kotlinc_options-x_inline_classes"></a>x_inline_classes | Enable experimental inline classes | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_jvm_default"></a>x_jvm_default | Specifies that a JVM default method should be generated for non-abstract Kotlin interface member. | String | optional | "off" |
|<a id="kt_kotlinc_options-x_lambdas"></a>x_lambdas | Change codegen behavior of lambdas | String | optional | "class" |
|<a id="kt_kotlinc_options-x_multi_platform"></a>x_multi_platform | Enable experimental language support for multi-platform projects | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_no_call_assertions"></a>x_no_call_assertions | Don't generate not-null assertions for arguments of platform types | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_no_optimize"></a>x_no_optimize | Disable optimizations | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_no_optimized_callable_references"></a>x_no_optimized_callable_references | Do not use optimized callable reference superclasses. Available from 1.4. | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_no_param_assertions"></a>x_no_param_assertions | Don't generate not-null assertions on parameters of methods accessible from Java | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_no_receiver_assertions"></a>x_no_receiver_assertions | Don't generate not-null assertion for extension receiver arguments of platform types | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_optin"></a>x_optin | Define APIs to opt-in to. | List of strings | optional | [] |
|<a id="kt_kotlinc_options-x_report_perf"></a>x_report_perf | Report detailed performance statistics | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_sam_conversions"></a>x_sam_conversions | Change codegen behavior of SAM/functional interfaces | String | optional | "class" |
|<a id="kt_kotlinc_options-x_skip_prerelease_check"></a>x_skip_prerelease_check | Suppress errors thrown when using pre-release classes. | Boolean | optional | False |
|<a id="kt_kotlinc_options-x_use_k2"></a>x_use_k2 | Compile using experimental K2. K2 is a new compiler pipeline, no compatibility guarantees are yet provided | Boolean | optional | False |
| Name | Description | Type | Mandatory | Default |
|:-----------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| :------------- | :------------- |:---------|
| <a id="kt_kotlinc_options-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="kt_kotlinc_options-dump_processor_stats"></a>dump_processor_stats | [Report annotation processor performance statistics to provided file](https://kotlinlang.org/docs/kapt.html#measuring-performance-of-annotation-processors). Empty means reporting is disabled. | String | optional | Empty |
| <a id="kt_kotlinc_options-include_stdlibs"></a>include_stdlibs | Don't automatically include the Kotlin standard libraries into the classpath (stdlib and reflect). | String | optional | "all" |
| <a id="kt_kotlinc_options-java_parameters"></a>java_parameters | Generate metadata for Java 1.8+ reflection on method parameters. | Boolean | optional | False |
| <a id="kt_kotlinc_options-warn"></a>warn | Control warning behaviour. | String | optional | "report" |
| <a id="kt_kotlinc_options-x_allow_result_return_type"></a>x_allow_result_return_type | Enable kotlin.Result as a return type | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_backend_threads"></a>x_backend_threads | When using the IR backend, run lowerings by file in N parallel threads. 0 means use a thread per processor core. Default value is 1. | Integer | optional | 1 |
| <a id="kt_kotlinc_options-x_emit_jvm_type_annotations"></a>x_emit_jvm_type_annotations | Basic support for type annotations in JVM bytecode. | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_explicit_api_mode"></a>x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | "off" |
| <a id="kt_kotlinc_options-x_inline_classes"></a>x_inline_classes | Enable experimental inline classes | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_jvm_default"></a>x_jvm_default | Specifies that a JVM default method should be generated for non-abstract Kotlin interface member. | String | optional | "off" |
| <a id="kt_kotlinc_options-x_lambdas"></a>x_lambdas | Change codegen behavior of lambdas | String | optional | "class" |
| <a id="kt_kotlinc_options-x_multi_platform"></a>x_multi_platform | Enable experimental language support for multi-platform projects | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_no_call_assertions"></a>x_no_call_assertions | Don't generate not-null assertions for arguments of platform types | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_no_optimize"></a>x_no_optimize | Disable optimizations | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_no_optimized_callable_references"></a>x_no_optimized_callable_references | Do not use optimized callable reference superclasses. Available from 1.4. | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_no_param_assertions"></a>x_no_param_assertions | Don't generate not-null assertions on parameters of methods accessible from Java | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_no_receiver_assertions"></a>x_no_receiver_assertions | Don't generate not-null assertion for extension receiver arguments of platform types | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_optin"></a>x_optin | Define APIs to opt-in to. | List of strings | optional | [] |
| <a id="kt_kotlinc_options-x_report_perf"></a>x_report_perf | Report detailed performance statistics | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_sam_conversions"></a>x_sam_conversions | Change codegen behavior of SAM/functional interfaces | String | optional | "class" |
| <a id="kt_kotlinc_options-x_skip_prerelease_check"></a>x_skip_prerelease_check | Suppress errors thrown when using pre-release classes. | Boolean | optional | False |
| <a id="kt_kotlinc_options-x_use_k2"></a>x_use_k2 | Compile using experimental K2. K2 is a new compiler pipeline, no compatibility guarantees are yet provided | Boolean | optional | False |


<a id="define_kt_toolchain"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ internal fun JvmCompilationTask.runPlugins(
.plus(
kaptArgs(context, plugins, "stubsAndApt"),
)
.plus(
CompilationArgs(info.passthroughFlagsList),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little afraid of this one. Need to go look at the docs and make sure it can't get into arguments.

)
)
.flag("-d", directories.generatedClasses)
.values(inputs.kotlinSourcesList)
Expand Down
14 changes: 14 additions & 0 deletions src/rkt_1_7/starlark/kotlin/opts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def _map_jvm_target_to_flag(version):
return None
return ["-jvm-target=%s" % version]

def _map_dump_processor_stats_to_flag(dest_file):
if not dest_file:
return None
return ["-P\nplugin:org.jetbrains.kotlin.kapt3:dumpProcessorStats=%s" % dest_file]

_KOPTS = {
"warn": struct(
args = dict(
Expand Down Expand Up @@ -251,6 +256,15 @@ _KOPTS = {
value_to_flag = None,
map_value_to_flag = _map_jvm_target_to_flag,
),
"dump_processor_stats": struct(
args = dict(
default = "",
doc = "Report annotation processor performance statistics to provided file",
),
type = attr.string,
value_to_flag = None,
map_value_to_flag = _map_dump_processor_stats_to_flag,
),
}

KotlincOptions = provider(
Expand Down