<div dir="ltr">A <a href="https://github.com/haskell/cabal/issues/1284">cabal-install bug</a> was fixed recently that pertains to building C libraries with profiling.<div><br></div><div>As a result, I want <a href="http://hackage.haskell.org/package/atomic-primops-0.1.0.2">a certain package</a> to test if cabal-install < 0.17.0 is used, and throw a preemptive error. Otherwise this package fails in weird ways at runtime (it's a nasty one).</div>
<div><br></div><div><div>I noticed with some surprise the following sequence:</div><div><br></div><div><font face="courier new, monospace"><b> $ cabal --version</b></font></div><div><font face="courier new, monospace"><b> cabal-install version 1.16.0.2</b></font></div>
<div><font face="courier new, monospace"><b> using version 1.16.0.3 of the Cabal library</b></font></div><div><font face="courier new, monospace"><b> $ cabal clean</b></font></div><div><font face="courier new, monospace"><b> $ cabal install</b></font></div>
<div><font face="courier new, monospace"><b> $ cat dist/build/autogen/cabal_macros.h | grep VERSION_Cabal</b></font></div><div><font face="courier new, monospace"><b> #define VERSION_Cabal "1.17.0"</b></font></div>
<div><br></div><div>Alright, so that, in retrospect, makes sense. The version is which *my* library is linked with is the relevant one, not the one cabal-install was linked with [1].</div><div><br></div><div>So the natural next thought is to move the MIN_VERSION_Cabal test into Setup.hs, and force cabal to use it by setting the build type to Custom. But... I just learned from this ticket that the cabal macros are not available in Setup.hs:</div>
<div><br></div><div> <a href="http://hackage.haskell.org/trac/hackage/ticket/326">http://hackage.haskell.org/trac/hackage/ticket/326</a></div><div><br></div><div>Uh oh, what's left? </div><div><br></div><div> -Ryan</div>
<div><br></div><div>[1] P.S. Personally I'm now using a bash function like below, to force the two versions to be the same:</div><div><br></div><div>function safe_cabal_install () {</div><div> VER=`cabal --version | tail -n1 | awk '{ print $3 }'`</div>
<div> cabal install --constraint="Cabal==$VER" $*</div><div>}</div><div><br></div></div></div>