The new ABI is simpler for use cases such as dynamically loaded packages.
The calling convention for import functions is similar to what go/ssa would
produce if BareInits were cleared. However, simply clearing this flag causes
two additional issues:
- We would need to special case the 'init$guard' variable (see discussion in https://codereview.appspot.com/78780043/).
- The call to __go_register_gc_roots needs to appear in the right place, i.e. after the guard check. Making this check appear in the right place with non-bare inits seems unreliable at best.
So we keep BareInits set and generate the necessary code manually.
It is still possible to get the old ABI by specifying a path to a gccgo
installation.
Would you mind moving this code to a separate function? defineFunction is getting a bit long.