Skip to content

Instantly share code, notes, and snippets.

@jonnycoder1
Last active October 5, 2023 16:06
Show Gist options
  • Select an option

  • Save jonnycoder1/bd3598ebab5d6de234a337526f4cba29 to your computer and use it in GitHub Desktop.

Select an option

Save jonnycoder1/bd3598ebab5d6de234a337526f4cba29 to your computer and use it in GitHub Desktop.
Reverse engineering Kotlin linuxArm32Hfp.md
# Update February 2023
Kotlin has announced deprecation of linuxArm32Hfp and other build targets:
https://blog.jetbrains.com/kotlin/2023/02/update-regarding-kotlin-native-targets/
# Diving Into ARM Cross Compilation for the First Time
A year ago this month, I was troubleshooting why our Kotlin C++ dynamic library was giving my team errors
regarding deprecated cp15 barrier instruction on one of our Linux ARM consumer device models, but not the others. It turns out none of knew that
the impacted model used an ARMv8 64bit SOC and that CP15 instructions were deprecated and stopped working in ARMv8.
My role was mostly that of a backend software engineer who had obtained some excellent experience in embedded C++ development thanks
to integration of multiple projects between my team's Python API and the device firmware. A very smart firmware coworker of mine
recommended that I recompile our Kotlin dynamic library using a ARMv7 or ARMv8 toolchain within Kotlin.
# Reverse Engineering Kotlin Native Compiler aka Konan
On my journey down the rabbit hole that is Kotlin multiplatform programming and cross compilation, I opened a Jetbrains YouTrack
support ticket found here:
https://youtrack.jetbrains.com/issue/KT-54427/Kotlin-Native-linuxArm32Hfp-produces-armv6-.so-despite-using-compilerOpts-marcharmv7
The support ticket documents my Q&A with reverse engineering Kotlin's native compilation and successfully documenting how one can
swap out the ARMv6 compiler with an ARMv7 or ARMv8 compiler.
# Lessons Learned
Some difficult problems will be frustrating especially in the face of abstraction hell, but the point of solving difficult
problems is to become better at it. It is also helpful to document your challenges because they make for great stories when
applying for a new job.
If you have read this far, perhaps you are interested in hiring an experienced software engineer who loves to solve problems? If
so, send me an email at jonnycoder@gmail.com
Notes & References:
-https://www.baeldung.com/kotlin/multiplatform-programming
-https://linaro-toolchain.linaro.narkive.com/FujRlXHl/question-on-using-deprecated-cp15-barrier-instruction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment