Hi,
I removed my change to statements.cc and made a change as you suggested
in libgo/runtime/go-defer.c in function __go_set_defering_fn:
+#if defined(__powerpc64__) && _CALL_ELF != 2
+ g->defer->__defering_fn = *(void **)defering_fn;
+#else
+ g->defer->__defering_fn = defering_fn;
+#endif
With this change along with PATCH 1/9, the recover.go testcase passes,
there are no new regressions on for ppc64 LE or BE or ppc (32 bit BE)
when running the go and libgo testsuites and I agree is the right solution.
Thanks,
Lynn
On 09/25/2014 06:44 AM, Ulrich Weigand wrote:
Lynn Boger wrote:
I modified the patch for statements.cc and rebuilt and that eliminates
the regressions and fixes the original problem it was intended to fix
for both ppc64 BE & LE. The ABIs are different between BE & LE, so that
make_func_code_reference on ppc64 BE is not returning the function's
code address but the function pointer from the .opd. The first 8 bytes
of the entry in the .opd is the function's code address. Here is the
change to statements.cc that made it work:
+#if defined(__powerpc64__) && _CALL_ELF != 2
+ Expression* pfn =
+ Expression::make_func_code_reference(function, location);
+ Type* pfntype =
+ Type::make_pointer_type(
+ Type::make_pointer_type(Type::make_void_type()));
+ Expression* fn = Expression::make_unsafe_cast(pfntype, pfn,
location);
+ Expression* fn_code_addr = Expression::make_unary(OPERATOR_MULT, fn,
+ location);
+#else
+ Expression* fn_code_addr =
+ Expression::make_func_code_reference(function, location);
+#endif
+ Expression* call = Runtime::make_call(Runtime::SET_DEFERING_FN,
+ location, 1, fn_code_addr);
+ Statement* s = Statement::make_statement(call, true);
This looks wrong when using gcc-go as a cross-compiler. The #if is
evaluated in the context of the *host*, but you'd need to check the
processor architecture and ABI of the *target*. This seems difficult
since you'd have to take into account -mabi= options, which are not
readily available to the front end.
It seems more straightforward to keep the front end as is, i.e. generate
code to pass a plain function pointer (as defined by the target ABI) to
the runtime, and have the *runtime* do whatever target-specific fiddling
is required to get from a function pointer to a code address.
For example, you could add something like:
#if defined(__powerpc64__) && _CALL_ELF != 2
defering_fn = *(void **)defering_fn;
#endif
to __go_set_defering_fn (or possibly __go_can_recover).
[ Since the runtime is compiled for the target with the appropriate
ABI setting, the #if works as intended when in runtime code. ]
Bye,
Ulrich