nexos wrote:
bzt wrote:
Correction: UEFI was written with purely MSVC in mind, not C in general
UEFI can easily be used on other compilers (especially Clang)
Yes, it can be used, but not easy, not by far.
It took me quite a while to figure out all the necessary CLang and lld switches. The most problematic part is, UEFI has renamed all the standard C functions (aaargh M$ you have been a nasty boy, why on earth did you do that?), like there's no memset, memcmp, memcpy etc. you have ZeroMem, CompareMem, CopyMem etc. but mem* still might be inserted into the binary by any C compiler even if the source doesn't reference them directly (depending on the code and optimization level of course). When such a builtin gets inlined, then no probs, you won't even notice. But under some circumstances sometimes only a libc call is emitted (even in the freestanding mode), and bam, you have a big problem, lots of linking errors. Yes, once you've figured out all the necessary switches, it's easy, but all problems seem easy once you know the solution... Maybe there's a
switch in CLang that simply tells it to always use UEFI equivalents of these builtins, but I couldn't find this switch, that's for sure.
Cheers,
bzt