ccall: handle Union appearing as a field-type without crashing (#46787)
We disallow union as the direct type, so perhaps we should disallow it
as a field-type also, but since we do allow references in those cases
typically, we will allow this also.
Also DRY the emit_global code, since it had bit-rotted relative to the
usual code path through emit_globalref (and apparently could still be
run though for handling the first argument to cfunction).
Fix #46786