Linking error with ANN pragma
There seems to be an issue with the ANN pragma, with fatal compilation errors.
To reproduce, setup two modules as such:
module Test where
import Weights (Weight(..))
{-# ANN mainTest (Weight 2) #-}
mainTest :: IO ()
mainTest = return ()
{-# LANGUAGE DeriveDataTypeable #-}
module Weights (Weight(..)) where
import Data.Data (Data(..))
newtype Weight = Weight Integer deriving Data
Compiling with GHC version 8.2.2
yields:
λ ghc Test.hs
[1 of 2] Compiling Weights ( Weights.hs, Weights.o )
[2 of 2] Compiling Test ( Test.hs, Test.o )
Test.hs:5:1: fatal:
cannot find object file ‘./Weights.dyn_o’
while linking an interpreted expression
The issue disappears with -dynamic
or -dynamic-too
:
λ ghc -dynamic Test.hs
[1 of 2] Compiling Weights ( Weights.hs, Weights.o )
[2 of 2] Compiling Test ( Test.hs, Test.o )
Issue persist in HEAD, GHC version 8.5.20180219
, but again disappears with -dynamic-too
or -dynamic
:
λ ../../ghc/inplace/bin/ghc-stage2 -dynamic-too Test.hs
[1 of 2] Compiling Weights ( Weights.hs, Weights.o )
[2 of 2] Compiling Test ( Test.hs, Test.o )
Remove the ANN pragma, and the compiler behaves just fine with both GHC versions. Please tell me if I can provide more information. Cheers.