[GHC] #14227: Add -fdefer-ffi-errors flag

#14227: Add -fdefer-ffi-errors flag -------------------------------------+------------------------------------- Reporter: tysonzero | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.2.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: -------------------------------------+------------------------------------- Currently when I do: {{{#!hs foreign import javascript unsafe "foo()" foo :: IO () }}} I understandably get: {{{ • The `javascript' calling convention is unsupported on this platform • When checking declaration: foreign import javascript unsafe "static foo()" foo :: IO () }}} However when I am developing with GHCJS I still want to use all my typical GHC tooling, a lot of which is not supported on GHCJS. So I need GHC to be able to compile my code even though I don't actually run it, currently I often have to do: {{{#!hs #ifdef __GHCJS__ foreign import javascript unsafe "foo()" foo :: IO () #else foo :: IO () foo = error "GHCJS required to use foo" #endif }}} Which is really noisy and annoying code to write, and it also does not help me with compiling external library code that does not do the above. It also pins me specifically to GHCJS and any future compiler that supports JS to any degree will need the code changed. The easiest solution to the problem seems to me to be a `-fdefer-ffi- errors` flag which replaces any unsupported ffi declaration with a runtime `error` call that gives a similar error message to the one currently given at compile time. I would also like a `-fdefer-ffi-errors-no-warn` flag to avoid my tooling complaining / emitting a bunch of warnings that don't actually help me much. This is not a very exciting request, but it would be a huge quality of life improvement for front end Haskell web development, and it does not seem overly difficult or dangerous to implement. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14227 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14227: Add -fdefer-ffi-errors flag -------------------------------------+------------------------------------- Reporter: tysonzero | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.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 bgamari):
The easiest solution to the problem seems to me to be a `-fdefer-ffi- errors` flag which replaces any unsupported ffi declaration with a runtime error call that gives a similar error message to the one currently given at compile time.
An interesting idea. I believe this wouldn't be too hard to implement; the relevant code can be found in `TcForeign.checkCConv`.
I would also like a `-fdefer-ffi-errors-no-warn` flag to avoid my tooling complaining / emitting a bunch of warnings that don't actually help me much.
I think I would probably instead spell this `-Wno-deferred-ffi-errors` or similar. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14227#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14227: Add -fdefer-ffi-errors flag -------------------------------------+------------------------------------- Reporter: tysonzero | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.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 simonpj): Would be fine with me. It's a user-facing change, so worth running quickly through the [https://github.com/ghc-proposals/ghc-proposals GHC proposals process]. Should be fast! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14227#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14227: Add -fdefer-ffi-errors flag -------------------------------------+------------------------------------- Reporter: tysonzero | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.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 bgamari): Ooh, this would also allow us to potentially compile, for instance, `win32` on Linux, which would simplify documentation preparation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14227#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14227: Add -fdefer-ffi-errors flag -------------------------------------+------------------------------------- Reporter: tysonzero | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.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 tysonzero): [https://github.com/ghc-proposals/ghc-proposals/pull/73 Proposal created] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14227#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC