c2hs icon indicating copy to clipboard operation
c2hs copied to clipboard

Failure with GCC 7

Open felixonmars opened this issue 7 years ago • 10 comments

I was trying to build gnuidn-0.2.2 against GCC 7.1.1 and failed with a failure of c2hs:

Preprocessing library gnuidn-0.2.2...
c2hs: C header contains errors:

/usr/lib/gcc/i686-pc-linux-gnu/7.1.1/include/stddef.h:435: (column 3) [ERROR]  >>> Syntax error !
  The symbol `__float128' does not fit here.

I have tried to build it against GCC 6.3.1 and the error is gone. It seems a problem of c2hs with GCC 7.

felixonmars avatar May 21 '17 08:05 felixonmars

Are you using c2hs-0.28.2? If not please upgrade. You can verify with c2hs --version.

deech avatar May 21 '17 16:05 deech

Yes it is c2hs-0.28.2

felixonmars avatar May 21 '17 16:05 felixonmars

Similar issues were also reported at https://bugzilla.redhat.com/show_bug.cgi?id=1427000 and https://github.com/gtk2hs/gtk2hs/issues/200.

/usr/lib/gcc/i686-pc-linux-gnu/7.1.1/include/stddef.h:435:

#ifdef __i386__
  __float128 __max_align_f128 __attribute__((__aligned__(__alignof(__float128))));
#endif

The type __float128 exposed in i686 build is unsupported by language-c used by c2hs. https://github.com/visq/language-c/blob/master/README#L36

I have sent a pull request https://github.com/visq/language-c/pull/33 to add __float128 with which the issue should be addressed.

Offtopic 肥猫大法好 感谢肥猫辛勤劳作

MaskRay avatar May 21 '17 20:05 MaskRay

I'm using gcc 7.2.0 and getting an error that also mentions 128-bit floating point:

c2hs: C header contains errors:

/usr/include/stdlib.h:133: (column 18) [ERROR]  >>> Syntax error !
  The symbol `strtof128' does not fit here.

Pull request #193 updates to language-c-0.7, which has @MaskRay's pull request, but it doesn't seem to solve my problem. @felixonmars: Does it solve yours?

jchia avatar Sep 30 '17 13:09 jchia

I think the error I saw is a result of _Float128 being unrecognized by language-c when it tries to process a line like this from stdlib.h:

extern _Float128 strtof128 (const char *__restrict __nptr, char **__restrict __endptr) ...

https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Floating-Types.html#Floating-Types

So, it's a problem with language-c, and needs to be fixed there. When it finally gets fixed there, c2hs will still need to update to a version of language-c that has the fix.

jchia avatar Oct 02 '17 06:10 jchia

The __float128 change to language-c is upstreamed https://github.com/visq/language-c/pull/33

MaskRay avatar Oct 28 '17 07:10 MaskRay

But it still fails with _Float128. https://github.com/visq/language-c/issues/39

deech avatar Oct 28 '17 16:10 deech

I have submitted a small fix, https://github.com/visq/language-c/pull/41

I tested it with the 0.7.0 compatibility improvements made by @deech and my test cases started working without having to define _Float128 for c2hs.

krakrjak avatar Nov 09 '17 12:11 krakrjak

I think this is now fixed in https://github.com/haskell/c2hs/issues/192#issuecomment-346962050. Please try and let me know and I'll close.

deech avatar Nov 25 '17 19:11 deech

Still fails on it https://github.com/haskell/c2hs/issues/198

XVilka avatar Jan 13 '18 03:01 XVilka