diff options
Diffstat (limited to 'src/Compile/Exec.hs')
| -rw-r--r-- | src/Compile/Exec.hs | 12 | 
1 files changed, 4 insertions, 8 deletions
diff --git a/src/Compile/Exec.hs b/src/Compile/Exec.hs index cc6d5fa..ad4180f 100644 --- a/src/Compile/Exec.hs +++ b/src/Compile/Exec.hs @@ -30,7 +30,7 @@ debug = False  -- The IORef wrapper is required for the finalizer to attach properly (see the 'Weak' docs)  data KernelLib = KernelLib !(IORef (FunPtr (Ptr () -> IO ()))) -buildKernel :: String -> String -> IO KernelLib +buildKernel :: String -> String -> IO (KernelLib, String)  buildKernel csource funname = do    template <- (++ "/tmp.chad.") <$> getTempDir    path <- mkdtemp template @@ -43,7 +43,8 @@ buildKernel csource funname = do               ,"-Wall", "-Wextra"               ,"-Wno-unused-variable", "-Wno-unused-but-set-variable"               ,"-Wno-unused-parameter", "-Wno-unused-function" -             ,"-Wno-alloc-size-larger-than"]  -- ideally we'd keep this, but gcc reports false positives +             ,"-Wno-alloc-size-larger-than"  -- ideally we'd keep this, but gcc reports false positives +             ,"-Wno-maybe-uninitialized"]  -- maximum1i goes out of range if its input is empty, yes, don't complain    (ec, gccStdout, gccStderr) <- readProcessWithExitCode "gcc" args csource    -- Print the source before the GCC output. @@ -51,11 +52,6 @@ buildKernel csource funname = do      ExitSuccess -> return ()      ExitFailure{} -> hPutStrLn stderr $ "[chad] Kernel compilation failed! Source: <<<\n" ++ lineNumbers csource ++ ">>>" -  when (not (null gccStdout)) $ -    hPutStrLn stderr $ "[chad] Kernel compilation: GCC stdout: <<<\n" ++ gccStdout ++ ">>>" -  when (not (null gccStderr)) $ -    hPutStrLn stderr $ "[chad] Kernel compilation: GCC stderr: <<<\n" ++ gccStderr ++ ">>>" -    case ec of      ExitSuccess -> return ()      ExitFailure{} -> do @@ -72,7 +68,7 @@ buildKernel csource funname = do    _ <- mkWeakIORef ref (do numLeft <- atomicModifyIORef' numLoadedCounter (\n -> (n-1, n-1))                             when debug $ hPutStrLn stderr $ "[chad] unloading kernel " ++ path ++ " (" ++ show numLeft ++ " left)"                             dlclose dl) -  return (KernelLib ref) +  return (KernelLib ref, gccStdout ++ (if null gccStdout then "" else "\n") ++ gccStderr)  foreign import ccall "dynamic"    wrapKernelFun :: FunPtr (Ptr () -> IO ()) -> Ptr () -> IO ()  | 
