Some assistance is needed from the Kotlin team! Wh...
# compiler
n
Some assistance is needed from the Kotlin team! What are the steps required to setup a third party LLVM based tool chain for a custom K/N target? Currently a GCC based tool chain is used however clang keeps on ignoring the
--gcc-toolchain
argument, which is essential for connecting the tool chain. Without it issues like the following occur:
Copy code
> Task :kotlin-native:runtime:rp2040CommonGc FAILED
clang-11: error: argument unused during compilation: '--gcc-toolchain=/home/napperley/.konan/dependencies/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi' [-Werror,-Wunused-command-line-argument]
Plan B is to use a LLVM based tool chain (the official ARM Embedded tool chain - https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm ), however unlike the GCC one it requires manual configuration on the tool chain side, and is missing some parts to make it a complete tool chain. Is there an example in the Kotlin code base where a third party LLVM based tool chain is used for a K/N target?
👀 1
Luckily the tool chain provides a ready made configuration file ( https://clang.llvm.org/docs/UsersManual.html#configuration-files ) for the armv6-m architecture (covers the RP2040 uC chip - https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html ), which contains the following:
Copy code
--target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m
-fuse-ld=lld
-fno-exceptions
-fno-rtti
--sysroot <CFGDIR>/../lib/clang-runtimes/armv6m_soft_nofp
<CFGDIR>/../lib/clang-runtimes/armv6m_soft_nofp/lib/crt0.o
Instructions are available on using the tool chain with the configuration file ( https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm#using-the-toolchain ), eg:
Copy code
clang --config armv6m_soft_nofp_semihost.cfg -T picolibc.ld -o example example.c
What needs to be done to create/setup a "configurable" for a LLVM based tool chain?
a
Hello, I'm also trying to include llvm obfuscator when building, did you manage to make any progress on this issue?
n
Only limited progress with connecting the LLVM based ARM Embedded toolchain. Beyond that there are a boat load of errors that occur with building the K/N runtime for the rp2040 target. All of the errors originate from the C++ side of the toolchain. Do note that the toolchain includes a C std lib called picolibc ( https://github.com/picolibc/picolibc ), which the rp2040 target will need to rely on to cover some functionality (i.e. fill in some of the gaps with the Kotlin Standard lib).
a
Thank you, I hope I will soon have a couple of days to actively deal with this issue. If you manage to implement your plan, please publish the results
@napperley Hi, I was able to connect a custom NDK that includes LLVM obfuscation. Also I tested it with IDA , it's better than without it. But still some of the functions do not work. https://github.com/o2e/OLLVM-9.0.1