Commit Graph

57 Commits

Author SHA1 Message Date
Svyatoslav Scherbina dcb34e0ec0 Native: mention cinterop libraries in the ExperimentalForeignApi KDoc
Now (mostly after 3f3f6eb) cinterop adds ExperimentalForeignApi to all
Kotlin declarations it generates from C and Objective-C libraries,
except for the platform libraries.
This commit changes the KDoc for ExperimentalForeignApi to reflect that
change.

^KT-58362
2023-07-25 17:18:00 +00:00
Yahor Berdnikau 5b5dae9249 [repo] Move buildSrc into repo/gradle-build-conventions/buildsrc-compat project
Include new project as build logic included build. Such change will
allow us to start migration into build convention plugins by splitting
buildSrc logic into subprojects.
2023-07-13 08:24:49 +00:00
Sebastian Sellmair 3f0130ecf1 [Gradle] Change 'UnsafeNumber' RequiresOptIn.level to 'ERROR'
^KT-59859 Verification Pending
^KT-55757 Verification Pending
2023-07-12 20:17:03 +00:00
Svyatoslav Scherbina 1bf3d55bdf Native: add detachObjCObject internal function for Obj-C objects
For a Kotlin wrapper of an Objective-C object, this functions zeroes
and releases the strong reference from the Kotlin wrapper to the
Objective-C object.
Usually, such a release happens only when the Kotlin wrapper is GCed.
So using this function can help that happen sooner.

^KT-59134
2023-06-07 11:57:54 +00:00
Vsevolod Tolstopyatov f4e8ae5191 Explicitly declare stability levels of declarations in kotlinx.cinterop package
* @ExperimentalForeignApi for all declarations that operate on
    unmanaged memory (i.e. pointers and references)
* @BetaInteropApi for the rest of the interoperability declarations,
    namely Swift/CInterop-specific interfaces and convenience-functions

### Implementation details

* Some typealiases are not marked explicitly because it crashes the compiler,
    yet their experimentality is properly propagated
* License header is adjusted where it previously had been existing
* Deprecated with ERROR interop declarations that are deprecated for more than
    two years are removed
* WASM target interop declarations are deprecated
* Deliberately make Boolean.toByte and Byte.toBoolean foreign-experimental to scare
    people away

^KT-57728 fixed

Merge-request: KT-MR-9788
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-05-04 13:52:21 +00:00
Abduqodiri Qurbonzoda 95f1d0b6ae [K/N] Internalize getNativeNullPtr() functions
As a part of efforts to stabilize Native stdlib.
2023-04-08 21:50:32 +03:00
Gleb Lukianets fc96eb6d8d [KN] CInterop: __attribute__((objc_direct)) support
Merge-request: KT-MR-8828
Merged-by: Gleb Lukianets <Gleb.Lukianets@jetbrains.com>
2023-03-02 10:36:53 +00:00
Pavel Punegov 71eaa43d95 [K/N][build] Move Native plugin to build-tools
This is K/N only plugin that shouldn't be
in the buildSrc of the whole Kotlin project
2023-02-27 10:48:27 +00:00
Pavel Punegov 395e3e0f81 [K/N][build] Composite build with build.tools-conventions plugin
Adds convention plugin instead of sources inclusion
inside the buildSrc, effectively reducing the amount
of the code to be compiled in buildSrc.

Merge-request: KT-MR-8898
2023-02-27 10:48:26 +00:00
Alexander Udalov 3c4b5529af Update year to 2023 in COPYRIGHT_HEADER.txt
This commit is the result of changing the year to 2023 in
COPYRIGHT_HEADER.txt and running all `generate*` tasks in
`generators/build.gradle.kts`.
2023-01-02 22:52:15 +01:00
Mikhail Glukhikh a22d7aea25 Native: don't set allWarningsAsErrors = true in K2 mode
Related to KT-54123
2022-09-29 15:32:01 +00:00
Alexander Udalov c410c5d3cd Do not reset freeCompilerArgs for some kotlin-native modules
Otherwise common compiler arguments which are set for all modules in the
project in `buildSrc/src/main/kotlin/common-configuration.gradle.kts`
are not applied. The most interesting of those are `-Xuse-k2` (if K2 is
enabled) and `-Xjvm-default=all`.
2022-09-27 11:04:31 +00:00
Nikita Bobko 2a4f3f41aa 2/5 Replace source dependency on kotlin-reflect with binary dependency
Review: https://jetbrains.team/p/kt/reviews/6753

Meaningful semantic change was splitted into 5 commits to simplify the
change review. Sinle commit would be too big.

Why replace source to binary: to get rid of kotlin-reflect in Kotlin
plugin artifact KTIJ-22276

Note: Kotlin Maven artifacts (./gradlew publish) changed their
dependency on kotlin-reflect
2022-08-22 15:43:49 +02:00
Svyatoslav Scherbina 2e8c25aeff Native: rewrite Kotlin_Interop_getObjCClass in Objective-C
This allows calling it in "Native" thread state.
2022-08-02 09:24:01 +00:00
Alexander Shabalin 29f3445721 [K/N] Deprecated freezing ^KT-50541
Starting with 1.7.20 freezing is deprecated. See https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md#freezing-deprecation for details.

Merge-request: KT-MR-6399
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2022-06-16 09:04:14 +00:00
Svyatoslav Scherbina 42ed0c5fe6 Native: add .alloc(value) for primitive types to interop runtime
^KT-50312 Fixed
2022-03-22 18:49:09 +03:00
Pavel Kirpichenkov 6674c3f482 [MPP] Apply @UnsafeNumber to functions and properties
KT-51224
KT-51215
2022-02-17 13:17:13 +03:00
Pavel Kirpichenkov f8a1395a03 [MPP] allow function and property targets for @UnsafeNumber annotation
KT-51224
KT-51215
2022-02-17 13:17:13 +03:00
Igor Chevdar f724b5c29d [K/N][gradle][interop] Workaround for loading readonly native libs 2022-01-14 10:29:12 +05:00
Igor Chevdar 993816a400 [K/N][runtime][interop] Refactoring to run cinterop in daemon 2022-01-14 10:29:05 +05:00
Igor Chevdar 353f82f9e6 Revert "[K/N][runtime][interop] Refactoring to run cinterop in daemon"
This reverts commit 47858126da.
2021-11-26 14:05:59 +05:00
Igor Chevdar 47858126da [K/N][runtime][interop] Refactoring to run cinterop in daemon 2021-11-25 23:42:09 +05:00
Svyatoslav Scherbina fb81ae0cd1 Native: fix deadlock in kotlinx.cinterop.typeOf impl for JVM
Don't use ConcurrentHashMap.computeIfAbsent for typeOf cache,
because the computation may call typeOf recursively for different type
(e.g. C enum var type computation calls typeOf for enum base integer type),
which might cause a deadlock in computeIfAbsent.
2021-09-22 07:31:22 +00:00
Pavel Kunyavskiy 91c6ee1ebb [K/N] Replace SymbolName with GCUnsafeCall in stdlib 2021-09-10 07:46:39 +00:00
Mikhail Glukhikh ed035d99ab Migrate -Xopt-in to -opt-in in Gradle Kotlin scripts 2021-09-03 15:40:47 +03:00
sebastian.sellmair bff62aba5f [Native] Implement 'kotlinx.cinterop.UnsafeNumber' interface
^KT-48459
2021-08-30 19:25:41 +00:00
Sergey Bogolepov 6e093b0beb [K/N] Update libffi for Windows
MinGW and MSVC are hardly compatible in case of static linkage, so we
need to use a native libffi.
2021-08-03 05:42:06 +00:00
Sergey Bogolepov a78fcd6b64 [K/N] Separate ClangArgs for jni and native
Since LLVM for Windows is now native instead on MinGW, we have to
compile code in a different environment in case of JNI. This commits
just separates ClangArgs into two subclasses without actual behavior
changes.
2021-08-03 05:42:05 +00:00
Alexander Gorshenev 9148094bbd Garbage collection capable wrappers for skia interop 2021-07-30 12:54:51 +03:00
Pavel Kunyavskiy d18ade088d [K/N] Help message for disabling quarantine flag on dylibs in distribution 2021-07-30 08:17:45 +00:00
Alexander Udalov 91c39ed01c Build: remove obsolete compiler arguments
These compiler arguments enable features which are enabled by default in
the current Kotlin anyway.

