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

Bzlmod: kotlin compiler is unconditionally downloaded #1106

Open
meteorcloudy opened this issue Jan 30, 2024 · 4 comments · May be fixed by #1126
Open

Bzlmod: kotlin compiler is unconditionally downloaded #1106

meteorcloudy opened this issue Jan 30, 2024 · 4 comments · May be fixed by #1126

Comments

@meteorcloudy
Copy link
Member

Reproducible case

https://github.com/meteorcloudy/my_tests/tree/master/rules_kotlin_test

$ bazel build //:bin
INFO: Invocation ID: f643fade-db51-4d9b-82ae-25bdb900fa0f
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=240
INFO: Reading rc options for 'build' from /Users/pcloudy/.bazelrc:
  'build' options: --verbose_failures --announce_rc --disk_cache=/tmp/bazel_disk_cache --repository_cache=/tmp/bazel_repository_cache
INFO: Analyzed target //:bin (45 packages loaded, 232 targets configured).
INFO: Found 1 target...
Target //:bin up-to-date:
  bazel-bin/bin
INFO: Elapsed time: 4.112s, Critical Path: 0.04s
INFO: 7 processes: 2 disk cache hit, 5 internal.
INFO: Build completed successfully, 7 total actions

Check the external repo directoires:

$ ls $(bazel info output_base)/external/rules_kotlin*
INFO: Invocation ID: e1aadea7-36c9-401e-9d4c-d5dfd89a62e6
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=0 --terminal_columns=80
INFO: Reading rc options for 'info' from /Users/pcloudy/.bazelrc:
  Inherited 'build' options: --verbose_failures --announce_rc --disk_cache=/tmp/bazel_disk_cache --repository_cache=/tmp/bazel_repository_cache
/private/var/tmp/_bazel_pcloudy/866f0b7a8d0e88178146ef74d48040fc/external/rules_kotlin~1.9.0:
BUILD.bazel      MODULE.bazel     WORKSPACE        WORKSPACE.bzlmod kotlin           src              third_party

/private/var/tmp/_bazel_pcloudy/866f0b7a8d0e88178146ef74d48040fc/external/rules_kotlin~1.9.0~rules_kotlin_extensions~com_github_jetbrains_kotlin:
BUILD.bazel      WORKSPACE        bin              build.txt        capabilities.bzl lib              license

The kotlin compiler is downloaded through com_github_jetbrains_kotlin even though building //:bin doesn't require it.

Cause

register_toolchains("//kotlin/internal:default_toolchain")

the default toolchain target depends directly on the kotlin compiler repo. This can be work around by defining the target in a config repo, which should avoid fetching the actual compiler.

@meteorcloudy
Copy link
Member Author

/cc @fmeum @comius Can you give some examples from rules_go or rules_java on how to fix this?

@meteorcloudy
Copy link
Member Author

Oh, probably it was caused by

load("@com_github_jetbrains_kotlin//:capabilities.bzl", _KOTLIN_OPTS = "KOTLIN_OPTS")

You should probably generate the capabilities.bzl file in a different repo:

repository_ctx.template(
"capabilities.bzl",
_get_capability_template(attr.compiler_version, attr._capabilities_templates),
executable = False,

meteorcloudy added a commit to meteorcloudy/bazel that referenced this issue Jan 30, 2024
@meteorcloudy
Copy link
Member Author

@Bencodes Do you have time to take a look at this?

@Bencodes
Copy link
Collaborator

Bencodes commented Feb 9, 2024

@meteorcloudy I believe @restingbull is looking into this one for you.

@restingbull restingbull linked a pull request Mar 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants