Open claudeha opened 6 years ago
It works fine with ghc-7.10.3 from https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-x86_64-unknown-mingw32.tar.xz , which has an earlier bundled mingw/gcc version.
It also works fine with ghc-8.0.2 from https://downloads.haskell.org/~ghc/8.0.2/ghc-8.0.2-x86_64-unknown-mingw32-win10.tar.xz
Thanks for this awesome bug report. Although I don't know much about inline ASM (__asm__ (...)
) I was able to get c2hs
to read this file when I passed cc-options: -D__FLAGCLOBBER2='"cc"'
to the build options. So it seems the issue is __FLAGCLOBBER
is not defined and c2hs
fails to parse:
__asm__ ( <bunch-of-asm>
: ) // c2hs does not like a blank after the ':'
I'll have to look into it further. I don't know enough to know if this is illegal C, something language-c
doesn't currently understand or an issue with c2hs
itself.
In any case thanks digging through it and let me know if you're happy with the workaround for now.
Hello. I've got the same problem on GHC-8.10.1. This happens in my file where I #include <Windows.h>
.
Unfortunately, the workaround doesn't work anymore, as __FLAGGLOBBER2
is now overwritten based on __GCC_ASM_FLAG_OUTPUTS__
in intrin-impl.h:77
:
/* GCC v6 added support for outputting flags. This allows better code to be
produced for a number of intrinsics. */
#ifndef __GCC_ASM_FLAG_OUTPUTS__
#define __FLAGCONSTRAINT "=qm"
#define __FLAGSET "\n\tsetc %[old]"
#define __FLAGCLOBBER1 , "cc"
#define __FLAGCLOBBER2 "cc"
#else
#define __FLAGCONSTRAINT "=@ccc"
#define __FLAGSET
#define __FLAGCLOBBER1
#define __FLAGCLOBBER2
#endif
So the new workaround is to undefine the variable: cc-options: -U__GCC_ASM_FLAG_OUTPUTS__
. But I wonder about that comment about better code for a number of intrinsics.
Trying to
cabal install -f bundled -f opengl fltkhs
in Appveyor (Windows compiler-as-a-service, with ghc-8.2.2 tarball downloaded from haskell.org inside its MSYS environment). I get a failure fromc2hs
related to theintrin-impl.h
bundled with the ghc distribution of mingw:The problematic source file can be found inside the ghc-8.2.2 mingw tarball: https://downloads.haskell.org/~ghc/8.2.2/ghc-8.2.2-x86_64-unknown-mingw32.tar.xz Here is an excerpt with line numbers annotated:
I don't have Windows at home so I don't know if it's Appveyor specific, or if it's a generic Windows issue. I also don't know if this should rather be an issue filed against
fltkhs
orlanguage-c
(or some other package).