The only exception is in :compiler:cli which uses an old language
version.
2021-07-27 13:35:38 +02:00
Mikhail Glukhikh 47c8bab48e Replace -Xuse-experimental with -Xopt-in in codebase 2021-07-12 21:26:17 +03:00
Sergey Bogolepov 36386de9a2 [Native] Drop explicit -fPIC flag setup
We don't need to explicitly set -fPIC flag everywhere
because since d82109cc92
it is set by default for all ClangArgs users.
2021-06-11 12:18:14 +00:00
Svyatoslav Scherbina dc8934ab22 Native: fix crash in custom LLVM diagnostics handler
48a684c0 added custom LLVM diagnostic handler, using JvmCallbacks machinery,
thus triggered a bug in the latter: callbacks are cached and outlive the compilation session,
but rely on memory that is reclaimed at the end of the compilation session.
So during a subsequent compilation in the same process (e.g. when the compiler runs in the
Gradle daemon process), LLVM might call the callback which accesses the reclaimed memory, 
which in turn causes the crash.

Fix this by forcing JvmCallbacks to allocate memory that doesn't "expire" at the end of the compilation session.
2021-05-21 07:34:34 +00:00
Ilya Matveev 4d346d3735 [K/N][New MM] Support thread state switching
Including

* Support thread state switching in codegen
* Introduce and use GCUnsafeCall annotation
* Switch thread state in C++ runtime code

Also

* Register current thread in Mark&Sweep tests
* Store MemoryState in Worker instance
* Set worker tid in WorkerInit
2021-05-06 14:10:21 +00:00
Alexander Gorshenev 887032667d [Kotlin/Native][Interop] Skia interop plugin for cinterop 2021-04-29 21:43:26 +03:00
Abduqodiri Qurbonzoda 3a8d1c4b5e Remove redundant @OptIn 2021-04-16 19:01:28 +03:00
Ilya Gorbunov 7cd306950a Deprecate Char-to-Number conversions in stdlib (Native)
- Synchronize code of Ranges, Progressions, ProgressionIterators
- Suppress deprecations in regex implementation code

KT-23451
2021-04-07 18:30:21 +03:00
Ilya Gorbunov 833955e56d Migrate deprecations in Native compiler
Replacing deprecated Char.toInt() with Char.code and
Number.toChar() with Number.toInt().toChar(), where Number is not Int.

KT-23451
2021-04-07 18:30:21 +03:00
Svyatoslav Scherbina 65fa2f62bd Fix :kotlin-native:**:nativelibs Gradle tasks
These tasks did copy all files from build to build/nativelibs, thus
causing up-to-date checks to fail, and native libs and temporary build
files to be accumulated in recursive directories like
nativelibs/nativelibs/... in both build dirs and dist.

Fix this by copying only relevant files.
2021-04-02 14:13:48 +00:00
Svyatoslav Scherbina 1d96f810da Native: fix target for ReturnsRetained and ConsumesReceiver annotations
These annotations can be used on Objective-C property accessors imported
to Kotlin.
Note: the annotations aren't used in source code, only generated
directly to metadata by cinterop. So this commit doesn't in fact fix
anything but rather makes the implementation less fragile.

See https://github.com/JetBrains/kotlin-native/issues/3336.
2021-03-30 20:23:59 +00:00
Svyatoslav Scherbina a9d0409f2e Don't use Function.reflect() in kotlin-native/Interop on JVM
Use inline functions and typeOf<T>() instead
2021-03-19 06:53:09 +00:00
Alexander Udalov d9a9bd0136 Fix compilation of Interop/Runtime after fc36178f3a 2021-03-15 20:34:24 +01:00
Alexander Udalov c56f719dcc Fix/suppress some warnings
(cherry picked from commit d8a43c216925b3a9e1475b786978436835a57927)
2021-03-15 15:54:50 +03:00
Svyatoslav Scherbina 27904c0fb9 Native compiler source: replace inline classes by value classes
The former are deprecated.
2021-03-05 12:15:22 +00:00
Vasily Levchenko 65dd798818 [build][native support] intoduced new native support. 2021-02-24 11:07:18 +01:00
Vasily Levchenko 7b73917217 [build][dist] global dist fixed 2021-02-24 11:07:17 +01:00
Vasily Levchenko c85c3ac123 [build] joint (step 1)
(cherry picked from commit 7d0775f7e69ab900200bcf1fa78b94d68e6bd4f6)
2021-02-24 11:04:59 +01:00
Svyatoslav Scherbina f766a3eae4 Optimize CPointer.toKStringFromUtf8 on Native
Use strlen and stop allocating intermediate ByteArray
to make the performance comparable to ByteArray.decodeToString().

Partially fix KT-44357.
2021-02-24 10:53:42 +01:00
Vasily Levchenko 40959c756d Revert "Temporary remove all -Werror flags"
This reverts commit 89c09214eeed951684405c10c233304834a89beb.
2021-02-01 16:54:15 +01:00