> In the end, you write code for a compiler so from your perspective, nothing changes.
Isn't this only true if you're only using the CPU and not any of the other onboard hardware? For example, consider this small Arduino program I wrote: https://arduino.stackexchange.com/a/56595/33351
It would need to be entirely discarded and rewritten from scratch to work on any non-AVR microcontroller.