Compiling GHC with Clang

Herbert Valerio Riedel hvr at gnu.org
Wed Apr 2 12:41:07 UTC 2014


On 2014-04-02 at 09:14:28 +0200, Herbert Valerio Riedel wrote:

[...]

> | compiler/stage2/build/Lexer.hs:2426:41:
> |     Couldn't match expected type ‘[Char]’ with actual type ‘Int#’
> |     In the first argument of ‘(>=)’, namely ‘offset’
> |     In the expression: (offset >= "0#")

FYI: I've found the cause, it's due to Clang's pre-processor:

The line in question is

    new_s = if GTE(offset,0#) && EQ(check,ord_c)

while the GET and EQ macros are defined as

    #if __GLASGOW_HASKELL__ > 706
    #define GTE(n,m) (tagToEnum# (n >=# m))
    #define EQ(n,m) (tagToEnum# (n ==# m))
    #else
    #define GTE(n,m) (n >=# m)
    #define EQ(n,m) (n ==# m)
    #endif
    
However, this is preprocessed into

    new_s = if (tagToEnum# (offset >="0#")) && (tagToEnum# (check =="ord_c"))

meaning that Clang's CPP made use of the stringifying operator '#' to
turn '0#' into '"0#"'


More information about the ghc-devs mailing list