Skip to content

`__GLASGOW_HASKELL_LLVM__` is not defined even if `-fllvm` is set

Summary

The docs say __GLASGOW_HASKELL_LLVM__ is defined if -fllvm is set. This is not the case.

Steps to reproduce

$ cat test_llvm.hs
{-# LANGUAGE CPP #-}

main :: IO ()
main = do
#if defined(__GLASGOW_HASKELL_LLVM__)
  putStrLn $ "__GLASGOW_HASKELL_LLVM__ = " ++ show __GLASGOW_HASKELL_LLVM__
#else
  putStrLn "__GLASGOW_HASKELL_LLVM__ not defined"
#endif
$ grep LLVM ~/.ghcup/ghc/9.12.1/lib/ghc-9.12.1/lib/settings
,("LLVM target", "arm64-apple-darwin")
,("LLVM llc command", "/opt/homebrew/opt/llvm@18/bin/llc")
,("LLVM opt command", "/opt/homebrew/opt/llvm@18/bin/opt")
,("LLVM llvm-as command", "clang")
$ ghc-9.12.1 -fllvm -fforce-recomp test_llvm.hs
$ ./test_llvm
__GLASGOW_HASKELL_LLVM__ not defined

Expected behavior

The program above should print __GLASGOW_HASKELL_LLVM__ = 1800 or something.

Environment

  • GHC version used: 9.12.1
  • Operating System: Ubuntu (with LLVM from APT) / macOS (with LLVM from Homebrew)
  • System Architecture: x86_64 / AArch64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information