Commit Graph

2160 Commits

Author SHA1 Message Date
Victor Petukhov 5c8ca0ca9b [Compiler CLI] Use reading language version settings from environment only if the resource is presented or flag is set 2022-02-16 18:41:51 +03:00
Victor Petukhov 683a3e74a0 [Compiler CLI] Implement reading language version settings from environment variable
^KT-51306 Fixed
2022-02-16 18:41:50 +03:00
Mads Ager 66bf5b08ba Allow versionNeededToExtract between 0 and 20 in Zip impl.
In the Android eco-system, there are jars with entries with a
versionNeededToExtract of 0. That should probably have been 10,
but will be hard to fix. This change proposes to just check
that the versionNeededToExtract is between 0 and 20.
2022-02-09 13:01:12 +03:00
Alexander Udalov 25edf64daf Psi2ir: support mode without generation of bodies
This is needed for kapt + JVM IR.

 #KT-49682
2022-02-08 20:15:14 +01:00
Yahor Berdnikau 5320a32d67 Check also the cause of throwable for OOM exception
Sometimes OOM exception is the cause of some higher-level one
exception in compilation.

^KT-51116 Fixed
2022-02-07 13:59:48 +00:00
Alexander Udalov 6601b8b62c Write snapshot by chunks in ProfilingCompilerPerformanceManager.dumpProfile
To prevent OutOfMemoryError from converting the whole string to byte
array, in case the snapshot is very big (see KT-51058).

Also, remove 'framebuf' option from -Xprofile help, since async-profiler
2.0+ has unlimited frame buffer.
2022-02-03 22:09:44 +01:00
Alexander Udalov 6379fe4c4c JVM IR: link via descriptors instead of signatures by default
Doing so speeds up psi2ir ~2 times, and thus improves total compiler
performance by about 6-8%.

Unless JVM IR is in the mode where linking via signatures is the only
way (-Xserialize-ir, -Xklib), signatures are actually not needed at all,
SymbolTable can use the frontend representation (descriptors for FE1.0,
and hopefully FIR elements for K2) as hash table keys. The only catch is
that since other backends still need to work with signatures, all the
common IR utilities, such as irTypePredicates.kt, need to work correctly
for IR elements both with signatures and without.

Also, introduce a fallback compiler flag -Xlink-via-signatures, in case
something goes wrong, to be able to troubleshoot and workaround any
issues.

 #KT-48233
2022-02-03 02:48:05 +01:00
Dmitry Petrov bbad3e9e94 JVM collect additional performance metrics in FE1.0 + JVM_IR pipeline 2022-02-02 11:56:01 +00:00
Mads Ager e2c7290214 [JVM CLI] Prefer source over classpath.
If the class `A` is in a jar `previous.jar`, the following CLI
invocation will take that class instead of the `A` class
defined in `A.java`:

kotlinc -cp previous.jar A.java B.kt

This is problematic for build tools that put the jar for a
previous build on the classpath when recompiling some of the
files.

^KT-51025 Fixed.
2022-01-29 00:58:00 +01:00
Dmitriy Novozhilov aab66bd623 [FIR] Support rendering diagnostic names in CLI FIR compiler 2022-01-28 16:12:12 +03:00
Simon Ogorodnik 4c5eb9ac32 KT-50889: Fix caching of module descriptors in K2MetadataKlibSerializer
Previously, in case of repeated analysis, descriptors cached in
CommonDependenciesContainer was initialized multiple times

 #KT-50889 Fixed
2022-01-27 17:32:18 +00:00
Yahor Berdnikau 35ef8cc6da Show user-friendly message on OOM compilation error
This should provide a hint to user how to mitigate out-of-memory error
on compilation inside Kotlin daemon or in-process.

