74 Commits

Author SHA1 Message Date
Alexander Shabalin 3a5f33e9cd [K/N] Convert :kotlin-native:klib
Use folder structure from the rest of the project and build it by
the bootstrap compiler.
2024-03-05 21:47:43 +00:00
Dmitriy Dolovov 5e81850bb1 [KLIB tool] Don't sort declarations in "dump-metadata" command
Instead, let the command print declarations in the program order.
Do sorting only in special "test mode".

^KT-62340
2024-02-22 22:21:30 +00:00
Yahor Berdnikau 6b19b8b9d0 [Repo] Don't use kotlinOptions in repo build scripts
^KT-63419 In Progress
2024-02-22 14:48:10 +00:00
Dmitriy Dolovov 795ee9f26d [KLIB tool] "dump-metadata-signatures": exclude fake overrides
There are few reasons why fake overrides should not be printed:

1. Fake overrides are not serialized in metadata. So, if one will run
   "dump-metadata" they won't see there any fake overrides. Neither
   their signatures. It would be inconsistent if
   "dump-metadata-signatures" command would show them.

2. In order to properly build fake overrides the KLIB tool needs
   the dependency library with the super class or interface, which
   is not available unless this is stdlib or one of the built-in
   Kotlin/Native platform libraries. KLIB tool does not support any
   reasonable means for passing dependencies through CLI arguments.
   If such possibility is added in the future, it would be the
   right time to support printing fake overrides (probably under
   a separate CLI option).

^KT-62340
2024-02-20 11:52:26 +00:00
Dmitriy Dolovov f4f609bea7 [KLIB tool] "dump-metadata-signatures": exclude private declarations
Don't print signatures computed for private declarations. This
effectively means that only signatures for `public`, `protected`,
and `internal` declarations will be printed.

Note: This new behavior is intact with `dump-ir-signatures` command.

^KT-62340
2024-02-20 11:52:26 +00:00
Dmitriy Dolovov d18afff12b [KLIB tool] "dump-metadata-signatures" command: use stable sorted order
Print the signatures computed by the metadata always in stable sorted
order.

^KT-62340
2024-02-20 11:52:26 +00:00
Dmitriy Dolovov 215303606b [KLIB tool] Entry point for tests: org.jetbrains.kotlin.cli.klib.Main.exec
^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 16a27c2e05 [KLIB tool] Split KlibToolCommand into multiple individual commands
^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 358ad272f4 [KLIB tool] Extract class KlibToolCommand from main.kt
^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 9878c1fa16 [KLIB tool] Introduce KlibToolOutput for capturing stdout and errors/warnings
With `KlibToolOutput` it's possible to forward the output of each
KLIB tool's command to either system stdout/stderr streams or to
some buffers which then can be read by tests.

^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 5b7c11ae39 [KLIB tool] Introduce a '-test-mode' CLI option
This is an option that allows running the commands that support it
in a special "test mode". The "test mode" means (but not limited to)
that a command may, for example, sort the output which is unsorted
by default, and this way guarantee stable output. This is essentially
helpful for tests, which rely on the command output.

^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 82115c1f26 [KLIB tool] Drop unused blind flag in "remove" command
^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 77b574bd0d [KLIB tool] Rename class Library -> class KlibToolCommand
Also, make it use `KlibToolArguments` instead of separate isolated
arguments passed via constructor or via individual command calls.

^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 7aa106c3a0 [KLIB tool] Extract self-sufficient classes from main.kt to separate files
Classes extracted:
- KlibToolArguments
- KlibToolArgumentsParser
- KlibToolLogger
- KlibToolIrLinker

^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 4fe8885376 [KLIB tool] Split KlibToolArguments to arguments & arguments parser
^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 02ab472f0b [KLIB tool] Rename: class Command -> class KlibToolArguments
This way it would better reflect its purpose.

^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov 921a787815 [KLIB tool] Move all CLI-related logic to the Command class
^KT-62340
2024-02-19 09:36:10 +00:00
Dmitriy Dolovov d4585ff3ce [KLIB tool] Refactoring. Fix visibility, add comments, drop useless code
What's done:
- Reduce the visibility of all entities inside the module to `internal`
  or `private`. Only leave `fun main()` as `public` because it's the
  single legal entry point.
- Add comments to few classes related to "contents" command that they
  should be removed together with the command after 2.0.
- Drop useless `DeclarationHeaderRenderer` interface.
- Rename: KlibToolLinker -> KlibToolIrLinker

^KT-62340
2024-02-19 09:36:10 +00:00
Leonid Startsev a6cdf27204 Fix compilation of :tools:kotlinp-klib and related projects
Conflicting PRs https://jetbrains.team/p/kt/reviews/14253 and https://jetbrains.team/p/kt/reviews/14384/files
were merged too close to each other for Safe-Merge to catch the problem and therefore resulted in compilation error.
2024-02-15 17:15:58 +00:00
Dmitriy Dolovov f9f97f2050 [KLIB tool] Support metadata format by kotlinp
Use the unified metadata printing format in KLIB tool. The same format
is already used in `kotlinp` CLI tool.

^KT-62340
2024-02-15 15:38:27 +00:00
Alexander Shabalin 4468167a64 [K/N] Move kotlin-native/utilities/basic-utils to compiler/utils 2024-02-08 20:43:11 +00:00
Dmitriy Dolovov 478205e6e8 [build] Don't use dependencies on Native backend in KLIB tool
^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov c1a4c33301 [build] Migrate kotlin-native/klib/build.gradle to KTS
^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov ca0c2f1405 [KLIB tool] Introduce a new CLI command: "dump-abi"
With this command it is possble to make an ABI snapshot of any IR-ful library

