Commit Graph

3300 Commits

Author SHA1 Message Date
Dmitriy Dolovov e92017f64e [KLIB Resolver] Deprecate Logger.fatal()
Invocation of Logger.fatal() may cause severe side effects such as
throwing an exception or even terminating the current JVM process
(check various implementations of this function for details).

The code that uses Logger.fatal() sometimes expects a particular kind
of side effect. This is totally a design flaw. And it's definitely not
a responsibility of Logger to influence the execution flow of
the program.
2024-01-08 13:26:24 +00:00
Pavel Kunyavskiy f45d92eebc [K/N, K/JS, K/WASM] Enable FakeOverrideRebuilder by default
While not beeing final solution, this is closer to what
we want to have in the end. Enabling on non-JVM targets
would help better testing.

Enabling in JVM is now not possible yet, as some of the bugs are
not fixed yet (check KT-61360 for details)

^KT-62476
2024-01-08 07:46:07 +00:00
Alexander Shabalin 3f2584bb02 [K/N] Move calls checker into separate module ^KT-62091 2024-01-05 13:35:35 +00:00
Dmitriy Novozhilov 8ff869a08c [FIR] Unregister FirJavaElementFinder at the Project disposing
^KT-64433 Fixed
2024-01-05 10:23:04 +00:00
Troels Bjerre Lund b668433256 [CLI] Add cache for reflection lookup of CLI arguments
Add cache for reflection lookup of CLI arguments.

Replace CLI argument list with map.

The current cli parser tries to match every possible command line
argument against each command line argument, essentially in a double
loop. This fix replaces one of the loops with a map lookup. Building the 
map is not expensive, and pays for itself even with a modest number of
parameters. The map is cached between calls, making subsequent calls
much cheaper. If run in a daemon, repeatedly parsing, e.g., 250 
arguments, this speeds up argument parsing by a factor 20. 

Disallow -shortName=value in CLI arguments.

Co-authored-by: Troels Lund <troels@google.com>
2023-12-19 17:05:03 +00:00
Marco Pennekamp 32fe29b8cc [Test] Add debug names to unnamed test disposables
- This helps to track down disposables which are never disposed, and
  reduces confusion when printing disposables in general (the names will
  now be meaningful, instead of endless lists of "newDisposable" and
  "TestDisposable").

^KT-64099
2023-12-19 11:12:23 +00:00
Marco Pennekamp bba5447b12 [Test/AA] Pass project disposable to getOrCreateApplicationEnvironment instead of application disposable
- The disposable passed to `getOrCreateApplicationEnvironment` should
  not actually be the application environment's disposable, which is
  created inside the function. Instead, it should be the project's
  disposable, which is used to track how many projects still rely on the
  shared application environment.
- This issue wasn't apparent before because there is no visible
  consequence when an application isn't disposed after all projects have
  been disposed (during tests). However, the solution for KT-63650
  relies on application environments being disposed after all projects
  are disposed, so that a new application environment with a different
  configuration can be created. (Only one shared application environment
  may be active at the same time.)

^KT-63650
2023-12-19 11:12:23 +00:00
Artem Kobzar 2530cba82a [K/JS] Compile Kotlin coroutines as JS generator ^KT-63038 Fixed 2023-12-18 17:13:07 +00:00
Dmitriy Dolovov b1093d8082 [KLIB Resolver] Don't discriminate KLIBs by duplicated unique_name in K2 metadata compiler
Use the same approach as in K1 metadata compiler: resolve each library
separately from others, don't attempt to resolve them all at once.

^KT-63573
2023-12-18 13:03:40 +00:00
Dmitriy Dolovov 46081f968d [KLIB Resolver] Report KLIB resolver issues as compiler messages
The reason of this change is to make messages (especially warnings)
that are reported by the KLIB resolver become visible to the end user.
This can be achieved to forwarding such messages to the appropriate
compiler's components such as
`org.jetbrains.kotlin.cli.common.messages.MessageCollector` and
`org.jetbrains.kotlin.ir.util.IrMessageLogger`.

