Add support for llvm-targets
authorAndrey Mokhov <andrey.mokhov@gmail.com>
Sat, 9 Sep 2017 10:39:57 +0000 (11:39 +0100)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Sat, 9 Sep 2017 10:39:57 +0000 (11:39 +0100)
See #412

cfg/system.config.in
src/Base.hs
src/Oracles/Setting.hs
src/Rules/Generate.hs

index 34ef7b9..0b05259 100644 (file)
@@ -63,6 +63,7 @@ target-platform-full  = @TargetPlatformFull@
 target-arch           = @TargetArch_CPP@
 target-os             = @TargetOS_CPP@
 target-vendor         = @TargetVendor_CPP@
+llvm-target           = @LLVMTarget_CPP@
 
 cross-compiling       = @CrossCompiling@
 
index 942b272..76e8f2b 100644 (file)
@@ -106,6 +106,7 @@ inplaceLibCopyTargets :: [FilePath]
 inplaceLibCopyTargets = map (inplaceLibPath -/-)
     [ "ghc-usage.txt"
     , "ghci-usage.txt"
+    , "llvm-targets"
     , "platformConstants"
     , "settings"
     , "template-hsc.h" ]
index 8af8f38..5f148d4 100644 (file)
@@ -46,6 +46,7 @@ data Setting = BuildArch
              | TargetPlatform
              | TargetPlatformFull
              | TargetVendor
+             | LlvmTarget
              | FfiIncludeDir
              | FfiLibDir
              | GmpIncludeDir
@@ -104,6 +105,7 @@ setting key = lookupValueOrError configFile $ case key of
     TargetPlatform     -> "target-platform"
     TargetPlatformFull -> "target-platform-full"
     TargetVendor       -> "target-vendor"
+    LlvmTarget         -> "llvm-target"
     FfiIncludeDir      -> "ffi-include-dir"
     FfiLibDir          -> "ffi-lib-dir"
     GmpIncludeDir      -> "gmp-include-dir"
index b23b72d..413abe5 100644 (file)
@@ -11,9 +11,9 @@ import Oracles.ModuleFiles
 import Oracles.Setting
 import Rules.Gmp
 import Rules.Libffi
+import Target
 import Settings
 import Settings.Packages.Rts
-import Target
 import Utilities
 
 -- | Track this file to rebuild generated files whenever it changes.
@@ -145,6 +145,7 @@ copyRules :: Rules ()
 copyRules = do
     (inplaceLibPath -/- "ghc-usage.txt")     <~ return "driver"
     (inplaceLibPath -/- "ghci-usage.txt"  )  <~ return "driver"
+    (inplaceLibPath -/- "llvm-targets")      <~ return "."
     (inplaceLibPath -/- "platformConstants") <~ (buildRoot <&> (-/- generatedDir))
     (inplaceLibPath -/- "settings")          <~ return "."
     (inplaceLibPath -/- "template-hsc.h")    <~ return (pkgPath hsc2hs)
@@ -394,6 +395,7 @@ generateGhcBootPlatformH = do
     hostVendor     <- chooseSetting HostVendor    TargetVendor
     targetPlatform <- getSetting TargetPlatform
     targetArch     <- getSetting TargetArch
+    llvmTarget     <- getSetting LlvmTarget
     targetOs       <- getSetting TargetOs
     targetVendor   <- getSetting TargetVendor
     return $ unlines
@@ -414,6 +416,7 @@ generateGhcBootPlatformH = do
         , "#define BUILD_ARCH "  ++ show buildArch
         , "#define HOST_ARCH "   ++ show hostArch
         , "#define TARGET_ARCH " ++ show targetArch
+        , "#define LLVM_TARGET " ++ show llvmTarget
         , ""
         , "#define " ++ buildOs  ++ "_BUILD_OS 1"
         , "#define " ++ hostOs   ++ "_HOST_OS 1"