Refactor foreign export initializers
This should fix the random stack corruption seen on Windows in #18548.
See Note [Tracking foreign exports]
in rts/ForeignExports.c
for an overview of the new scheme. In addition to being more correct than the previous scheme (by avoiding calls into libc
from initializers) it should produce slightly faster and smaller initialization code since the foreign export list for each module is more succinct.