packages feed

llvm-ffi-19.0: llvm-ffi.cabal

Cabal-Version: 2.2
Name:          llvm-ffi
Version:       19.0
License:       BSD-3-Clause
License-File:  LICENSE
Synopsis:      FFI bindings to the LLVM compiler toolkit.
Description:
  FFI bindings to the LLVM compiler toolkit.
  .
  Installation cannot be done fully automatically.
  It would require Cabal code that is bound to certain Cabal versions
  and is prone to fail.
  We give several non-automatic ways
  that also allow you to choose a particular LLVM version.
  .
  First possibility is to point Cabal
  to the LLVM installation directories manually.
  It is recommended to add options to your global @.cabal/config@:
  .
  > extra-include-dirs: /usr/lib/llvm-19/include
  > extra-lib-dirs: /usr/lib/llvm-19/lib
  .
  This works for both @v1-build@ and @v2-build@.
  The shown paths work for Debian and Ubuntu
  using the LLVM repositories at <https://apt.llvm.org/>.
  You can obtain them with
  .
  > llvm-config-19 --includedir --libdir
  .
  You can choose specific LLVM versions per project.
  For @v1-builds@ it works like so:
  .
  > cabal install -fllvm1300 --extra-include-dirs=$(llvm-config-13 --includedir) --extra-lib-dirs=$(llvm-config-13 --libdir) yourpackage
  .
  For Nix-style build you must add some options
  to the @cabal.project.local@ file of your LLVM-related project:
  .
  > package llvm-ffi
  >   flags: +llvm1300
  >   extra-include-dirs: /usr/lib/llvm-13/include
  >   extra-lib-dirs: /usr/lib/llvm-13/lib
  .
  Alternatively, you may set environment variables globally or locally:
  .
  > export CPATH=/usr/lib/llvm-19/include:$CPATH
  > export C_INCLUDE_PATH=/usr/lib/llvm-19/include:$C_INCLUDE_PATH
  > export LD_LIBRARY_PATH=/usr/lib/llvm-19/lib:$LD_LIBRARY_PATH
  .
  You can install and make LLVM library available
  in an elegant way using Nix:
  .
  > nix-shell -p llvmPackages_19.libllvm
  .
  Though, for compatibility of GHC with LLVM and GLIBC
  you will need to use more packages from Nix
  and you better use a @shell.nix@ file for bundling those:
  .
  > let
  >   pkgs = import <nixpkgs> {};
  >   llvmPkgs = pkgs.llvmPackages_19.libllvm;
  > in
  > pkgs.mkShell {
  >   nativeBuildInputs = (with pkgs; [
  >     gnumake
  >     pkg-config
  >     ghc
  >     cabal-install
  >     llvmPkgs
  >   ]);
  >   CPATH="${llvmPkgs.dev}/include";
  >   C_INCLUDE_PATH="${llvmPkgs.dev}/include";
  >   LD_LIBRARY_PATH="${llvmPkgs.lib}/lib";
  > }
  .
  The second way uses @pkg-config@.
  You can store above paths permanently in a @pkg-config@ file like @llvm.pc@.
  The optimal way would be if LLVM installations or GNU/Linux distributions
  would contain such a file, but they don't.
  Instead, you may generate it using the @llvm-pkg-config@ package
  or write one manually.
  Then you run
  .
  > cabal install -fpkgConfig
  .
  We try to stay up to date with LLVM releases.
  The current version of this package is compatible with LLVM 13-19.
  Please understand that the package may or may not work
  against older LLVM releases.
  .
  Warning for inplace builds:
  Re-configuring the package using, say @-fllvm1600@,
  and re-buildung it might result in corrupt code.
  You must make sure that the stuff in @cbits@ is re-compiled.
  Cabal or GHC may forget about that.
  You are safe if you run @cabal clean@.
  .
  Caution: Ugly crashes can occur
  if you have configured paths for LLVM version X in @.cabal/config@
  and try to build @llvm-ffi@ for a different LLVM version Y.
  Counterintuitively, global search paths have higher precedence
  than local ones: <https://github.com/haskell/cabal/issues/7782>.
  But that does not simply mean
  that the local configuration is ignored completely.
  Instead the local library file is found,
  because its name libLLVM-Y.so is unique,
  whereas the include file names clash,
  thus the ones from the global include directory are used.
Author:        Henning Thielemann, Bryan O'Sullivan, Lennart Augustsson
Maintainer:    Henning Thielemann <llvm@henning-thielemann.de>
Homepage:      http://haskell.org/haskellwiki/LLVM
Stability:     experimental
Category:      Compilers/Interpreters, Code Generation
Tested-With:   GHC==7.4.2, GHC==7.6.3, GHC==7.8.4
Tested-With:   GHC==8.0.2, GHC==8.2.2, GHC==8.4.4
Tested-With:   GHC==8.6.5, GHC==8.8.4, GHC==8.10.4
Build-Type:    Simple

Extra-Source-Files:
  include/support.h
  tool/ltrace.config
  tool/ltrace.readme
  flatpak/llvm-3.8.1.json
  flatpak/llvm-3.9.1.json

Flag developer
  Description: developer mode - warnings let compilation fail
  Manual: True
  Default: False

Flag buildExamples
  Description: Build example executables
  Manual: True
  Default: False

Flag pkgConfig
  Description: use pkgconfig (llvm.pc) instead of extra-libraries
  Manual: True
  Default: False

Flag specificPkgConfig
  Description: use llvm-x.pc instead of llvm.pc
  Manual: True
  Default: True

Flag llvm1300
  Description: use LLVM-13 instead of latest supported LLVM
  Manual: True
  Default: False

Flag llvm1400
  Description: use LLVM-14 instead of latest supported LLVM
  Manual: True
  Default: False

Flag llvm1500
  Description: use LLVM-15 instead of latest supported LLVM
  Manual: True
  Default: False

Flag llvm1600
  Description: use LLVM-16 instead of latest supported LLVM
  Manual: True
  Default: False

Flag llvm1700
  Description: use LLVM-17 instead of latest supported LLVM
  Manual: True
  Default: False

Flag llvm1800
  Description: use LLVM-18 instead of latest supported LLVM
  Manual: True
  Default: False

Source-Repository head
  Type:     darcs
  Location: https://hub.darcs.net/thielema/llvm-ffi/

Source-Repository this
  Tag:      19.0
  Type:     darcs
  Location: https://hub.darcs.net/thielema/llvm-ffi/

Library
  Build-Depends:
    enumset >=0.0.5 && <0.2,
    base >= 3 && < 5

  Hs-Source-Dirs: src
  GHC-Options: -Wall -fwarn-missing-import-lists
  Default-Language: Haskell2010

  If flag(developer)
    GHC-Options: -Werror

  Exposed-Modules:
      LLVM.FFI.Analysis
      LLVM.FFI.BitReader
      LLVM.FFI.BitWriter
      LLVM.FFI.Core
      LLVM.FFI.Core.Attribute
      LLVM.FFI.Error
      LLVM.FFI.ExecutionEngine
      LLVM.FFI.Support.Host
      LLVM.FFI.Target
      LLVM.FFI.TargetMachine
      LLVM.FFI.Transforms.PassBuilder
      LLVM.Target.Native

  Other-modules:
      LLVM.FFI.Base
      LLVM.FFI.Version
      LLVM.Target.ARM
      LLVM.Target.Hexagon
      LLVM.Target.MSP430
      LLVM.Target.Mips
      LLVM.Target.NVPTX
      LLVM.Target.PowerPC
      LLVM.Target.Sparc
      LLVM.Target.X86
      LLVM.Target.XCore
      LLVM.Raw.Core
      LLVM.FFI.Core14

  If flag(llvm1300)
    If flag(pkgConfig)
      If flag(specificPkgConfig)
        PkgConfig-Depends: llvm-13
      Else
        PkgConfig-Depends: llvm == 13.*
    Else
      Extra-Libraries: LLVM-13
    Hs-Source-Dirs: src/13, src/before14
    CC-Options: -DHS_LLVM_VERSION=1300
    Cxx-Options: -DHS_LLVM_VERSION=1300
    CPP-Options: -DHS_LLVM_VERSION=1300
  Else
    Hs-Source-Dirs: src/from14
    If flag(llvm1400)
      If flag(pkgConfig)
        If flag(specificPkgConfig)
          PkgConfig-Depends: llvm-14
        Else
          PkgConfig-Depends: llvm == 14.*
      Else
        Extra-Libraries: LLVM-14
      Hs-Source-Dirs: src/14
      CC-Options: -DHS_LLVM_VERSION=1400
      Cxx-Options: -DHS_LLVM_VERSION=1400
      CPP-Options: -DHS_LLVM_VERSION=1400
    Else
      If flag(llvm1500)
        If flag(pkgConfig)
          If flag(specificPkgConfig)
            PkgConfig-Depends: llvm-15
          Else
            PkgConfig-Depends: llvm == 15.*
        Else
          Extra-Libraries: LLVM-15
        Hs-Source-Dirs: src/15
        CC-Options: -DHS_LLVM_VERSION=1500
        Cxx-Options: -DHS_LLVM_VERSION=1500
        CPP-Options: -DHS_LLVM_VERSION=1500
      Else
        Cxx-Options: -std=c++17
        If flag(llvm1600)
          If flag(pkgConfig)
            If flag(specificPkgConfig)
              PkgConfig-Depends: llvm-16
            Else
              PkgConfig-Depends: llvm == 16.*
          Else
            Extra-Libraries: LLVM-16
          Hs-Source-Dirs: src/16
          CC-Options: -DHS_LLVM_VERSION=1600
          Cxx-Options: -DHS_LLVM_VERSION=1600
          CPP-Options: -DHS_LLVM_VERSION=1600
        Else
          If flag(llvm1700)
            If flag(pkgConfig)
              If flag(specificPkgConfig)
                PkgConfig-Depends: llvm-17
              Else
                PkgConfig-Depends: llvm == 17.*
            Else
              Extra-Libraries: LLVM-17
            Hs-Source-Dirs: src/17
            CC-Options: -DHS_LLVM_VERSION=1700
            Cxx-Options: -DHS_LLVM_VERSION=1700
            CPP-Options: -DHS_LLVM_VERSION=1700
          Else
            If flag(llvm1800)
              If flag(pkgConfig)
                If flag(specificPkgConfig)
                  PkgConfig-Depends: llvm-18
                Else
                  PkgConfig-Depends: llvm == 18.*
              Else
                Extra-Libraries: LLVM-18
              Hs-Source-Dirs: src/18
              CC-Options: -DHS_LLVM_VERSION=1800
              Cxx-Options: -DHS_LLVM_VERSION=1800
              CPP-Options: -DHS_LLVM_VERSION=1800
            Else
              If flag(pkgConfig)
                If flag(specificPkgConfig)
                  PkgConfig-Depends: llvm-19
                Else
                  PkgConfig-Depends: llvm == 19.*
              Else
                Extra-Libraries: LLVM-19
              Hs-Source-Dirs: src/19
              CC-Options: -DHS_LLVM_VERSION=1900
              Cxx-Options: -DHS_LLVM_VERSION=1900
              CPP-Options: -DHS_LLVM_VERSION=1900

  CC-Options: -DHAVE_LLVM_SUPPORT_DYNAMICLIBRARY_H=1
  CPP-Options: -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
  Include-Dirs: include
  Extra-Libraries: stdc++
  Cxx-Options: -std=c++0x -std=c++14
  Cxx-Sources:
    cbits/support.cpp

Executable llvm-ffi-host
  If flag(buildExamples)
    Build-Depends:
      llvm-ffi,
      utility-ht >=0.0.9 && <0.1,
      base
  Else
    Buildable: False

  If flag(developer)
    GHC-Options: -Werror

  Hs-Source-Dirs: example
  GHC-Options: -Wall
  Default-Language: Haskell2010
  Main-Is: Host.hs
  Other-Modules: Common

Executable llvm-ffi-jit
  If flag(buildExamples)
    Build-Depends:
      llvm-ffi,
      utility-ht >=0.0.9 && <0.1,
      base
  Else
    Buildable: False

  If flag(developer)
    GHC-Options: -Werror

  Hs-Source-Dirs: example
  GHC-Options: -Wall
  Default-Language: Haskell2010
  Main-Is: JIT.hs
  Other-Modules: Common

Executable llvm-ffi-offset
  If flag(buildExamples)
    Build-Depends:
      llvm-ffi,
      utility-ht >=0.0.9 && <0.1,
      base
  Else
    Buildable: False

  If flag(developer)
    GHC-Options: -Werror

  Hs-Source-Dirs: example
  GHC-Options: -Wall
  Default-Language: Haskell2010
  Main-Is: Offset.hs
  Other-Modules: Common