Also: The default `DummyLogger` should be used as minimal as possible.
Because it just forwards messages to the standard output (console)
where they can remain unattended. When the compiler is executed
from the Gradle plugin such messages appear only in DEBUG Gradle's log.

^KT-63573
2023-12-18 13:03:40 +00:00
Dmitriy Novozhilov f4e3203cd8 [FIR] Unregister java element finders from previous sessions
The problem here is that for common session we register `FirJavaElementFinder`
  which provides light classes based on expect classes. And then
  at the start of analysis of jvm module we register one another
  `FirJavaElementFinder`, which sees actual classes and uses them to
  build light classes

But, because class ids of expect and actual class pair are the same and
  element finders are ordered by creation order, when java resolve tries
  to resolve some class, it founds light class based on expect class,
  even if we are already in platform session

To fix this problem, it was decided to unregister all previous element
  finders on creation of each new session, so old finders won't interfere
  with analysis

^KT-63612 Fixed
^KT-64296
2023-12-14 09:51:15 +00:00
Ivan Kochurkin 145958e284 [K2] Disable constants evaluation with native metadata compilation
^KT-63835 Fixed
2023-12-08 16:38:04 +00:00
Troels Bjerre Lund 4f77434ea5 [K/N] Remove LLVM coverage
The -Xcoverage feature has not worked and has been disabled for a while.
This fix removes it, and all of its uses.


Co-authored-by: Troels Lund <troels@google.com>


Merge-request: KOTLIN-MR-821
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-12-06 14:07:16 +00:00
Dmitriy Novozhilov 1cdc8361d6 [IR] Rename IrAnnotationsFromPluginRegistrar to IrGeneratedDeclarationsRegistrar
In further commits, this service will be used not only for registering
  annotations, but newly generated IR declarations too
2023-12-05 10:21:27 +02:00
Svyatoslav Kuzmich e901629cf0 [Wasm] Support WASI target in K2
- Support WASI mode in CLI and test infrastructure
- Add external declaration checker
- Split Fir diagnostic lists into Base, JS and WASI

#KT-56849 Fixed
2023-11-28 11:51:53 +00:00
Dmitriy Novozhilov e38b25c278 [FIR2IR] Make convertAndActualize method the only entrypoint to fir2ir
Fir2Ir conversion consists of multiple steps with complex logic (like
  conversion of each module, actualization, plugins application, constant
  evaluation), and to ensure that they all are executed correctly it's
  convenient to have the single entry point for all this machinery
2023-11-27 10:17:54 +00:00
Dmitriy Dolovov b1c9791404 [Native] Warn on any usage of -repo CLI option
^KT-61098
2023-11-21 09:36:07 +00:00
Marco Pennekamp 1870189e47 [AA] Fix write access configuration in unit test application environments
- We cannot configure the application's write action accessibility on a
  per-test basis because (1) the application may be shared across
  concurrent tests and (2) the application is usually cached, so the
  configuration will be missed entirely.
- There is actually a much easier solution to allow write access
  selectively: We can enable it in `runWriteAction` blocks, and keep it
  in a thread local to support concurrent test runs. As Analysis API
  tests never call `runWriteAction`, there will be no "analyze cannot be
  called from a write action" error, and if `analyze` is somehow called
  from a write action, it will now be caught.

