From a0060062f31bdb31e2024cb8fa801c252d76a593 Mon Sep 17 00:00:00 2001 From: Sven Tennie Date: Sun, 13 Apr 2025 18:28:50 +0200 Subject: [PATCH 1/2] Update the code for GHC 9.13 Fix --- Main.hs | 6 ++---- cabal.project | 1 + iserv-proxy.cabal | 6 ++---- src/IServ/Remote/Interpreter.hs | 5 +++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Main.hs b/Main.hs index a4c0d04..bcd9ee6 100644 --- a/Main.hs +++ b/Main.hs @@ -109,8 +109,7 @@ main = do inh <- getGhcHandle rfd2 outh <- getGhcHandle wfd1 installSignalHandlers - lo_ref <- newIORef Nothing - let in_pipe = Pipe{pipeRead = inh, pipeWrite = outh, pipeLeftovers = lo_ref} + in_pipe <- mkPipeFromHandles inh outh when verbose $ trace ("Trying to connect to " ++ host_ip ++ ":" ++ (show port)) @@ -307,5 +306,4 @@ socketToPipe sock = do hdl <- socketToHandle sock ReadWriteMode hSetBuffering hdl NoBuffering - lo_ref <- newIORef Nothing - pure Pipe{ pipeRead = hdl, pipeWrite = hdl, pipeLeftovers = lo_ref } + mkPipeFromHandles hdl hdl diff --git a/cabal.project b/cabal.project index e6fdbad..12c8d21 100644 --- a/cabal.project +++ b/cabal.project @@ -1 +1,2 @@ packages: . +allow-newer: * diff --git a/iserv-proxy.cabal b/iserv-proxy.cabal index 39e5cc6..5aaea55 100644 --- a/iserv-proxy.cabal +++ b/iserv-proxy.cabal @@ -80,8 +80,7 @@ Library directory >= 1.3 && < 1.4, network >= 2.6, filepath >= 1.4 && < 1.5, - ghci == 9.3, - libiserv == 9.3 + ghci Executable iserv-proxy Default-Language: Haskell2010 @@ -92,8 +91,7 @@ Executable iserv-proxy directory >= 1.3 && < 1.4, network >= 2.6, filepath >= 1.4 && < 1.5, - ghci == 9.3, - libiserv == 9.3, + ghci, iserv-proxy Executable iserv-proxy-interpreter diff --git a/src/IServ/Remote/Interpreter.hs b/src/IServ/Remote/Interpreter.hs index 9f8f88f..301a559 100644 --- a/src/IServ/Remote/Interpreter.hs +++ b/src/IServ/Remote/Interpreter.hs @@ -3,7 +3,8 @@ module IServ.Remote.Interpreter where import Network.Socket -import IServ (serv) +import GHCi.Server (serv) +import GHCi.Message import IServ.Remote.Message import System.IO @@ -153,7 +154,7 @@ socketToPipe sock = do hSetBuffering hdl NoBuffering lo_ref <- newIORef Nothing - pure Pipe{ pipeRead = hdl, pipeWrite = hdl, pipeLeftovers = lo_ref } + mkPipeFromHandles hdl hdl acceptSocket :: Socket -> IO Socket acceptSocket = fmap fst . accept From b15cfdd649d51f0ebaef3082d3d084a6001c5339 Mon Sep 17 00:00:00 2001 From: Sven Tennie Date: Sun, 13 Apr 2025 18:29:52 +0200 Subject: [PATCH 2/2] Add a run script for cross-compilers I tend to forget things. This script should help me to remember how the proxy can be used to test a cross-compiler. --- run.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..3b7d9f1 --- /dev/null +++ b/run.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Simple script to build and start the proxy. The printed args show how to use +# it for testing a cross-compiler on the same machine. + +set -e + +GHC="${GHC:-ghc}" +port=5005 + +cabal build -w "$GHC" exe:iserv-proxy +echo ghc-args: -fexternal-interpreter -pgmi=$(cabal list-bin -w "$GHC" exe:iserv-proxy) -opti=127.0.0.1 -opti=$port +cabal run -w "$GHC" iserv-proxy-interpreter $port .