[GHC] #12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files
with invalid paths
----------------------------------------+----------------------------
Reporter: rcook | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: hsc2hs | Version: 8.0.1
Keywords: | Operating System: Windows
Architecture: Unknown/Multiple | Type of failure: Other
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
----------------------------------------+----------------------------
Repro steps:
* Install Stack on a ''Windows'' development machine.
* Create new simple project with `stack new inlinecbug simple`.
* Rename `src/Main.hs` to `src/Main.hsc` in the `inlinecbug` project
directory.
* Build project with `stack build` and run with `stack exec inlinecbug` to
verify that hsc2hs works correctly.
* Replace content of `src/Main.hsc` with following:
{{{#!hs
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
import qualified Language.C.Inline as C
C.include "

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths ----------------------------+---------------------------------------- Reporter: rcook | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------+---------------------------------------- Comment (by rcook): See comment from "awson" at: https://github.com/fpco/inline-c/issues/50#issuecomment-241212544: The culprit is `{-# LINE ... #-}` pragmas in the files generated by hsc2hs. hsc2hs on Windows emits paths with non-escaped backslashes in it: {{{#!hs {-# LINE 1 "src\Language\C\Clang\Internal\FFI.hsc" #-} }}} I don't know how GHC's `LINE` pragma behavior is specified, but this is at least inconsistent with how Windows C compilers operate. GCC emits line directives with forward slashes in paths and Visual C emits escaped backslashes. Thus I mostly inclined to treat this as a bug in hsc2hs (easily fixable). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rcook): * testcase: => /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): It seems that you have a patch Richard? Could you possibly submit it to phabricator for review if it fixes the issue you are facing? Thank you for the reproduction steps but they are too involved to be really useful to find the issue. A reproduction should ideally be one invocation of `ghc` rather than relying on lots of external tools and libraries like stack. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2477 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * status: new => patch * differential: => Phab:D2477 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2477 Wiki Page: | Phab:D2478 -------------------------------------+------------------------------------- Changes (by rcook): * differential: Phab:D2477 => Phab:D2477 Phab:D2478 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2477 Wiki Page: | Phab:D2478 -------------------------------------+------------------------------------- Comment (by rcook): Phab:D2477 adds a test case under `testsuite/tess/hsc2hs`. Phab:D2478 is a fix for the bug located under `utils/hsc2hs`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files
with invalid paths
-------------------------------------+-------------------------------------
Reporter: rcook | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: hsc2hs | Version: 8.0.1
Resolution: | Keywords:
Operating System: Windows | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
| /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2477
Wiki Page: | Phab:D2478
-------------------------------------+-------------------------------------
Description changed by rcook:
@@ -25,1 +25,1 @@
- * Add the line `c-source-files: src/Main.c` to the `executable inlinecbug`
+ * Add the line `c-sources: src/Main.c` to the `executable inlinecbug`
New description:
Repro steps:
* Install Stack on a ''Windows'' development machine.
* Create new simple project with `stack new inlinecbug simple`.
* Rename `src/Main.hs` to `src/Main.hsc` in the `inlinecbug` project
directory.
* Build project with `stack build` and run with `stack exec inlinecbug` to
verify that hsc2hs works correctly.
* Replace content of `src/Main.hsc` with following:
{{{#!hs
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
import qualified Language.C.Inline as C
C.include "

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Changes (by rcook): * differential: Phab:D2477 Phab:D2478 => Phab:D2478 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Comment (by rcook): @mpickering: Here's a more compact repro case: {{{#!hs $ cat T12504/path/to/T12504.hsc module Main (main) where main :: IO () main = putStrLn "hello world" $ '/c/src/ghc/inplace/bin/hsc2hs.exe' T12504/path/to/T12504.hsc $ cat T12504/path/to/T12504.hs {-# LINE 1 "T12504\path\to\T12504.hsc" #-} module Main (main) where {-# LINE 2 "T12504\path\to\T12504.hsc" #-} main :: IO () main = putStrLn "hello world" }}} Notice that the backslashes in the paths are not escaped properly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files
with invalid paths
-------------------------------------+-------------------------------------
Reporter: rcook | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: hsc2hs | Version: 8.0.1
Resolution: | Keywords:
Operating System: Windows | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
| /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2478
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: hsc2hs | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge * milestone: => 8.0.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: hsc2hs | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` as 76286af5c621f032c4afab1f26b992e8ffa7f84d. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: hsc2hs | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Comment (by rcook): Will hsc2cs's version number need to be bumped? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths -------------------------------------+------------------------------------- Reporter: rcook | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: hsc2hs | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: | /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2478 Wiki Page: | Phab:D2537 -------------------------------------+------------------------------------- Changes (by Phyx-): * differential: Phab:D2478 => Phab:D2478 Phab:D2537 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files with invalid paths ----------------------------+--------------------------------------------- Reporter: rcook | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: hsc2hs | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Windows | Architecture: Unknown/Multiple Type of failure: Other | Test Case: T12504 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2478 Phab:D2537 Wiki Page: | ----------------------------+--------------------------------------------- Changes (by Phyx-): * testcase: /testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc => T12504 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12504#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12504: Windows: Using hsc2hs in combination with inline-c generates the .c files
with invalid paths
----------------------------+---------------------------------------------
Reporter: rcook | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 8.0.2
Component: hsc2hs | Version: 8.0.1
Resolution: fixed | Keywords:
Operating System: Windows | Architecture: Unknown/Multiple
Type of failure: Other | Test Case: T12504
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2478 Phab:D2537
Wiki Page: |
----------------------------+---------------------------------------------
Comment (by Tamar Christina
participants (1)
-
GHC