Skip to content

Link error when using LLVM backend on Windows: undefined symbol: `_fltused`

Summary

When using LLVM backend on Windows, a link error "undefined symbol: _fltused" occurs if the program contains floating-point related code.

Steps to reproduce

With MSYS2,

$ cat test-llvm.hs
add :: Double -> Double -> Double
add x y = x + y
{-# NOINLINE add #-}
main = do putStrLn "Hello world!"
          print (add 1.0 2.0)

$ ghc-9.4.3 -fllvm -pgmlo /c/ghcup/ghc/9.4.3/mingw/bin/opt -pgmlc /c/ghcup/ghc/9.4.3/mingw/bin/llc -fforce-recomp test-llvm.hs
[1 of 2] Compiling Main             ( test-llvm.hs, test-llvm.o )
[2 of 2] Linking test-llvm.exe
ld.lld: error: undefined symbol: _fltused
>>> referenced by test-llvm.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-9.4.3.exe: `clang.exe' failed in phase `Linker'. (Exit code: 1)

Expected behavior

The program should link fine.

Environment

  • GHC version used: 9.4.3

Optional:

  • Operating System: Windows
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information