Hacker News new | ask | show | jobs
by nodesocket 1609 days ago
Curious, is porting complex C++ projects to arm64 just a matter of updating build/CI systems or does it actually involve changing core code and adding branches if (x64) {} ... if (arm64) {}.
5 comments

Most user-space code is not difficult to port. An operating system is much more work.

Take a look at https://github.com/torvalds/linux/tree/master/arch/arm64

For common programs it's not very difficult, usually just recompile. But if it uses assembly then you are out of luck. Also if it requires a library that uses it.

For an OS it is different, you need to reimplement many parts: bootloader, drivers, task scheduler, virtual memory...

Like everything in computing it depends.

x86 and ARM don't same the same memory consistency model, so while managed languages do somehow protect their users from the differences, languages like C++ do expose it by default (unless you make use of the C++11 memory model APIs[0]).

So it depends how clever the lock-free kernel datastructure were written and other memory access assumptions.

[0] - https://en.cppreference.com/w/cpp/language/memory_model

All of the x86 assembly (see arch and boot/x86 dirs..) and any x86 assumptions being made elsewhere in the rest of the code is where the work is.
An os kernel needs a lot of custom work for the hardware. Example: manipulating page tables, handling interrupts, making context switches work.