^KT-63560 fixed
2023-11-20 16:29:26 +00:00
Pavel Kunyavskiy 021a00f4ff [IR] Avoid depending from fir2ir on ir.actualization module
^KT-62292
2023-11-20 08:31:41 +00:00
Artem Kobzar 1832f5a3f7 [K/JS] Introduce the ability to consume platform-specific cli arguments inside the main function ^KT-16981 Fixed 2023-11-18 11:01:34 +00:00
Kirill Rakhman 4964ee12a9 [CLI] Update CLI argument descriptions after review 2023-11-17 14:36:28 +00:00
Yahor Berdnikau 3413b07550 [IC, Gradle] Remove 'kotlin.incremental.useClasspathSnapshot' system property
^KT-62962 Fixed
2023-11-17 11:34:19 +00:00
Marco Pennekamp 03a7162f37 [AA] Enable test-specific configuration of write access permissions
- In general, Analysis API tests forbid write access because the
  Analysis API should not be used from write actions. However, in some
  cases we might want tests to e.g. modify PSI, which requires write
  access. This change allows `AnalysisApiTestConfigurator`s to enable
  write access for the specific test.
2023-11-16 19:50:51 +00:00
Dmitriy Dolovov e7b8f3ecde [Native] Deprecate KLIB repositories in Kotlin/Native compiler
1. Log warnings on usage of KLIB repositories.
2. Don't block using repositories for now.

^KT-61098
2023-11-15 19:38:24 +00:00
Pranav 6c7963fe47 fix: Fix memory leak in ZipImplementation with -Xuse-fast-jar-file-system
When using the compiler with `-Xuse-fast-jar-file-system` enabled, the compiler causes memory leak in ZipImplementation class at MappedByteBuffer.contentsToByteArray method since the Inflater used to deflate zip/jar files, isn't released/ended after the task.
2023-11-13 10:04:39 +00:00
Chris Povirk 72c9378500 Fix error message for -Xjspecify-annotations.
The message currently claims that you can pass the value "disable," but
in fact the value it means is "ignore."
2023-11-13 09:59:27 +00:00
Ilya Kirillov 6f097dc8f6 Introduce utility function for specifying compiler argument names
^KT-63294
2023-11-08 17:32:48 +00:00
Alexander Udalov 4fca52b66c FIR entrypoint: deduplicate some code and remove JVM dependency
Deduplicate Fir2IrExtensions creation and move the
convertToIrAndActualizeForJvm function to 'cli', which allows to remove
the dependency of 'fir.entrypoint' on 'backend.jvm'.

Note that behavior slightly changes in IncrementalFirJvmCompilerRunner:
previously the value of linkViaSignatures was always false, now it is
taken from the compiler configuration, which seems more correct.
2023-11-06 08:49:04 +00:00
Ilya Chernikov b3d33aee19 HMPP, IC: Implement shared provider for IC class files
#KT-61942 fixed
temporary solution, see comments for details
2023-11-02 11:03:37 +00:00
Ilya Chernikov 76eda0095e HMPP: Fix isCommon calculation for the K2 HMPP case 2023-11-02 11:03:37 +00:00
Alexander Udalov 4f96171716 K2: report IR_WITH_UNSTABLE_ABI_COMPILED_CLASS
Also, remove setting the value of allowUnstableDependencies to true if
K2 is used because we want K2 to report errors (as K1 does) on
unstable-ABI dependencies.

 #KT-61598 Fixed
2023-10-31 10:39:43 +00:00
Ivan Kochurkin 1827df82c4 Removed useless as casts from compiler code
It allows compiling code with K2 and enabled `-Werror`
2023-10-24 20:59:56 +00:00
Ivan Kylchik 2af73c2b13 [FIR] Add FirJavaElementFinder to session's components
This change allows us to use `IrInterpreter` to evaluate Kotlin's
const properties that were called from Java world

#KT-57802
2023-10-20 16:33:20 +00:00
Nikolay Lunyak ba9baa7457 [FIR] Don't enable features without sinceKotlin in Progressive Mode
There are two BUG_FIX features that have
been added to the compiler, without a clear
decision to enable them somewhere in the
future. Since there is no decision to
force users rewrite their code, such
features should not be enabled in
Progressive Mode.

