[GHC] #12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I've noticed it as a build failure on openbsd-6 but on linux behaviour is strange as well. Build failure: {{{ libraries/base/System/Posix/Types.hs:217:100: error: * No instance for (Fractional Int32) arising from the 'deriving' clause of a data type declaration Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself * When deriving the instance for (Fractional CTimer) }}} On openbsd-6.0 timer_t is an int32: {{{ # gcc -E /usr/include/time.h | grep timer_t typedef __int32_t __timer_t; typedef __timer_t timer_t; }}} On amd64-linux-glibc it's void*: {{{ $ gcc -E /usr/include/time.h | grep timer_t typedef void * __timer_t; typedef __timer_t timer_t; }}} But base's configure detects it as Double (by chance) on amd64-linux- glibc. {{{ System.Posix.Types> :t CTimer CTimer :: Double -> CTimer }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by slyfox): changeset:ffc2327070dbb664bdb407a804121eacb2a7c734 added instance as: {{{#!hs #if defined(HTYPE_TIMER_T) -- | @since 4.10.0.0 FLOATING_TYPE_WITH_CTYPE(CTimer,timer_t,HTYPE_TIMER_T) #endif }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: DanielG (added) Comment: As I note [https://phabricator.haskell.org/rGHCffc2327070dbb664bdb407a804121eacb2a7c734 here], a quick-and-dirty fix would be to introduce a macro `OPAQUE_TYPE_WITH_CTYPE` in `CTypes.h`: {{{#!hs #define OPAQUE_CLASSES Eq,Ord,Storable #define OPAQUE_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \ newtype {-# CTYPE "THE_CTYPE" #-} T = T B \ deriving (OPAQUE_CLASSES) \ deriving newtype (Read, Show); }}} And then use that on `CTimer` instead of `FLOATING_TYPE_WITH_CTYPE`. Of course, this doesn't fix the infelicity that the underlying representation of `CTimer` is still not a `Ptr ()`, which would require fixing the `FPTOOLS_CHECK_HTYPE_ELSE` [http://git.haskell.org/ghc.git/blob/ffc2327070dbb664bdb407a804121eacb2a7c734... M4 macro] in `libraries/base/aclocal.m4` to remedy. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12795 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #12795 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12795 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by DanielG): Ah looks like I trusted the assessments of `FPTOOLS_CHECK_HTYPE` a bit too much. Personally I'm not all that attached to `timer_t` specifically I just added it for completeness' sake. So I wouldn't mind just removing it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12795 | Differential Rev(s): Phab:D2876 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D2876 * milestone: => 8.2.1 Comment: Very well, I've opted to go down the "remove `CTimer`" route in Phab:D2876. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for
opaque type
-------------------------------------+-------------------------------------
Reporter: slyfox | Owner:
Type: bug | Status: patch
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #12795 | Differential Rev(s): Phab:D2876
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12795 | Differential Rev(s): Phab:D2876 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12795 | Differential Rev(s): Phab:D2876 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: closed => new * resolution: fixed => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12795 | Differential Rev(s): Phab:D2876, Wiki Page: | Phab:D2952 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * differential: Phab:D2876 => Phab:D2876, Phab:D2952 Comment: Since I was morbidly curious, I decided to see how much effort it would take to tweak the autoconf scripts to support detecting pointer types. To my surprise, it wasn't bad at all! I've opened to Phab:D2952 to add `CTimer` back to `System.Posix.Types`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for
opaque type
-------------------------------------+-------------------------------------
Reporter: slyfox | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #12795 | Differential Rev(s): Phab:D2876,
Wiki Page: | Phab:D2952
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#12998: libraries/base/System/Posix/Types.hs: tries to define Floating instance for opaque type -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12795 | Differential Rev(s): Phab:D2876, Wiki Page: | Phab:D2952 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => fixed Comment: Fixed for real this time. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12998#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC