[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 <hvr@gnu.org> Date: Thu, 31 Dec 2015 16:58:28 +0100 Subject: [PATCH] Drop redundant `-D__GLASGOW_HASKELL__=...` flag In 3549c952b535803270872adaf87262f2df0295a4 a `include/ghcversions.h` include file was introduced which defines `__GLASGOW_HASKELL__` as well. So there's no need to define it twice. }}} So in theory, `cpphs-1.20.4` should just be reading `__GLASGOW_HASKELL__` from `include/ghcversions.h`. But I overlooked the warning that `cpphs-1.20.4` was emitting: {{{ Warning: Can't find file "/opt/ghc/8.2.1/lib/ghc-8.2.0.20170403/include/ghcversion.h" in directories }}} That's not good. In GHC 8.0.2, even though `cpphs` couldn't find `include/ghcversions.h`, it was able to find `__GLASGOW_HASKELL__` anyway by dumb luck, as `DriverPipeline` also (re-)defined it. But after 351dea4a7c07f4e845eac6c2e895f6f41524b40c, that is no longer the case, so if `cpphs` can't find `include/ghcversions.h`, we're hosed. This `cpphs` issue was reported upstream as https://github.com/malcolmwallace/cpphs/issues/11 a while back. There is a patch [https://raw.githubusercontent.com/jmitchell/cpphs-blackbox/master /avoid-using-findfile_-ghc-7_4-doesn_t-include-it_.dpatch here] which you can apply to the `cpphs` repo to fix the issue (I've confirmed that applying the patch makes GHC 8.2 work with `cpphs-1.20.4` again). So now we wait for a new release of `cpphs` with this fix... -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13553#comment:1> 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: 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