The `-fms-hotpatch` flag has been available in Clang since version 14, but it was broken before version 18 (e.g., it could crash on some files when using CI’s Clang). Unfortunately, I couldn’t find a reliable way to check for this in configure, hence the convoluted workaround.
The flag is supported on both 32-bit and 64-bit x86 architectures. It ensures that the first instruction of a function is at least 2 bytes long at the compiler level and adds additional padding during linking.
However, there is a limitation: when the compiler emits multiple functions in a single `.text` section, those functions are not padded. This differs from MSVC, where the compiler handles such padding. Using `-ffunction-sections` mitigates this issue.
While we could limit the use of `-ffunction-sections` to specific cases, it appears beneficial overall. It allows the linker to GC unused functions, which is helpful when linking against static libraries that include both used and unused functions in the same file. This is already the default on ARM64EC, so it makes things more consistent across targets.