mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-11-11 03:34:13 +03:00
Call gcc using rawSystem
This commit is contained in:
parent
528cc113fe
commit
27d6b04fcd
@ -81,7 +81,7 @@ showver = do putStrLn $ "Idris version " ++ ver
|
||||
|
||||
showLibs :: IO b
|
||||
showLibs = do libFlags <- getLibFlags
|
||||
putStrLn libFlags
|
||||
putStrLn $ unwords libFlags
|
||||
exitWith ExitSuccess
|
||||
|
||||
showLibdir :: IO b
|
||||
@ -91,5 +91,5 @@ showLibdir = do dir <- getIdrisLibDir
|
||||
|
||||
showIncs :: IO b
|
||||
showIncs = do incFlags <- getIncFlags
|
||||
putStrLn incFlags
|
||||
putStrLn $ unwords incFlags
|
||||
exitWith ExitSuccess
|
||||
|
@ -24,24 +24,22 @@ codegenC ci = codegenC' (simpleDecls ci)
|
||||
(outputFile ci)
|
||||
(outputType ci)
|
||||
(includes ci)
|
||||
(concatMap mkObj (compileObjs ci))
|
||||
(concatMap mkLib (compileLibs ci) ++
|
||||
concatMap incdir (importDirs ci))
|
||||
(concatMap mkFlag (compilerFlags ci))
|
||||
(compileObjs ci)
|
||||
(map mkLib (compileLibs ci) ++
|
||||
map incdir (importDirs ci))
|
||||
(compilerFlags ci)
|
||||
(debugLevel ci)
|
||||
|
||||
where mkObj f = f ++ " "
|
||||
mkLib l = "-l" ++ l ++ " "
|
||||
mkFlag l = l ++ " "
|
||||
incdir i = "-I" ++ i ++ " "
|
||||
where mkLib l = "-l" ++ l
|
||||
incdir i = "-I" ++ i
|
||||
|
||||
codegenC' :: [(Name, SDecl)] ->
|
||||
String -> -- output file name
|
||||
OutputType -> -- generate executable if True, only .o if False
|
||||
[FilePath] -> -- include files
|
||||
String -> -- extra object files
|
||||
String -> -- extra compiler flags (libraries)
|
||||
String -> -- extra compiler flags (anything)
|
||||
[String] -> -- extra object files
|
||||
[String] -> -- extra compiler flags (libraries)
|
||||
[String] -> -- extra compiler flags (anything)
|
||||
DbgLevel ->
|
||||
IO ()
|
||||
codegenC' defs out exec incs objs libs flags dbg
|
||||
@ -64,23 +62,22 @@ codegenC' defs out exec incs objs libs flags dbg
|
||||
comp <- getCC
|
||||
libFlags <- getLibFlags
|
||||
incFlags <- getIncFlags
|
||||
let gcc = comp ++ " " ++
|
||||
gccDbg dbg ++ " " ++
|
||||
gccFlags ++
|
||||
-- # Any flags defined here which alter the RTS API must also be added to config.mk
|
||||
" -DHAS_PTHREAD -DIDRIS_ENABLE_STATS" ++
|
||||
" -I. " ++ objs ++ " -x c " ++
|
||||
(if (exec == Executable) then "" else " -c ") ++
|
||||
" " ++ tmpn ++
|
||||
" " ++ libFlags ++
|
||||
" " ++ incFlags ++
|
||||
" " ++ libs ++
|
||||
" " ++ flags ++
|
||||
" -o " ++ out
|
||||
let args = [gccDbg dbg] ++
|
||||
gccFlags ++
|
||||
-- # Any flags defined here which alter the RTS API must also be added to config.mk
|
||||
["-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS",
|
||||
"-I."] ++ objs ++ ["-x", "c"] ++
|
||||
(if (exec == Executable) then [] else ["-c"]) ++
|
||||
[tmpn] ++
|
||||
libFlags ++
|
||||
incFlags ++
|
||||
libs ++
|
||||
flags ++
|
||||
["-o", out]
|
||||
-- putStrLn gcc
|
||||
exit <- system gcc
|
||||
exit <- rawSystem comp args
|
||||
when (exit /= ExitSuccess) $
|
||||
putStrLn ("FAILURE: " ++ gcc)
|
||||
putStrLn ("FAILURE: " ++ show comp ++ " " ++ show args)
|
||||
|
||||
headers xs =
|
||||
concatMap
|
||||
@ -92,7 +89,7 @@ debug _ = ""
|
||||
|
||||
-- We're using signed integers now. Make sure we get consistent semantics
|
||||
-- out of them from gcc. See e.g. http://thiemonagel.de/2010/01/signed-integer-overflow/
|
||||
gccFlags = " -fwrapv -fno-strict-overflow"
|
||||
gccFlags = ["-fwrapv", "-fno-strict-overflow"]
|
||||
|
||||
gccDbg DEBUG = "-g"
|
||||
gccDbg TRACE = "-O2"
|
||||
|
@ -38,31 +38,31 @@ getTargetDir :: IO String
|
||||
getTargetDir = environment "TARGET" >>= maybe getDataDir return
|
||||
|
||||
#if defined(FREEBSD) || defined(DRAGONFLY)
|
||||
extraLib = " -L/usr/local/lib"
|
||||
extraLib = ["-L/usr/local/lib"]
|
||||
#else
|
||||
extraLib = ""
|
||||
extraLib = []
|
||||
#endif
|
||||
|
||||
#ifdef IDRIS_GMP
|
||||
gmpLib = " -lgmp"
|
||||
gmpLib = ["-lgmp"]
|
||||
#else
|
||||
gmpLib = ""
|
||||
gmpLib = []
|
||||
#endif
|
||||
|
||||
getLibFlags = do dir <- getDataDir
|
||||
return $ "-L" ++ (dir </> "rts") ++
|
||||
" -lidris_rts" ++ extraLib ++ gmpLib ++ " -lpthread"
|
||||
return $ ["-L" ++ (dir </> "rts"),
|
||||
"-lidris_rts"] ++ extraLib ++ gmpLib ++ ["-lpthread"]
|
||||
|
||||
getIdrisLibDir = do dir <- getDataDir
|
||||
return $ addTrailingPathSeparator dir
|
||||
|
||||
#if defined(FREEBSD) || defined(DRAGONFLY)
|
||||
extraInclude = " -I/usr/local/include"
|
||||
extraInclude = ["-I/usr/local/include"]
|
||||
#else
|
||||
extraInclude = ""
|
||||
extraInclude = []
|
||||
#endif
|
||||
getIncFlags = do dir <- getDataDir
|
||||
return $ "-I" ++ dir </> "rts" ++ extraInclude
|
||||
return $ ("-I" ++ dir </> "rts") : extraInclude
|
||||
|
||||
getExecutablePom = do dir <- getDataDir
|
||||
return $ dir </> "java" </> "executable_pom.xml"
|
||||
|
@ -224,7 +224,7 @@ testLib warn p f
|
||||
(tmpf, tmph) <- tempfile
|
||||
hClose tmph
|
||||
let libtest = d </> "rts" </> "libtest.c"
|
||||
e <- system $ gcc ++ " " ++ libtest ++ " -l" ++ f ++ " -o " ++ tmpf
|
||||
e <- rawSystem gcc [libtest, "-l" ++ f, "-o", tmpf]
|
||||
case e of
|
||||
ExitSuccess -> return True
|
||||
_ -> do if warn
|
||||
|
Loading…
Reference in New Issue
Block a user