^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov 9d6266d6ad [KLIB tool] Use more correct wording in HELP output
"dump ... of all public declarations"
->
"dump ... of all non-private declarations"

^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov ab09a3d0fe [KLIB tool] Dump metadata for all non-private declarations
This is done to make the output of "dump-metadata" command consistent
with the output of "dump-metadata-signatures" and "dump-ir-signatures",
which dump signatures for all non-private declarations.

^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov 1f3da86021 [KLIB tool] Don't print stack trace on CLI args parsing errors
^KT-62340
2024-01-30 16:12:56 +00:00
Pavel Punegov cdb6a06e49 [K/N][test] Move ZipTest to compiler/util-io tests
This is the last test in the Klib and was run separately.
Instead, it should be located with 'kotlin-util-io' project which it tests


Merge-request: KT-MR-13978
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2024-01-23 11:01:58 +00:00
Dmitry Savvinov 77ebe1085d [klib tool] Return unbound symbols for dump-ir mode
This is more convenient behaviour for debugging with klib-tool than
just failing.

Note that enabling Partial Linkage globally in klib-tool is undesirable,
as it can auto-tweak IR (e.g. when overrides do not match), thus
distorting the rendered IR

^KT-61143 Fixed
2024-01-22 17:11:56 +00:00
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
Ilya Gorbunov d2aae67e03 Replace kotlin-test project dependencies in the project
Use dependency helper function that chooses whether to take them
from the bootstrap repository or from a configuration of kotlin-test

KT-61969
2023-12-13 15:40:25 +00:00
Dmitriy Dolovov ede77ea29c [KLIB tool] Warn on unknown CLI options 2023-11-21 09:36:07 +00:00
Dmitriy Dolovov b1c9791404 [Native] Warn on any usage of -repo CLI option
^KT-61098
2023-11-21 09:36:07 +00:00
Dmitriy Dolovov aa9b901926 [KLIB tool] Migrate 'dump-metadata' tests to K/N test infra 2023-10-27 09:28:00 +00:00
Dmitriy Dolovov 57e004e2b0 [KLIB tool] Respect '-signature-version' in 'dump-metadata' and 'dump-ir' commands 2023-10-27 09:28:00 +00:00
Dmitriy Dolovov c34e334550 [KLIB tool] Rename "signatures" to "dump-metadata-signatures"
To make KLIB tool command names more uniform.
2023-10-27 09:28:00 +00:00
Dmitriy Dolovov 8f141e5dc6 [KLIB tool] Minor. Update usage info 2023-10-27 09:28:00 +00:00
Dmitriy Dolovov a49723e35c [KLIB tool] Minor. Rename ir() to dumpIr() 2023-10-27 09:27:59 +00:00
Dmitriy Dolovov 02f52371c1 [KLIB tool] Rename "contents" to "dump-metadata"
To make KLIB tool command names more uniform.
2023-10-27 09:27:59 +00:00
Dmitriy Dolovov d8d95fdf4b [KLIB tool] Deprecate usage of KLIB repositories
^KT-61098
2023-10-27 09:27:59 +00:00
Dmitriy Dolovov 5961710db3 [KLIB tool] Don't print stack trace on trivial errors
1. Don't need to print stack trace on trivial errors such as invalid
CLI argument or incompatible library version.

2. Re-organization of `logWarning()` & `logError()` calls inside
the klib tool.
2023-10-27 09:27:59 +00:00
Dmitriy Dolovov 8ca62ad656 [KLIB tool] Fail with an adequate error message on IR-less KLIBs
^KT-62341
2023-10-27 09:27:59 +00:00
Dmitriy Dolovov 4b2776e126 [KLIB tool] Introduce new command: dump-ir-signatures
^KT-62341
2023-10-27 09:27:59 +00:00
Dmitriy Dolovov 447b0eddac [KLIB tool] Drop useless arg: -target 2023-10-27 09:27:59 +00:00
Dmitriy Dolovov b0c1cbff32 [KLIB tool] Minor. Reformat usage info 2023-10-27 09:27:59 +00:00
Pavel Kunyavskiy 2b8b6a2b21 [IR] Split FakeOverrideBuilder to two parts
Now there is separate class encapsulating logic about how to build
fakeOverrides and one encapsulating logic of which classes
do need building fake overrides.

This also allows to untie strange inheritance dependencies.

^KT-61934
2023-09-24 16:11:49 +00:00
Dmitriy Dolovov fa34021a04 [Native][tests] Fix KLIB contents tests 2023-09-22 05:56:22 +00:00
Alexander.Likhachev 357d12fc8e [Build] Move JUnit dependencies into the version catalog
The `kotlin-test` dependencies are left untouched as changing them affects publications, thus these versions are independent from the used inside our build
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Dmitrii Krasnov ade88e2b0f Fixed konan.data.dir with caches
Removed TODOs after updating to kotlin bootstrap version with konan.data.dir gradle property changes

Fixed warning of incorrect passing -Xkonan-data-dir arg in konanc from KGP and fixed setting konan-data-dir in SetupConfiguration#setupCommonOptionsForCaches

#KT-60660 Fixed

Merge-request: KT-MR-11299
Merged-by: Dmitrii Krasnov <Dmitrii.Krasnov@jetbrains.com>
2023-08-22 07:56:26 +00:00
Johan Bay fafea27283 [klib tool] Add option to print ir
Dumping the IR from a klib is useful for debugging klib compilations.

^KT-58877
2023-07-31 09:45:19 +00:00