-
Notifications
You must be signed in to change notification settings - Fork 213
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
[RFC] Add kotlinc option support in toolchain #303
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@@ -107,6 +108,10 @@ _kt_toolchain = rule( | |||
"1.3", | |||
], | |||
), | |||
"extra_copts": attr.string_list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably follow naming from java_toolchain
and be kotlincopts
https://docs.bazel.build/versions/master/be/java.html#java_toolchain.javacopts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context I plan to add javacopts
to kt_jvm_library
later, having kotlinc
and javac
prefixes is prob best to avoid confusion while also being on same page with rules_java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna lean towards a hard no on adding javacopts to the kt_jvm_lib. When IR becomes available, it would get dicey.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just quick question: what is IR
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna lean towards a hard no on adding javacopts to the kt_jvm_lib. When IR becomes available, it would get dicey.
Hold on, javacoptions
are for javac
call for .java
sources in mixed Kotlin/Java kt_jvm_library
, they have nothing to do with kotlinc
options :)
just quick question: what is
IR
?
Intermediate Representation, form of abstract (byte)code produced by Kotlin toolchain before it is transformed to actual instructions of the target platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, I'd agree, but the kotlin java compilation is currently interleaved. I'm taking a wait and see approach.
@@ -107,6 +108,10 @@ _kt_toolchain = rule( | |||
"1.3", | |||
], | |||
), | |||
"extra_copts": attr.string_list( | |||
doc = "The extra options for kotlinc compiler.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc = "The extra options for kotlinc compiler.", | |
doc = "The list of extra arguments for the Kotlin compiler. Please refer to the Kotlin compiler documentation for the extensive list of possible Kotlin compiler flags.", |
I was considering something closer to java_plugin. It makes maintaining, and assigning the plugin, a lot easier when bazel handles the paths. Additionally, I'm not thrilled with adding it to the toolchain -- compiler plugins have a lot of capabilities, and not all of them performant. I'd lean towards applying it on a library basis, as that allows fine tuning the performance of the build graph. Finally, I am very much against passing arbitrary flags to the compiler. Without validation, it can result in all sort of fun maintenance issues. And upgrade issues. Toolchains, and the usage of them, can very easily introduce surprise into a build. |
@restingbull I also think |
I also agree that compiler plugins should be supported similarly to however in general we need to be able to set other compiler options like |
@restingbull @cgruber any comments? We've been applying this approach in our fork to pass in kotlinc options and it works well. I agree with @artem-zinnatullin that this PR covers the part to provide a more general approach to pass in kotlinc options and |
@googlebot I signed it! |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
add back update optional fix compilation
951f2c9
to
0675cb2
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
The fact a compiler plugin is added via the compiler options enough for me that this approach is too loose. See #308 for a better plugin approach. The usages of the controlling validation I can see as reasonable, but since the compiler options are so unbounded, I really don't agree with this change. It's far better to start restrictive and open up, than to have things completely open at the start. With validation controlling the allowed options this is roughly ok. The compiler opts need to added to all kt_*, of course, to match the java rule paradigm. (for better or worse, it's familiar) |
Seems like we have a plugin implementation available. Close this PR and feel free to reopen it in the future if we decided to support passing general kotlinc option through toolchain. |
Proof of concept
Add kotlinc option support into kotlin rule's toolchain, then we can add kotlinc options