Mention -Xoverride-konan-properties in HACKING.md
This commit is contained in:
committed by
Stanislav Erokhin
parent
93f9caf568
commit
42d416e0e7
@@ -274,6 +274,13 @@ You can replace its value with either `$llvm.<HOST_NAME>.{dev, user}` to use one
|
|||||||
or pass an absolute to your own distribution.
|
or pass an absolute to your own distribution.
|
||||||
Don't forget to set `llvmVersion.<HOST_NAME>` to the version of your LLVM distribution.
|
Don't forget to set `llvmVersion.<HOST_NAME>` to the version of your LLVM distribution.
|
||||||
|
|
||||||
|
#### Example. Using LLVM from an absolute path.
|
||||||
|
Assuming LLVM distribution is installed at `/usr` path, one can specify a path to it
|
||||||
|
with the `-Xoverride-konan-properties` option:
|
||||||
|
```
|
||||||
|
konanc main.kt -Xoverride-konan-properties=llvmHome.linux_x64=/usr
|
||||||
|
```
|
||||||
|
|
||||||
### Playing with compilation pipeline.
|
### Playing with compilation pipeline.
|
||||||
|
|
||||||
Following compiler phases control different parts of LLVM pipeline:
|
Following compiler phases control different parts of LLVM pipeline:
|
||||||
@@ -284,18 +291,18 @@ Following compiler phases control different parts of LLVM pipeline:
|
|||||||
For example, pass `-Xdisable-phases=BitcodeOptimization` to skip optimization pipeline.
|
For example, pass `-Xdisable-phases=BitcodeOptimization` to skip optimization pipeline.
|
||||||
Note that disabling `LinkBitcodeDependencies` or `ObjectFiles` will break compilation pipeline.
|
Note that disabling `LinkBitcodeDependencies` or `ObjectFiles` will break compilation pipeline.
|
||||||
|
|
||||||
By default, compiler takes options for Clang from [konan.properties](konan/konan.properties) file
|
Compiler takes options for Clang from [konan.properties](konan/konan.properties) file
|
||||||
by combining `clangFlags.<TARGET>` and `clang<Noopt/Opt/Debug>Flags.<TARGET>` properties.
|
by combining `clangFlags.<TARGET>` and `clang<Noopt/Opt/Debug>Flags.<TARGET>` properties.
|
||||||
To override this behaviour, one can specify flag `-Xoverride-clang-options=<arg1, ..., argN>`.
|
Use `-Xoverride-konan-properties=<key_1=value_1; ...;key_n=value_n>` flag to override default values.
|
||||||
|
|
||||||
Please note:
|
Please note:
|
||||||
1. Kotlin Native passes bitcode files to Clang instead of C or C++, so many flags won't work.
|
1. Kotlin Native passes bitcode files to Clang instead of C or C++, so many flags won't work.
|
||||||
2. `-c` should be passed because Kotlin/Native calls linker by itself.
|
2. `-cc1 -emit-obj` should be passed because Kotlin/Native calls linker by itself.
|
||||||
|
3. Use `clang -cc1 -help` to see a list of available options.
|
||||||
|
|
||||||
Another useful compiler option is `-Xtemporary-files-dir=<PATH>` which allows
|
Another useful compiler option is `-Xtemporary-files-dir=<PATH>` which allows
|
||||||
to specify a directory for intermediate compiler artifacts like bitcode and object files.
|
to specify a directory for intermediate compiler artifacts like bitcode and object files.
|
||||||
|
|
||||||
|
|
||||||
#### Example 1. Bitcode right after IR to Bitcode translation.
|
#### Example 1. Bitcode right after IR to Bitcode translation.
|
||||||
```shell script
|
```shell script
|
||||||
konanc main.kt -produce bitcode -o bitcode.bc
|
konanc main.kt -produce bitcode -o bitcode.bc
|
||||||
@@ -309,7 +316,8 @@ konanc main.kt -Xtemporary-files-dir=<PATH> -o <OUTPUT_NAME>
|
|||||||
|
|
||||||
#### Example 3. Replace predefined LLVM pipeline with Clang options.
|
#### Example 3. Replace predefined LLVM pipeline with Clang options.
|
||||||
```shell script
|
```shell script
|
||||||
konanc main.kt -Xdisable-phases=BitcodeOptimization -Xoverride-clang-options=-c,-O2
|
CLANG_FLAGS="clangFlags.macos_x64=-cc1 -emit-obj;clangNooptFlags.macos_x64=-O2"
|
||||||
|
konanc main.kt -Xdisable-phases=BitcodeOptimization -Xoverride-konan-properties="$CLANG_FLAGS"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running Clang the same way Kotlin/Native compiler does
|
## Running Clang the same way Kotlin/Native compiler does
|
||||||
|
|||||||
Reference in New Issue
Block a user