^KT-62644 Fixed
^KT-62143 Fixed
2023-10-18 13:16:10 +00:00
Ilya Goncharov a79324037d [JS] Fix JPS artifacts cordinates 2023-10-16 13:34:37 +00:00
Svyatoslav Kuzmich a10042f909 [Wasm] Add K2 checkers.wasm module (KT-56849)
Add first K2 checker ExternalInheritanceChecker to test the infra
2023-10-12 13:26:58 +00:00
Simon Ogorodnik 024e94a479 [K2] Document KMP implementation in the K2 Compiler
Add comprehensive documentation explaining the implementation and
functions of the Kotlin multiplatform (KMP) support in the K2 Compiler.
2023-10-12 12:27:54 +00:00
Alexander Udalov 9164b7d405 K2 kapt: remove reference to "kapt 4" from the warning
#KT-62438 Fixed
2023-10-09 16:08:45 +00:00
Stanislav Erokhin 0cfa721585 [KMP] Remove experimental from -Xmulti-platform flag
#KT-61686
2023-10-04 18:19:35 +00:00
Artem Kobzar eef57f216c [K/JS] Rework main function call to support it in per-file 2023-10-04 12:13:20 +00:00
Dmitriy Dolovov 78a962f6d2 [KLIB] Deprecate -Xexpect-actual-linker CLI argument
This argument has been finally superseded by `-Xmetadata-klib`.

^KT-61136
2023-10-02 16:21:17 +00:00
Alexander Korepanov 522952db1f [JS IR] Run diagnostics by IR before the klib serialization
Implement an infrastructure for checking IR before JS klib serialization.
Implement the EXPORTING_JS_NAME_CLASH and EXPORTING_JS_NAME_CLASH_ES checks.

^KT-61710 Fixed
2023-09-23 19:49:17 +02:00
Dmitriy Novozhilov 9e5ee3afa0 [FE] Add isLocal name to ClassId constructor calls where it needed 2023-09-21 12:40:44 +00:00
Mikhail Glukhikh a77b758efa LV 2.0: drop reporting FIR_COMPILED_CLASS and relevant stuff
#KT-62056 Fixed
Related to KT-59171, KT-61951
2023-09-21 11:14:09 +00:00
Dmitriy Dolovov 38a67f3d30 [KLIB] Use -Xmetadata-klib to produce metadata KLIBs
With this change a new `-Xmetadata-klib` CLI flag becomes the
preferable way to instruct K2MetadataCompiler to produce metadata
KLIBs. The old `-Xexpect-actual-linker` flag still works for
K2MetadataCompiler, but that would last just for a short transition
period until the necessary changes are made in the Gradle plugin.

The K2NativeCompiler does not work anymore with `-Xexpect-actual-linker`
and respects only the `-Xmetadata-klib` flag. This is not an
issue since the Gradle plugin anyway supplies both flags for Native
metadata compilations.

^KT-61136
2023-09-20 22:26:36 +00:00
Dmitriy Dolovov 848c88b1a5 [KLIB] Lift up -Xmetadata-klib CLI key from Native to Common args
This is a precondition for obsoleting and finally removing
`-Xexpect-actual-linker` CLI key, which became useless since
the removal of ExpectActualTable.

^KT-61136
2023-09-20 22:26:36 +00:00
Ilya Chernikov e5ee364419 IC: Implement expect/actual tracking
fixes NewMultiplatformIT.testIncrementalCompilation
also #KT-61590 fixed
2023-09-19 15:46:30 +00:00
Mikhail Glukhikh 91acabc286 K2: don't use FastJarFS if output jar is used in classpath (KT-61883) 2023-09-19 15:46:29 +00:00
strangepleasures 8fb7ea1126 [KAPT4] KT-61333 Support REPORT_OUTPUT_FILES
Add extra logging
2023-09-15 11:05:05 +00:00
Pavel Kunyavskiy 9a9598c16b [Klib] Run prerelease checker in all backends
The checker also checks the metadata version, which
would be handled separately. Now it would never
emmit this error for klib-based backends.

^KT-61773
^KT-61596
^KT-55809
2023-09-15 09:48:42 +00:00