
#10383: AArch64: get GHC Calling convention working ----------------------------------------+---------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: aarch64 Type of failure: Building GHC failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: ----------------------------------------+---------------------------------- Comment (by erikd): Narrowed the problem down to code in `rts/sm/Evac.c` namely: {{{ do { info_ptr = xchg((StgPtr)&p->header.info, (W_)&stg_WHITEHOLE_info); } while (info_ptr == (W_)&stg_WHITEHOLE_info); }}} Adding a `printf` before and after the call to `xchg` found that the exchange was happening, but the function was returning `0` instead of the old value of `p->header.info`. Wrote a small program to test this: {{{ #include "PosixSource.h" #include "Rts.h" #include "Stg.h" #include "stg/Types.h" #include "stg/SMP.h" int main (void) { StgWord a = 0xa, b = 0xb, res = 1; printf ("0x%lx 0x%lx 0x%lx\n", res, a, b); res = xchg(&a, b); printf ("0x%lx 0x%lx 0x%lx\n", res, a, b); return 0; } }}} which I compile and run as: {{{ gcc-5 -Wall -O3 -Iincludes -Irts -fno-stack-protector -DTHREADED_RTS \ -DCOMPILING_RTS xchg_test.c -o xchg_test && ./xchg_test }}} which on AArch64/Arm64 results: {{{ 0x1 0xa 0xb 0x0 0xb 0xb }}} which is just profoundly wrong! The expected result is: {{{ 0x1 0xa 0xb 0xa 0xb 0xb }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10383#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler