[GHC] #13553: GHC 8.2.1 preprocesses __GLASGOW_HASKELL__ incorrectly with cpphs

#13553: GHC 8.2.1 preprocesses __GLASGOW_HASKELL__ incorrectly with cpphs -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) 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'm not exactly sure if this is the fault of `cpphs` or GHC, but I'll report this issue to GHC Trac for now, since (ostensibly) the only thing that has changed in this equation is the GHC version. Take this file: {{{#!hs {-# LANGUAGE CPP #-} module Bug where foo :: Int #if __GLASGOW_HASKELL__ >= 800 foo = 42 #else foo = "wrong type" #endif }}} Now let's compile it using `cpphs-1.20.4` as a preprocessor. With GHC 8.0, everything works out fine: {{{ $ /opt/ghc/8.0.2/bin/ghc Bug.hs -pgmP cpphs -optP --cpp Warning: Can't find file "/opt/ghc/8.0.2/lib/ghc-8.0.2/include/ghcversion.h" in directories Asked for by: Bug.hs at line 1 col 1 [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) }}} But with GHC 8.2.1, things go awry: {{{ $ /opt/ghc/8.2.1/bin/ghc Bug.hs -pgmP cpphs -optP --cpp Warning: Can't find file "/opt/ghc/8.2.1/lib/ghc-8.2.0.20170403/include/ghcversion.h" in directories Asked for by: Bug.hs at line 1 col 1 [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) Bug.hs:8:7: error: • Couldn't match expected type ‘Int’ with actual type ‘[Char]’ • In the expression: "wrong type" In an equation for ‘foo’: foo = "wrong type" | 8 | foo = "wrong type" | ^^^^^^^^^^^^ }}} This bug causes several libraries on Hackage which use `cpphs` as a preprocessor to fail when built with GHC 8.2.1, including `Agda`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13553 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13553: GHC 8.2.1 preprocesses __GLASGOW_HASKELL__ incorrectly with cpphs
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: upstream
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):
* status: new => upstream
Comment:
As it turns out, this is more of `cpphs`'s fault than GHC's. The commit
which started all this is 351dea4a7c07f4e845eac6c2e895f6f41524b40c:
{{{
From 351dea4a7c07f4e845eac6c2e895f6f41524b40c Mon Sep 17 00:00:00 2001
From: Herbert Valerio Riedel

#13553: GHC 8.2.1 preprocesses __GLASGOW_HASKELL__ incorrectly with cpphs -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: invalid | 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): * status: upstream => closed * resolution: => invalid Comment: An update: Malcolm Wallace released `cpphs-1.20.5`, which does not exhibit this problem anymore on //Linux//. On Windows, however, it still does. See https://github.com/malcolmwallace/cpphs/issues/11#issuecomment-294297975 I'm going to close this issue, as the ball is entirely in `cpphs`'s court when it comes to fixing the Windows issue. See https://github.com/malcolmwallace/cpphs/issues/11#issuecomment-294299458 for a patch which fixes the problem on `cpphs-1.20.5`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13553#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC