on master help sign in
Merge pull request #389 from melted/optllvm

Make LLVM optional but the default

commit0c1deaf9879cd16e6acc8d1074898de6ae966d9e authorEdwin Brady <edwin.brady@gmail.com> dateSat 13 Jul 2013, 01:29 (13 years ago) parentb7535907eaa86a
5 files changed+63−8
Setup.hs+10−2 idris.cabal+13−2 src/IRTS/Compiler.hs+5−1 src/Idris/REPL.hs+5−3 src/Util/LLVMStubs.hs+30
Setup.hs+10−2
@@ -143,6 +143,12 @@ javaFlag flags =
143143 Just False -> False
144144 Nothing -> False
145145
146+llvmFlag flags =
147+ case lookup (FlagName "LLVM") (S.configConfigurationsFlags flags) of
148+ Just True -> True
149+ Just False -> False
150+ Nothing -> False
151+
146152noEffectsFlag flags =
147153 case lookup (FlagName "noeffects") (S.configConfigurationsFlags flags) of
148154 Just True -> True
@@ -167,7 +173,8 @@ main = do
167173 let withoutEffects = noEffectsFlag $ configFlags lbi
168174 installStdLib pkg lbi withoutEffects verb
169175 (S.fromFlag $ S.copyDest flags)
170− installLLVMLib verb pkg lbi (S.fromFlag $ S.copyDest flags)
176+ when (llvmFlag $ configFlags lbi)
177+ (installLLVMLib verb pkg lbi (S.fromFlag $ S.copyDest flags))
171178 when (javaFlag $ configFlags lbi)
172179 (installJavaLib pkg
173180 lbi
@@ -180,7 +187,8 @@ main = do
180187 let withoutEffects = noEffectsFlag $ configFlags lbi
181188 installStdLib pkg lbi withoutEffects verb
182189 NoCopyDest
183− installLLVMLib verb pkg lbi NoCopyDest
190+ when (llvmFlag $ configFlags lbi)
191+ (installLLVMLib verb pkg lbi NoCopyDest)
184192 when (javaFlag $ configFlags lbi)
185193 (installJavaLib pkg
186194 lbi
idris.cabal+13−2
@@ -242,6 +242,11 @@ Flag NoEffects
242242 Description: Do not build the effects package
243243 Default: False
244244
245+Flag LLVM
246+ Description: Build the LLVM backend
247+ Default: True
248+ manual: True
249+
245250Executable idris
246251 Main-is: Main.hs
247252 hs-source-dirs: src
@@ -267,7 +272,7 @@ Executable idris
267272 IRTS.CodegenC, IRTS.Defunctionalise, IRTS.Inliner,
268273 IRTS.Compiler, IRTS.CodegenJava, IRTS.Java.ASTBuilding,
269274 IRTS.Java.JTypes, IRTS.Java.Mangling, IRTS.BCImp,
270− IRTS.CodegenJavaScript, IRTS.CodegenLLVM,
275+ IRTS.CodegenJavaScript,
271276 IRTS.CodegenCommon, IRTS.DumpBC
272277
273278 Paths_idris
@@ -276,7 +281,7 @@ Executable idris
276281 haskeline>=0.7, split, directory,
277282 containers, process, transformers, filepath,
278283 directory, binary, bytestring, text, pretty,
279− language-java>=0.2.2, libffi, llvm-general>=3.3.4.1 && <3.3.5,
284+ language-java>=0.2.2, libffi,
280285 vector, vector-binary-instances
281286
282287 Extensions: MultiParamTypeClasses, FunctionalDependencies,
@@ -292,3 +297,9 @@ Executable idris
292297 if os(windows)
293298 cpp-options: -DWINDOWS
294299 build-depends: Win32
300+ if flag(LLVM)
301+ other-modules: IRTS.CodegenLLVM
302+ cpp-options: -DIDRIS_LLVM
303+ build-depends: llvm-general>=3.3.4.1 && <3.3.5
304+ else
305+ other-modules: Util.LLVMStubs
src/IRTS/Compiler.hs+5−1
@@ -1,4 +1,4 @@
1−{-# LANGUAGE PatternGuards, TypeSynonymInstances #-}
1+{-# LANGUAGE PatternGuards, TypeSynonymInstances, CPP #-}
22
33module IRTS.Compiler where
44
@@ -10,7 +10,11 @@ import IRTS.CodegenC
1010import IRTS.CodegenJava
1111import IRTS.DumpBC
1212import IRTS.CodegenJavaScript
13+#ifdef IDRIS_LLVM
1314import IRTS.CodegenLLVM
15+#else
16+import Util.LLVMStubs
17+#endif
1418import IRTS.Inliner
1519
1620import Idris.AbsSyntax
src/Idris/REPL.hs+5−3
@@ -1,5 +1,5 @@
11{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, DeriveFunctor,
2− PatternGuards #-}
2+ PatternGuards, CPP #-}
33
44module Idris.REPL where
55
@@ -38,9 +38,11 @@ import IRTS.CodegenCommon
3838-- import RTS.Bytecode
3939-- import RTS.PreC
4040-- import RTS.CodegenC
41−
41+#ifdef IDRIS_LLVM
4242import LLVM.General.Target
43−
43+#else
44+import Util.LLVMStubs
45+#endif
4446import System.Console.Haskeline as H
4547import System.FilePath
4648import System.Exit
src/Util/LLVMStubs.hsnew file+30
@@ -0,0 +1,30 @@
1+{--
2+
3+Things needed to build without LLVM
4+Replaces stuff from LLVM.General.Target and IRTS.CodegenLLVM.
5+
6+--}
7+
8+module Util.LLVMStubs where
9+
10+import qualified Core.TT as TT
11+import IRTS.Simplified
12+import IRTS.CodegenCommon
13+
14+
15+getDefaultTargetTriple :: IO String
16+getDefaultTargetTriple = return ""
17+
18+getHostCPUName :: IO String
19+getHostCPUName = return ""
20+
21+
22+codegenLLVM :: [(TT.Name, SDecl)] ->
23+ String -> -- target triple
24+ String -> -- target CPU
25+ Int -> -- Optimization degree
26+ FilePath -> -- output file name
27+ OutputType ->
28+ IO ()
29+
30+codegenLLVM _ _ _ _ _ _ = print "Error: This Idris was compiled without the LLVM backend."