title: Build against an old glibc with Guix
body: <p>Say that you got a c program, but almost any program will do, and put it in a file:</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &lt;gnu/libc-version.h&gt;
  
  int main (void) {
      puts (gnu_get_libc_version ());
      return 0;
  }
  </code></pre>
  <p>And say that you want to build it against a specific version of glibc, for some reason. My initial attempt at doing this would be to create a Guix environment containing that old version of <code>glibc</code> along with <code>gcc</code> (and <code>coreutils</code> for programs like <code>ls</code>).</p>
  <pre class="lang-bsh prettyprint-override"><code>$ guix environment --pure --ad-hoc glibc@2.29 gcc-toolchain coreutils
  $ rm a.out &amp;&amp; gcc printer.c &amp;&amp; ldd a.out &amp;&amp; a.out
      linux-vdso.so.1 (0x00007ffd2cd0c000)
      libgcc_s.so.1 =&gt; /gnu/store/jlrfl1ss3b4xjggvajwffa9zppfcxksf-gcc-5.5.0-lib/lib/libgcc_s.so.1 (0x00007fcefd7b6000)
      libc.so.6 =&gt; /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libc.so.6 (0x00007fcefd5f9000)
      /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 (0x00007fcefd7d1000)
  2.31
  </code></pre>
  <p>Unfortunately this doesn't seem to work. The resulting program is linked against a newer version of <code>glibc</code> than I expected, 2.31 rather than 2.29. But this may be due to <code>gcc</code> itself being linked against linked against <code>glibc</code> 2.31 and that ends up polluting the environment, so to speak.</p>
  <pre class="lang-bsh prettyprint-override"><code>$ ldd $(which gcc)
      linux-vdso.so.1 (0x00007fff7cfc5000)
      libm.so.6 =&gt; /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libm.so.6 (0x00007ff842b93000)
      libc.so.6 =&gt; /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libc.so.6 (0x00007ff8429d6000)
      /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 (0x00007ff842cd6000)
  </code></pre>
  <p>Where do I go from here? I've tried using older versions of <code>gcc</code> packaged in Guix, but they all seem to be built against <code>glibc</code> 2.31. I also tried adding <code>-L /gnu/store/hlsas48h6x7364kcfs8yy6xfksdsffr4-glibc-2.29/lib</code> to my <code>gcc</code>-invocation but to no avail.</p>