Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,252
    • Issues 5,252
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 577
    • Merge requests 577
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #13491
Closed
Open
Issue created Mar 28, 2017 by Sergei Trofimovich@trofiReporter

UNIQUE_BITS is not crosscompiler-friendly

Things break when I try to build crosscompiler from 32-bit system to 64-bit system. For example i386-linux -> powerpc64-linux:

$ ./configure --target=powerpc64-unknown-linux-gnu --with-system-libffi --with-libffi-includes=/usr/lib/libffi-3.2.1/include/
$ make

"inplace/bin/ghc-stage1" -static  -H32m -O -optc-I/usr/lib/libffi-3.2.1/include -Wall   -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header 
-Irts -Irts/dist/build -DCOMPILING_RTS -this-unit-id rts -dcmm-lint      -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen           -O2    -Wno
ncanonical-monad-instances  -c rts/StgStartup.cmm -o rts/dist/build/StgStartup.o
/tmp/ghc19687_0/ghc_4.s: Assembler messages:

/tmp/ghc19687_0/ghc_4.s:11:0: error:
     Error: unknown pseudo-op: `.l'
   |
11 | .L�4:
   | ^

The problem here comes from definition of UNIQUE_BITS:

# cat compiler/Unique.h 
#include "../includes/MachDeps.h"

#define UNIQUE_BITS (WORD_SIZE_IN_BITS - 8)

Here WORD_SIZE_IN_BITS is a target platform size (64) while stage1 is still running on host platform (32).

As a result uniques truncate down to zero:

compiler/basicTypes/Unique.hs:    tag  = ord c `shiftL` UNIQUE_BITS
compiler/basicTypes/Unique.hs:        tag = chr (u `shiftR` UNIQUE_BITS)

As we operate on host Ints we could use the following:

#define UNIQUE_BITS sizeof(HsInt) * 8 -- C code

#define UNIQUE_BITS (finiteBitSize (undefined :: Int) * 8) -- Haskell code
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking