This patch to libgo permits building libgo when using --without-libffi. This is mainly to aid porting. The resulting libgo has some limitations. Finalizers use libffi, and finalizers are used to arrange for the garbage collector to close open files when they are garbage collected. So using libgo built this way means that you must be careful to explicitly close any open files. Also the reflect.Call function will not work; it is used by things like the net/rpc package.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian
diff -r 86e58c4837fc libgo/runtime/go-reflect-call.c --- a/libgo/runtime/go-reflect-call.c Tue Feb 14 11:38:04 2012 -0800 +++ b/libgo/runtime/go-reflect-call.c Tue Feb 14 12:37:22 2012 -0800 @@ -8,13 +8,17 @@ #include <stdint.h> #include <stdlib.h> -#include "ffi.h" +#include "config.h" #include "go-alloc.h" #include "go-assert.h" #include "go-type.h" #include "runtime.h" +#ifdef USE_LIBFFI + +#include "ffi.h" + /* The functions in this file are only called from reflect_call. As reflect_call calls a libffi function, which will be compiled without -fsplit-stack, it will always run with a large stack. */ @@ -500,3 +504,20 @@ free (call_result); } + +#else /* !defined(USE_LIBFFI) */ + +void +reflect_call (const struct __go_func_type *func_type __attribute__ ((unused)), + const void *func_addr __attribute__ ((unused)), + _Bool is_interface __attribute__ ((unused)), + _Bool is_method __attribute__ ((unused)), + void **params __attribute__ ((unused)), + void **results __attribute__ ((unused))) +{ + /* Without FFI there is nothing we can do. */ + runtime_throw("libgo built without FFI does not support " + "reflect.Call or runtime.SetFinalizer"); +} + +#endif /* !defined(USE_LIBFFI) */