Skip to content

Build with -Wconversion produces non-viable GHC

OpenBSD people recently tried to build their ports tree with clang forcing -Wconversion. GHC 8.10.5 build on amd64 reported a number of warnings, many duplicated. More concerning is that the build didn't fail, it succefully produced broken artifacts. For example, ghci is broken:

% ./inplace/bin/ghc-stage2 --interactive
GHCi, version 8.10.5: https://www.haskell.org/ghc/  :? for help
ghc-stage2: internal error: m32_filled_page_set_next: Page not in lower 32-bits
    (GHC version 8.10.5 for x86_64_unknown_openbsd)
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

To reproduce the findings cc in PATH should be replaced with a wrapper that adds -Wconversion and removes -Werror:

#!/bin/sh
for i; do arg=$1; shift; case $arg in -Werror*) ;; *) set - "$@" "$arg" ;; esac; done
exec  /usr/bin/cc -B /usr/ports/pobj/ghc-8.10.5/bin -Wconversion "$@"

Some typical warnings are below, the full log is attached.

In file included from /tmp/ghc80558_0/ghc_4.c:2:0: error: 

In file included from /usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/Rts.h:35:0: error:
    

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/Stg.h:515:17: error:
     warning: implicit conversion changes signedness: 'StgInt64' (aka 'long long') to 'W_' (aka 'unsigned long long') [-Wsign-conversion]
        p_dest[0] = src;
                  ~ ^~~
    |
515 |     p_dest[0] = src;
    |                 ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/Stg.h:520:12: error:
     warning: implicit conversion changes signedness: 'W_' (aka 'unsigned long long') to 'StgInt64' (aka 'long long') [-Wsign-conversion]
        return p_src[0];
        ~~~~~~ ^~~~~~~~
    |
520 |     return p_src[0];
    |            ^

In file included from /tmp/ghc80558_0/ghc_4.c:2:0: error: 

In file included from /usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/Rts.h:208:0: error:
    

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:115:27: error:
     warning: implicit conversion changes signedness: 'const StgSRTField' (aka 'const int') to 'StgHalfWord' (aka 'unsigned int') [-Wsign-conversion]
        return get_itbl(con)->srt;
        ~~~~~~ ~~~~~~~~~~~~~~~^~~
    |
115 |     return get_itbl(con)->srt;
    |                           ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:212:39: error:
     warning: implicit conversion changes signedness: 'int' to 'unsigned long long' [-Wsign-conversion]
        return (StgClosure*)((StgWord)p & ~TAG_MASK);
                                        ~ ^~~~~~~~~
    |
212 |     return (StgClosure*)((StgWord)p & ~TAG_MASK);
    |                                       ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:218:45: error:
     warning: implicit conversion changes signedness: 'int' to 'unsigned long long' [-Wsign-conversion]
        return (const StgClosure*)((StgWord)p & ~TAG_MASK);
                                              ~ ^~~~~~~~~
    |
218 |     return (const StgClosure*)((StgWord)p & ~TAG_MASK);
    |                                             ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:315:28: error:
     warning: implicit conversion loses integer precision: 'StgWord' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
    |
315 | { return AP_STACK_sizeW(x->size); }
    |                            ^
{ return AP_STACK_sizeW(x->size); }
         ~~~~~~~~~~~~~~ ~~~^~~~

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:384:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return thunk_sizeW_fromITBL(info);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
    |
384 |         return thunk_sizeW_fromITBL(info);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:386:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return THUNK_SELECTOR_sizeW();
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~
    |
386 |         return THUNK_SELECTOR_sizeW();
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:388:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return ap_stack_sizeW((StgAP_STACK *)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |
388 |         return ap_stack_sizeW((StgAP_STACK *)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:390:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return ap_sizeW((StgAP *)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~
    |
390 |         return ap_sizeW((StgAP *)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:392:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return pap_sizeW((StgPAP *)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~
    |
392 |         return pap_sizeW((StgPAP *)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:396:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return arr_words_sizeW((StgArrBytes *)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |
396 |         return arr_words_sizeW((StgArrBytes *)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:401:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return mut_arr_ptrs_sizeW((StgMutArrPtrs*)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |
401 |         return mut_arr_ptrs_sizeW((StgMutArrPtrs*)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:406:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return small_mut_arr_ptrs_sizeW((StgSmallMutArrPtrs*)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |
406 |         return small_mut_arr_ptrs_sizeW((StgSmallMutArrPtrs*)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:410:16: error:
     warning: implicit conversion loses integer precision: 'StgWord' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return stack_sizeW((StgStack*)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
    |
410 |         return stack_sizeW((StgStack*)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:412:16: error:
     warning: implicit conversion loses integer precision: 'StgWord' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return bco_sizeW((StgBCO *)p);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~
    |
412 |         return bco_sizeW((StgBCO *)p);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:416:16: error:
     warning: implicit conversion loses integer precision: 'StgOffset' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            return sizeW_fromITBL(info);
            ~~~~~~ ^~~~~~~~~~~~~~~~~~~~
    |
416 |         return sizeW_fromITBL(info);
    |                ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/ClosureMacros.h:443:20: error:
     warning: implicit conversion changes signedness: 'const StgHalfInt' (aka 'const int') to 'unsigned long long' [-Wsign-conversion]
            return 1 + GET_LARGE_BITMAP(&info->i)->size;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
    |
443 |         return 1 + GET_LARGE_BITMAP(&info->i)->size;
    |                    ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/InfoTables.h:381:58: error:
     note: expanded from macro 'GET_LARGE_BITMAP'
                                            + (info)->layout.large_bitmap_offset))
                                            ~ ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
    |
381 |                                         + (info)->layout.large_bitmap_offset))
    |                                                          ^

In file included from /tmp/ghc80558_0/ghc_4.c:2:0: error: 

In file included from /usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/Rts.h:210:0: error:
    

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/GC.h:248:37: error:
     warning: implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'StgWord16' (aka 'unsigned short') [-Wimplicit-int-conversion]
        RELAXED_STORE(&bd->gen_no, gen->no);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
    |
248 |     RELAXED_STORE(&bd->gen_no, gen->no);
    |                                     ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/stg/SMP.h:477:39: error:
     note: expanded from macro 'RELAXED_STORE'
    |
477 | #define RELAXED_STORE(ptr,val) *ptr = val
    |                                       ^
#define RELAXED_STORE(ptr,val) *ptr = val
                                    ~ ^~~

In file included from /tmp/ghc80558_0/ghc_4.c:2:0: error: 

In file included from /usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/Rts.h:210:0: error:
    

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/rts/storage/GC.h:249:39: error:
     warning: implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'StgWord16' (aka 'unsigned short') [-Wimplicit-int-conversion]
        RELAXED_STORE(&bd->dest_no, dest->no);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
    |
249 |     RELAXED_STORE(&bd->dest_no, dest->no);
    |                                       ^

/usr/ports/pobj/ghc-8.10.5/bootstrap/lib/ghc/include/stg/SMP.h:477:39: error:
     note: expanded from macro 'RELAXED_STORE'
    |
477 | #define RELAXED_STORE(ptr,val) *ptr = val
    |                                       ^
#define RELAXED_STORE(ptr,val) *ptr = val
                                    ~ ^~~
20 warnings generated.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information