Skip to content

Various fixes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
58568f9
Add aarch64-musl symbols
angerman Nov 29, 2023
38e16f7
Add old `remote-iserv` command line code
hamishmack Dec 13, 2022
a46dc2a
Add Z drive for TH code
hamishmack Dec 13, 2022
a1f3c50
Support for older GHC versions
hamishmack Dec 14, 2022
d37cd95
libiserv is included in ghci from 9.8
hamishmack Jul 5, 2023
5e39e2a
libiserv is included in ghci from 9.8
hamishmack Jul 5, 2023
27bf2a5
libiserv is included in ghci from 9.8
hamishmack Jul 5, 2023
0ef42dc
Update deepseq upper bound
hamishmack Aug 10, 2023
7f665ec
Sigh
angerman Nov 29, 2023
4543444
[aarch64-musl] Add ptsname
angerman Nov 29, 2023
94fb984
add more printf stuff
angerman Nov 29, 2023
c00e3fb
Only on aarch64-linux include aarch64-musl
angerman Nov 29, 2023
7cbb7e3
add closure_sizeW_ to symbols
angerman Nov 30, 2023
a90a789
Add more libc functions
angerman Feb 21, 2024
13a1adc
Add getauxval (needed by e.g. libblst)
angerman Feb 21, 2024
2f2a318
Update bytestring and filepath upper bounds
hamishmack Feb 15, 2024
494c0f6
Add malloc/free to aarch64-musl
angerman Mar 16, 2024
50ea210
Add pipe related things
angerman Mar 16, 2024
2ed3400
Add `--no-load-call` flag for wine cross compiles
hamishmack Jun 4, 2024
9fee3a1
Add other platforms
hamishmack Feb 11, 2025
3890af9
Add i386 musl
hamishmack Feb 11, 2025
756f455
Update musl32 sysmbols
hamishmack Feb 11, 2025
9095fc6
Fix OS detection
hamishmack Feb 11, 2025
b9711cc
Fix for armv7a
hamishmack Feb 20, 2025
89ae671
Fix for aarch64-android
hamishmack Feb 24, 2025
531768c
Fixes for aarch64-android
hamishmack Feb 26, 2025
8cc5d87
More fixes for aarch64-android
hamishmack Feb 27, 2025
b93fe77
More fixes for aarch64-android
hamishmack Feb 27, 2025
d469d00
armv7a fixes
hamishmack Feb 27, 2025
a438f0c
Add symbols for armv7a android
hamishmack Mar 3, 2025
0a34e46
Add _exit (needed for GHC 9.10)
hamishmack Mar 3, 2025
49648aa
Disable iserv-proxy unresolved external fix code for now (needs updat…
hamishmack Mar 3, 2025
7ebe235
Disable iserv-proxy unresolved external fix code for now (needs updat…
hamishmack Mar 4, 2025
7bd7f5b
More symbols needed once libc.a is excluded from loadArchive
hamishmack Mar 5, 2025
c26dafb
More symbols needed once libc.a is excluded from loadArchive
hamishmack Mar 5, 2025
521964b
Add cbits/symbols.x86_64-windows.c
hamishmack Mar 7, 2025
a905515
Add support for GHC >=9.12
hamishmack Mar 14, 2025
e9dc86e
Add symbols for GHC 9.12
hamishmack Mar 16, 2025
dea34de
Add __strncpy_chk for android
hamishmack May 12, 2025
05a87bf
Fix for GHC HEAD
hamishmack Jun 4, 2025
832b56c
Add missing `,`
hamishmack Jun 4, 2025
c38db6f
Fix for android
hamishmack Jun 5, 2025
6972fbc
Fix for android
hamishmack Jun 6, 2025
aff8850
Use `-threaded` to fix Windows IO issue
hamishmack Jun 8, 2025
e40eddb
Add `threaded` flag (so we can easily turn it off)
hamishmack Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions Interpreter.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
module Main where

import System.Environment
import IServ.Remote.Message
import IServ.Remote.Interpreter
import IServ.Remote.Interpreter (startInterpreter')
import System.Environment (getArgs, getProgName)
import System.Exit (die)

verbose :: Bool
verbose = False
import Control.Monad (when)

main :: IO ()
main = do
[portStr, storagePath] <- getArgs
let port = read portStr
startInterpreter' verbose storagePath port
main = getArgs >>= startSlave

dieWithUsage :: IO a
dieWithUsage = do
prog <- getProgName
die $ msg prog
where
msg name = "usage: " ++ name ++ " /path/to/storage PORT [-v] [--no-load-call]"

startSlave :: [String] -> IO ()
startSlave args0
| "--help" `elem` args0 = dieWithUsage
| otherwise = do
(path, port, rest) <- case args0 of
arg0:arg1:rest -> return (arg0, read arg1, rest)
_ -> dieWithUsage

let verbose = "-v" `elem` rest
noLoadCall = "--no-load-call" `elem` rest

when (any (not . (`elem` ["-v", "--no-load-call"])) rest)
dieWithUsage

startInterpreter' verbose noLoadCall path port
39 changes: 28 additions & 11 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,24 @@ main = do
return (wfd1, rfd2, ip, port, rest)
_ -> dieWithUsage

verbose <- case rest of
["-v"] -> return True
[] -> return False
_ -> dieWithUsage
let verbose = "-v" `elem` rest
noLoadCall = "--no-load-call" `elem` rest

when (any (not . (`elem` ["-v", "--no-load-call"])) rest)
dieWithUsage

when verbose $
printf "GHC iserv starting (in: %d; out: %d)\n"
(fromIntegral rfd2 :: Int) (fromIntegral wfd1 :: Int)
inh <- getGhcHandle rfd2
outh <- getGhcHandle wfd1
installSignalHandlers
#if MIN_VERSION_ghci(9,13,0)
in_pipe <- mkPipeFromHandles inh outh
#else
lo_ref <- newIORef Nothing
let in_pipe = Pipe{pipeRead = inh, pipeWrite = outh, pipeLeftovers = lo_ref}
#endif

when verbose $
trace ("Trying to connect to " ++ host_ip ++ ":" ++ (show port))
Expand All @@ -124,7 +129,7 @@ main = do

when verbose $
trace "Starting proxy"
proxy verbose in_pipe out_pipe
proxy verbose noLoadCall in_pipe out_pipe

-- | A hook, to transform outgoing (proxy -> interpreter)
-- messages prior to sending them to the interpreter.
Expand All @@ -141,8 +146,16 @@ hook = return
--
fwdTHMsg :: (Binary a) => Pipe -> THMessage a -> IO a
fwdTHMsg local msg = do
writePipe local (putTHMessage msg)
readPipe local get
writePipe local (putTHMessage (fixAddDep msg))
readPipe local get
where
fixAddDep (AddDependentFile fp) = AddDependentFile $ fixZ (map fixSlash fp)
fixAddDep m = m
fixZ ('Z':':':rest) = rest
fixZ ('/':'/':'?':'/':'Z':':':rest) = rest
fixZ fp = fp
fixSlash '\\' = '/'
fixSlash c = c

-- | Fowarard a @Message@ call and handle @THMessages@.
fwdTHCall :: (Binary a) => Bool -> Pipe -> Pipe -> Message a -> IO a
Expand Down Expand Up @@ -199,7 +212,7 @@ fwdLoadCall verbose _ remote msg = do
writePipe remote (put m)
loopLoad :: IO ()
loopLoad = do
when verbose $ trace "fwdLoadCall: reading remote pipe"
when verbose $ trace "fwdLoadCall: X reading remote pipe"
SomeProxyMessage msg' <- readPipe remote getProxyMessage
when verbose $
trace ("| Sl Msg: proxy <- interpreter: " ++ show msg')
Expand All @@ -219,8 +232,8 @@ fwdLoadCall verbose _ remote msg = do

-- | The actual proxy. Conntect local and remote pipe,
-- and does some message handling.
proxy :: Bool -> Pipe -> Pipe -> IO ()
proxy verbose local remote = loop
proxy :: Bool -> Bool -> Pipe -> Pipe -> IO ()
proxy verbose noLoadCall local remote = loop
where
fwdCall :: (Binary a, Show a) => Message a -> IO a
fwdCall msg = do
Expand Down Expand Up @@ -275,7 +288,7 @@ proxy verbose local remote = loop
-- that are referenced in C:\ these are usually system libraries.
LoadDLL path@('C':':':_) -> do
fwdCall msg' >>= reply >> loop
LoadDLL path | isAbsolute path -> do
LoadDLL path | isAbsolute path && not noLoadCall -> do
resp <- fwdLoadCall verbose local remote msg'
reply resp
loop
Expand Down Expand Up @@ -307,5 +320,9 @@ socketToPipe sock = do
hdl <- socketToHandle sock ReadWriteMode
hSetBuffering hdl NoBuffering

#if MIN_VERSION_ghci(9,13,0)
mkPipeFromHandles hdl hdl
#else
lo_ref <- newIORef Nothing
pure Pipe{ pipeRead = hdl, pipeWrite = hdl, pipeLeftovers = lo_ref }
#endif
Loading