On Thu, Feb 15, 2024 at 12:57:21PM +0100, Florian Weimer wrote:
> For the first issue, please try this GHC patch (only compile-tested with
> the stage 0 compiler build this point):
> 
> diff --git a/compiler/GHC/HsToCore/Foreign/C.hs 
> b/compiler/GHC/HsToCore/Foreign/C.hs
> index 2164ded112..8beaa8986e 100644
> --- a/compiler/GHC/HsToCore/Foreign/C.hs
> +++ b/compiler/GHC/HsToCore/Foreign/C.hs
> @@ -560,7 +560,7 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty 
> is_IO_res_ty cc
>       ,   ppUnless res_hty_is_unit $
>           if libffi
>                    then char '*' <> parens (ffi_cResType <> char '*') <>
> -                       text "resp = cret;"
> +                       text "resp = " <> parens ffi_cResType <> text "cret;"
>                    else text "return cret;"
>       , rbrace
>       ]
> 
> I'm not even sure if there is a better fix for this.  Perhaps emitting a
> memcpy call to avoid the aliasing violation?

I thought it isn't an aliasing violation (though I only looked at the
diagnostics, nothing else), I thought the problem is that cret has some
pointer type and ffi_arg has integer type.  The above will work
if cret has non-pointer type (changes implicit conversion to explicit) but
with pointers still will emit a warning if say ffi_arg is 64-bit and pointers
are 32-bit or ffi_arg is 32-bit and pointers are 64-bit.
For that (ffi_arg) (uintptr_t) cret;
casts would be desirable, but one would need to find out if cret is a
pointer or not.

        Jakub
--
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to