Skip to content
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

Update for 9.6.2 #21

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

pillowtrucker
Copy link

@drvink @Kleidukos this builds now and make, load and unsafeEval mostly work, even on a relatively complicated test:

main = do fn <- unsafeEval_ "(\\x -> (x,x::Int))" [] ["-O2","-v","-g","-threaded","-with-rtsopts=-N"] [] [] :: IO (Either [String] (Int -> (Int,Int)))
          case fn of
            Right fn -> putStrLn $ show $ fn 8
            Left err -> putStrLn $ "error top level"
          whoop <- atomically $ newTMVar 1
          whoop2 <- atomically $ newTMVar 2
          whoop3 <- atomically $ newTMVar 3
--          when (isJust fn) $ putStrLn $ show $ (fromRight fn) 7
          danger <- unsafeEval_ "(\\w -> (atomically $ takeTMVar w) >>= putStrLn . show >> threadDelay 5000000 >> (atomically $ putTMVar w 5)) :: TMVar Int -> IO ()" ["Control.Concurrent.STM","Control.Concurrent.STM.TMVar","Control.Concurrent"] ["-O2","-v","-g","-threaded","-with-rtsopts=-N"] [] [] :: IO (Either [String] (TMVar Int -> IO ()))
          case danger of
            Right fn -> do
              tid <- forkIO $ fn whoop
              return ()
            Left err -> mapM putStrLn err >> return ()
--          hmm <- atomically $ readTMVar whoop2
--          putStrLn . show $ hmm
          threadDelay 2000000
          hmm2 <- atomically $ do
            hhhh <- tryTakeTMVar whoop
            case hhhh of
              Just ok -> return ok
              Nothing -> retry
          putStrLn . show $ hmm2

I'm getting a solid full terminal of warnings such as this though:

Symbol type mismatch.
Symbol stg_ap_pppppp_fast was defined by /home/wrath/.ghcup/ghc/9.6.2/lib/ghc-9.6.2/lib/../lib/x86_64-linux-ghc-9.6.2/rts-1.0.2/libHSrts-1.0.2.a to be a code symbol.
      yet was defined by <builtin> to be a data symbol.

I was getting those even on very basic tests and thought maybe it's because I had ghc flags different in my main project than in the evaled code, but they're the same even when I tested:

main = do fn <- unsafeEval "(\\x -> (x,x::Int))" [] :: IO (Maybe (Int -> (Int,Int)))
          when (isJust fn) $ putStrLn $ show $ (fromJust fn) 7

@Kleidukos
Copy link

oh wow that's wonderful, thanks a lot for this work!

@arjunkathuria
Copy link

Hi! Ran into this one today.

Does this build with GHC 9.2 and is mostly safe to use?

@pillowtrucker
Copy link
Author

the other pull request might work better for 9.2 but I don't remember when the API changes were made. I don't know enough about the GHC API and to tell whether this is still safe. The code means exactly the same as it did before. Whether that still makes sense on the ABI level is another matter. I was hoping someone who knows this better would help debug it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants