Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

JetBrains/kotlin-native

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date
Jan 21, 2020
Jan 27, 2020
Jan 21, 2020
Nov 4, 2019
Dec 27, 2019
Aug 27, 2019
Jan 20, 2020
Dec 19, 2019
Nov 28, 2019
Dec 25, 2019
Jan 23, 2020
Nov 13, 2019
Mar 21, 2019
Oct 31, 2019
Jan 13, 2020
Jan 24, 2020
Dec 21, 2019
Jan 24, 2020
Jan 20, 2020
Dec 27, 2019
Jan 17, 2020
Jan 21, 2020
Mar 18, 2019
Mar 30, 2017
Dec 18, 2019
Apr 5, 2019
Oct 3, 2019
Oct 17, 2018
Sep 19, 2018
Oct 26, 2018
Oct 25, 2019
Dec 2, 2019
Dec 9, 2019
Sep 13, 2018
Apr 30, 2019
Sep 30, 2019
Apr 30, 2019
Apr 28, 2017
Oct 2, 2018
Oct 25, 2019
Jan 30, 2019
Sep 28, 2019
Sep 28, 2019
Sep 30, 2019
Jan 23, 2020
Jan 22, 2020
Nov 28, 2019
Jul 10, 2019
Dec 3, 2019

Repository files navigation

official project version

Kotlin/Native

Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain.

Kotlin/Native is primarily designed to allow compilation for platforms where virtual machines are not desirable or possible (such as iOS or embedded targets), or where a developer is willing to produce a reasonably-sized self-contained program without the need to ship an additional execution runtime.

Prerequisites:

  • install JDK for your platform, instead of JRE. The build requires tools.jar, which is not included in JRE;
  • on macOS install Xcode 11
  • on Fedora 26+ yum install ncurses-compat-libs may be needed
  • on recent Ubuntu apt install libncurses5 is needed

To compile from sources use following steps:

First, download dependencies:

./gradlew dependencies:update

Then, build the compiler and libraries:

./gradlew bundle

To build with experimental targets support compile with -Porg.jetbrains.kotlin.native.experimentalTargets.

The build can take about an hour on a Macbook Pro. To run a shorter build with only the host compiler and libraries, run:

./gradlew dist distPlatformLibs

To include Kotlin compiler in composite build and build against it, use the kotlinProjectPath project property:

./gradlew dist -PkotlinProjectPath=path/to/kotlin/project

It's possible to include in a composite build both Kotlin compiler and Kotlin/Native Shared simultaneously.

After that, you should be able to compile your programs like this:

export PATH=./dist/bin:$PATH
kotlinc hello.kt -o hello

For an optimized compilation, use -opt:

kotlinc hello.kt -o hello -opt

For tests, use:

./gradlew backend.native:tests:run

To generate interoperability stubs, create a library definition file (refer to samples/tetris/.../sdl.def), and run the cinterop tool like this:

cinterop -def lib.def

See the provided samples and INTEROP.md for more details.

The Interop tool generates a library in the .klib library format. See LIBRARIES.md for more details on this file format.