^KT-47522 Fixed
2022-01-24 10:30:53 +01:00
Dmitriy Novozhilov dd953908df [FE 1.0] Add compiler flag for rendering internal diagnostic names in error messages 2022-01-23 11:14:56 +03:00
Mikhael Bogdanov 92e893bebe Rework Tune module graph dependencies building
#KT-50701 In progress
2022-01-14 11:22:46 +00:00
Andrey Uskov 2adc851f1b Don't use global state for keeping incremental compilation state
Previously IC state was stored in System properties. As result parallel
compilation might cause incorrect state of IC, what led to corruption
of kotlin_module files. Now IC state is stored via CompilerArguments
and CompilerConfiguration
#KT-46038 Fixed
2022-01-12 13:37:46 +03:00
Irene Dea 374d287d08 Reorganize TypeAttributeTranslatorExtension 2022-01-08 15:26:38 +03:00
Irene Dea d444978ebf Add support for attribute serialization. 2022-01-08 15:25:07 +03:00
Irene Dea f2a351367c Implement unionTypeAttributes and replaceTypeAttributes in ConeInferenceContext 2022-01-08 15:25:07 +03:00
Irene Dea fad3c1f2f6 Add initial type attributes infra 2022-01-08 15:25:06 +03:00
Mikhael Bogdanov faa2a67180 Add Java17ModulesIntegrationTest tests, fix problem with wrong diagnostic 2021-12-23 07:26:03 +00:00
Mikhael Bogdanov 9221810d7f -Xjdk-release. Review fixes. Pass nullable jdkRelease 2021-12-23 07:26:01 +00:00
Mikhael Bogdanov a6052dce44 -Xjdk-release. Review fixes 2021-12-23 07:26:01 +00:00
Mikhael Bogdanov 3593e45b97 Rename 'RELEASE' fields into 'JDK_RELEASE' 2021-12-23 07:26:00 +00:00
Mikhael Bogdanov f5da166d7c Switch -jvm-target default to null 2021-12-23 07:25:59 +00:00
Mikhael Bogdanov 6379ed22d1 Calculate proper roots for JDK 10-11
#KT-29974
2021-12-23 07:25:59 +00:00
Mikhael Bogdanov a062eb04ac Release flag. Check conflicts with `-jvm-target' 2021-12-23 07:25:59 +00:00
Mikhael Bogdanov c2d17ded33 Release flag. Add diagnostics 2021-12-23 07:25:58 +00:00
Mikhael Bogdanov e5e3e9d326 Advanced modules supports
#KT-29974
2021-12-23 07:25:58 +00:00
Mikhael Bogdanov ae81aaa7b0 Tune module graph dependencies building 2021-12-23 07:25:57 +00:00
Mikhael Bogdanov 409d36c911 Basic -Xrelease option support
#KT-29974 Fixed
2021-12-23 07:25:57 +00:00
Mikhael Bogdanov 6026a96349 Add flag for ct.sym serch 2021-12-23 07:25:56 +00:00
Mikhael Bogdanov 22b3688493 Support sig files processing 2021-12-23 07:25:56 +00:00
sebastian.sellmair 3598ba1d45 [MPP][Test] Implement Diagnostics with mpp composite analysis tests
Using the 'MULTIPLATFORM_COMPOSITE_ANALYSIS_MODE' test directive
will add support for testing "cli metadata compilation" and
"ide analysis" _like_ configurations. In this configuration,
dependsOn modules will not be analyzed together with dependents in
the same ModuleDescriptor, but will be passed as separate 'expectedBy'
dependency descriptor.

Used to cover ^KT-50120 inside kotlin.git
2021-12-21 21:31:42 +00:00
Mads Ager b5b1b38cb0 [FE] Do not repeatedly load inner classes from class files.
Java protobufs generate a lot of inner classes and when compiling
Kotlin wrappers for those Java protobufs the inner classes can
be loaded hundreds of times leading to out of memory. This change
avoids reloading by fixing a bug in the cache implementation that
caused inner classes to not be cached.
2021-12-21 13:23:48 +03:00
Alexander Udalov 6acb0c3d06 CLI: load module-info from META-INF/versions/... for any version
Not just 9, since at least some libraries are putting module-info to
META-INF/versions/11 nowadays.

 #KT-48027 Fixed
2021-12-20 18:59:07 +01:00
Dmitriy Novozhilov 7bcd3c7948 [FIR] Add FirExtensionRegistrarAdapter to fix extension points in FE 1.0 IDE plugin
FirExtensionRegistrar is FIR specific extension which requires FIR
  classes to work, which are missing in dependencies of FE 1.0 IDE plugin.
  To fix this issue FirExtensionRegistrarAdapter is introduced. This
  class is a base class for FirExtensionRegistrar and it does not have
  any FIR specific classes in it's API, so it can be safely registered
  in IDE
2021-12-06 17:19:34 +03:00
Dmitriy Novozhilov ce218b8a0b [FIR] Make FirExtensionRegistrar a proper extension point
After that commit it's allowed to register any FIR plugin using
  existing extension infrastructure (`-Xplugin` CLI argument,
  plugin.xml for IDE plugins, etc)
2021-11-30 12:57:50 +03:00
Andrey Uskov 95648f1a9e Fix incremental compilation in some compiler plugins
If compiler plugin removes source files between rounds of incremental
compilation, it may result into incorrect state of stubs. But rebuilding
stubs may require services available in UI mode only and cause
compiler failure.
This commit contains work-around allowing to avoid incorrect state of
stubs.
#KT-49340 Fixed
2021-11-26 14:25:45 +03:00
Stanislav Erokhin 8a0969156f Do not set "idea.plugins.compatible.build" -- fix plugin update issue
In the IDEA plugin update there are a code that used system property
"idea.plugins.compatible.build" to calculate the IDEA version
that will be sent to plugin marketplace to download last version of
the plugins. It seems like by some reason setupIdeaStandaloneExecution()
was called from the IDEA thread and because of that idea version was
calculated incorrectly and incorrect version of the plugins was
downloaded.

It is still unclear how the setupIdeaStandaloneExecution() could be
called from the IDEA, so added logging for that.

Relevant issue: MP-3702
Relevant code in the IDEA:
- ApplicationInfoImpl.getPluginsCompatibleBuildAsNumber
2021-11-25 15:50:37 +03:00
Ivan Gavrilovic 684273783f Kotlin Gradle Plugin - clean caches for in-process compilation
This is to prevent file handle leaks on Windows. This
commit disposes KotlinCoreEnvironment used during
in-process compilation.

^KT-49772 Fixed
2021-11-18 16:20:10 +01:00
Alexander Udalov a7fef487c1 JVM IR: fix support of cyclic module dependencies
Previous episode was at 987a3460 (KT-45915).

Apparently, it's not enough to run psi2ir for all modules, and then
backend for all modules. If there are several modules in the chunk, IR
in any one of them can reference IR of any other one after psi2ir.

So we would end up in a situation where we're running codegen for the
first module, but the second module is completely unlowered. This would
break some assumptions in the codegen, for example in KT-49575, codegen
would see a reference to a top-level function from another module, and
would fail because the function has no containing class (since file
facades have not been generated yet!), and thus must be an intrinsic,
yet no such intrinsic is known to the codegen.

The solution is to run lowerings first on all modules, and then run
codegen on all modules. The kind of error explained above shouldn't be
possible anymore, because lowerings have to deal both with lowered and
unlowered code from other files all the time, so lowerings can't assume
that reference from other module is lowered either (or unlowered).

The code is not very nice, but hopefully it can be improved as soon as
we get rid of the old JVM backend (and maybe later with the migration to
FIR too).

 #KT-49575 Fixed
2021-11-16 20:20:20 +01:00
Alexander Udalov 38273e6b3c Minor, remove comments in JvmContentRoots.kt, suppress unused
The kdocs were almost self-evident, as opposed to the fact that
JvmClasspathRoot is unused in the project, which could make it a victim
of an innocent refactoring.
2021-11-16 02:20:52 +01:00
aragos 466acc6132 Allow the usage of virtual JVM content roots in kotlinc (#4645) 2021-11-16 02:20:40 +01:00
Alexander Udalov 73f0540d5b Remove runtime jar files version checker
... and the compiler argument -Xskip-runtime-version-check.

The vast majority of warnings reported by this checker in practice has
proven to be false positives. In addition to that, it was needlessly
verbose, and also completely untested.

If we decide to reintroduce some of these checks, it's probably a better
idea to perform them in tools, such as Kotlin Gradle plugin, which
usually have slightly more information about the way the project is
built and can suggest some meaningful solutions (as opposed to "remove
this jar $HOME/.gradle/... from the classpath" which was the best
JvmRuntimeVersionsConsistencyChecker could do.)

 #KT-27256 Obsolete
 #KT-41664 Fixed
2021-11-09 14:56:10 +01:00
Ilya Chernikov 70366dc7a6 Refactor diagnostic & result reporters...
to better reflect actual roles
2021-10-27 22:17:41 +02:00
Ilya Chernikov fc176e9845 Refactor IR reporting and infrastructure 2021-10-27 22:17:41 +02:00
Ilya Chernikov da2d3f29da Add multiple renderer sources support to new diagnostics infrastructure 2021-10-27 22:17:41 +02:00
Ilya Chernikov 1ce4075112 Prepare CLI reporting infrastructure for non-PSI diagnostics 2021-10-27 22:17:40 +02:00
Ilya Chernikov 9e60c70db7 Add abstract source element and switch diagnostics to it 2021-10-27 22:17:40 +02:00
Ilya Chernikov e9f59e8d1d Move common diagnostics infrastructure to frontend.common 2021-10-27 22:17:39 +02:00