primitive package doesnt compile
dfordivam opened this issue · 1 comments
dfordivam commented
compile error from clang
2206 | {extern void (hsprimitive_memset_Word8)(void *, I_, W_, I_); [1230/7270]
| ^
{extern void (hsprimitive_memset_Word8)(void *, I_, W_, I_);
^
/run/user/1000/ghc19231_0/ghc_46.hc:97:15: error:
note: previous declaration is here
|
97 | {extern void (hsprimitive_memset_Word8)(void *, I_, W_, W_);
| ^
{extern void (hsprimitive_memset_Word8)(void *, I_, W_, W_);
^
/run/user/1000/ghc19231_0/ghc_46.hc:2317:15: error:
error: conflicting types for 'hsprimitive_memset_Word16'
|
2317 | {extern void (hsprimitive_memset_Word16)(void *, I_, W_, I_);
| ^
{extern void (hsprimitive_memset_Word16)(void *, I_, W_, I_);
^
/run/user/1000/ghc19231_0/ghc_46.hc:208:15: error:
note: previous declaration is here
|
208 | {extern void (hsprimitive_memset_Word16)(void *, I_, W_, W_);
| ^
{extern void (hsprimitive_memset_Word16)(void *, I_, W_, W_);
^
/run/user/1000/ghc19231_0/ghc_46.hc:2428:15: error:
error: conflicting types for 'hsprimitive_memset_Word32'
|
2428 | {extern void (hsprimitive_memset_Word32)(void *, I_, W_, I_);
| ^
{extern void (hsprimitive_memset_Word32)(void *, I_, W_, I_);
^
/run/user/1000/ghc19231_0/ghc_46.hc:319:15: error:
note: previous declaration is here
|
319 | {extern void (hsprimitive_memset_Word32)(void *, I_, W_, W_);
| ^
{extern void (hsprimitive_memset_Word32)(void *, I_, W_, W_);
This issue is because of using same C function with different type signature
foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8"
setWord8Array# :: MutableByteArray# s -> CPtrdiff -> CSize -> Word# -> IO ()
foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8"
setInt8Array# :: MutableByteArray# s -> CPtrdiff -> CSize -> Int# -> IO ()
Adding a wrapper C code solves this issue
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8"
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8_Int"
setInt8Array# :: MutableByteArray# s -> CPtrdiff -> CSize -> Int# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word16"
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word16_Int"
setInt16Array# :: MutableByteArray# s -> CPtrdiff -> CSize -> Int# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word32"
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word32_Int"
setInt32Array# :: MutableByteArray# s -> CPtrdiff -> CSize -> Int# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word64"
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word64_Int"
setInt64Array# :: MutableByteArray# s -> CPtrdiff -> CSize -> Int64_# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word"
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word_Int"
setIntArray# :: MutableByteArray# s -> CPtrdiff -> CSize -> Int# -> IO ()
Is this a correct fix? should I open a PR upstream?
ElvishJerricco commented
This is a duplicate of WebGHC/ghc#12