<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 &lt; 0.17.0 is used, and throw a preemptive error.  Otherwise this package fails in weird ways at runtime (it&#39;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 &quot;1.17.0&quot;</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&#39;s left?  </div><div><br></div><div> -Ryan</div>

<div><br></div><div>[1] P.S. Personally I&#39;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 &#39;{ print $3 }&#39;`</div>

<div>  cabal install --constraint=&quot;Cabal==$VER&quot; $*</div><div>}</div><div><br></div></div></div>