Open juhp opened 4 months ago
(I am also seeing this error on Debian 12.5)
I can build like this (and tests pass)
$ cabal test --ghc-options="-optc=-Wno-deprecated-declarations" --ghc-options="-optc=-Wno-incompatible-pointer-types"
This will still print lots of
/tmp/ghc119412_0/ghc_190.c:35:104: error:
warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
but apparently it decides for "warning" (not "error")
Thanks @jwaldmann : at least for Fedora 40, just -Wno-incompatible-pointer-types
seems sufficient for the build to succeed.
Does this mean we're going to have to add
ghc-options:
HsOpenSSL: -optc=-Wno-incompatible-pointer-types
to every project that transitively depends on HsOpenSSL?
I have no knowledge of internals, but I was looking at the error message and types:
In file included from /tmp/ghc1577599_0/ghc_26.c:21:0: error:
cbits/HsOpenSSL.h:108:39: error:
note: expected ‘const BIGNUM **’ {aka ‘const struct bignum_st **’} but argument is of type ‘BIGNUM **’ {aka ‘struct bignum_st **’}
108 | const BIGNUM **r, const BIGNUM **s);
| ~~~~~~~~~~~~~~~^
|
108 | const BIGNUM **r, const BIGNUM **s);
| ^
/tmp/ghc1577599_0/ghc_26.c:32:195: error:
error: passing argument 5 of ‘HsOpenSSL_dsa_sign’ from incompatible pointer type [-Wincompatible-pointer-types]
32 | HsInt32 ghczuwrapperZC9ZCHsOpenSSLzm0zi11zi7zi6zminplaceZCOpenSSLziDSAZCHsOpenSSLzudsazusign(void* a1, char* a2, HsInt32 a3, BIGNUM** a4, BIGNUM** a5) {return HsOpenSSL_dsa_sign(a1, a2, a3, a4, a5);}
| ^~
|
the temporary C file contains
HsInt32 ghczuwrapperZC9ZCHsOpenSSLzm0zi11zi7zi6zminplaceZCOpenSSLziDSAZCHsOpenSSLzudsazusign(void* a1, char* a2, HsInt32 a3, BIGNUM** a4, BIGNUM** a5) {return HsOpenSSL_dsa_sign(a1, a2, a3, a4, a5);}
while in cbits/HsOpenSSL.h
, we have
int HsOpenSSL_dsa_sign(DSA *dsa, const unsigned char *ddata, int len,
const BIGNUM **r, const BIGNUM **s);
It seems the const
have gone missing in the transformation.
This transform is done by hsc2hs
? Probably from OpenSSL/DSA.hsc which contains
foreign import capi unsafe "HsOpenSSL.h HsOpenSSL_dsa_sign"
_dsa_sign :: Ptr DSA -> CString -> CInt -> Ptr (Ptr BIGNUM) -> Ptr (Ptr BIGNUM) -> IO CInt
There is no const
?
Apparently, this could be solved with ConstPtr
, see https://gitlab.haskell.org/ghc/ghc/-/issues/22043
Yeah, CApiFFI
needs https://hackage.haskell.org/package/base-4.19.1.0/docs/Foreign-C-ConstPtr.html but you may stumble upon https://gitlab.haskell.org/ghc/ghc/-/issues/24814, although the chances for this problem to happen are not very high.
Something like this might work
$ diff -r HsOpenSSL-0.11.7.6/OpenSSL/DSA.hsc my-HsOpenSSL-0.11.7.6/OpenSSL/DSA.hsc
37a38
> import Foreign.C.ConstPtr
135c136
< _dsa_sign :: Ptr DSA -> CString -> CInt -> Ptr (Ptr BIGNUM) -> Ptr (Ptr BIGNUM) -> IO CInt
---
> _dsa_sign :: Ptr DSA -> CString -> CInt -> Ptr (ConstPtr BIGNUM) -> Ptr (ConstPtr BIGNUM) -> IO CInt
138c139
< _dsa_verify :: Ptr DSA -> CString -> CInt -> Ptr BIGNUM -> Ptr BIGNUM -> IO CInt
---
> _dsa_verify :: Ptr DSA -> CString -> CInt -> ConstPtr BIGNUM -> ConstPtr BIGNUM -> IO CInt
353,356c354,357
< r <- peek rptr >>= peekBN . wrapBN
< peek rptr >>= _bn_free
< s <- peek sptr >>= peekBN . wrapBN
< peek sptr >>= _bn_free
---
> r <- peek rptr >>= peekBN . wrapBN . unConstPtr
> peek rptr >>= _bn_free . unConstPtr
> s <- peek sptr >>= peekBN . wrapBN . unConstPtr
> peek sptr >>= _bn_free . unConstPtr
367c368
< (_dsa_verify dsaptr ptr (fromIntegral len) (unwrapBN bnR) (unwrapBN bnS))))))
---
> (_dsa_verify dsaptr ptr (fromIntegral len) (ConstPtr $ unwrapBN bnR) (ConstPtr $ unwrapBN bnS))))))
but I don't have the resources to continue this (now)
Downstream bug is here: https://bugzilla.redhat.com/show_bug.cgi?id=2261128
It fails on all Fedora archs: https://koji.fedoraproject.org/koji/taskinfo?taskID=115236336
The x86_64 log looks like: (cached copy build.log)