Skip to content
Snippets Groups Projects
Commit c42cdb7f authored by Sergei Trofimovich's avatar Sergei Trofimovich Committed by Sergei Trofimovich
Browse files

fix Float/Double unreg cross-compilation


Looking at more failures on m68k (Trac #11395)
I've noticed the arith001 and arith012 test failures.
(--host=x86_64-linux --target=m68k-linux).

The following example was enough to reproduce a problem:

    v :: Float
    v = 43
    main = print v

m68k binaries printed '0.0' instead of '43.0'.

The bug here is how we encode Floats and Double
as Words with the same binary representation.

Floats:
  Before the patch we just coerced Float to Int.
  That breaks when we cross-compile from
  64-bit LE to 32-bit BE.

  The patch fixes conversion by accounting for padding.
  when we extend 32-bit value to 64-bit value (LE and BE
  do it slightly differently).

Doubles:
  Before the patch Doubles were coerced to a pair of Ints
  (not correct as x86_64 can hold Double in one Int) and
  then trucated this pair of Ints to pair of Word32.

  The patch fixes conversion by always decomposing in
  Word32 and accounting for host endianness (newly
  introduced hostBE)  and target endianness (wORDS_BIGENDIAN).

I've tested this patch on Double and Float conversion on
    --host=x86_64-linux --target=m68k-linux
crosscompiler. It fixes 10 tests related to printing Floats
and Doubles.

Thanks to Bertram Felgenhauer who poined out this probem.

Signed-off-by: default avatarSergei Trofimovich <siarheit@google.com>

Test Plan: checked some examples manually, fixed 10 tests in test suite

Reviewers: int-e, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1990

GHC Trac Issues: #11395
parent 374f9199
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment