haskell / haskell/c2hs

The symbol `)' does not fit here.

Open
#199 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Haskell
Stars
211
Forks
52
PR merge metrics
No merged PRs in 30d

Description

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 from `c2hs` related to the `intrin-impl.h` bundled with the ghc distribution of mingw:

...
Installed language-c-0.7.1
Installed c2hs-0.28.3
....
Preprocessing library for fltkhs-0.5.4.4..
c2hs.exe: C header contains errors:
C:/msys64/opt/ghc-8.2.2/mingw/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h:763: (column 222) [ERROR] >>> Syntax error !
The symbol `)' does not fit here.
cabal: Leaving directory 'C:\msys64\tmp\cabal-tmp-2128\fltkhs-0.5.4.4'
cabal.exe: Error: some packages failed to install:
fltkhs-0.5.4.4-2soiFkskaE436y5UI0TpGW failed during the building phase. The exception was:
ExitFailure 1
Command exited with code 1

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:

...
/* this is line 241 */
/* This macro is used by _bittest & _bittest64

Parameters: (FunctionName, DataType, OffsetConstraint)
FunctionName: Any valid function name
DataType: __LONG32 or __int64
Type: l, q
OffsetConstraint: either "I" for 32bit data types or "J" for 64.

*/
#define __buildbittest(x, y, z, a) unsigned char x(const y *Base, y Offset) \
{ \
unsigned char old; \
__asm__ ("bt{" z " %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET \
: [old] __FLAGCONSTRAINT (old) \
: [Offset] a "r" (Offset), [Base] "rm" (*Base) \
: __FLAGCLOBBER2); \
return old; \
}
/* this is line 260 */
...
/* this is line 759 */
#if __INTRINSIC_PROLOG(_bittest64)
__MINGW_EXTENSION unsigned char _bittest64(__int64 const *a, __int64 b);
__MINGW_EXTENSION __INTRINSICS_USEINLINE
__buildbittest(_bittest64, __int64, "q", "J")
#define __INTRINSIC_DEFINED__bittest64
#endif /* __INTRINSIC_PROLOG */
/* this is line 766 */
...

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` or `language-c` (or some other package).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the AppVeyor command `cabal install -f bundled -f opengl fltkhs` with the stated GHC 8.2.2 Windows tarball. Inspect `psdk_inc/intrin-impl.h` around line 763 and the c2hs preprocessing failure, then determine whether the issue is reproducible outside AppVeyor. Done means the affected fltkhs preprocessing completes without the reported syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.