title: Static linking against openmp
body: <p>I am building a shared object on Ubuntu 16.04 which uses libgomp. My goal is to make this final object as portable as possible, by static linking anything not normally in a base distribution (using docker ubuntu or alpine images as a reference baseline). I've been able to do this with my other dependencies pretty easily, but I'm hung up on libgomp.</p>
  
  <p>I can link just fine with the <code>-fopenmp</code> option, and get a dynamic link:</p>
  
  <pre><code># ldd *.so
  linux-vdso.so.1 =&gt;  (0x00007fff01df4000)
  libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9ba59db000)
  libgomp.so.1 =&gt; /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f9ba57b9000)
  libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9ba55a3000)
  libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9ba5386000)
  libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9ba4fbc000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f9ba6516000)
  libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9ba4db8000)
  </code></pre>
  
  <p>But if I naively add <code>-static</code> before <code>-fopenmp</code> I get:</p>
  
  <pre><code>relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC
  </code></pre>
  
  <p>Fair enough; with my other dependencies I've just built from source to enable PIC and any other options I needed. When I try to do the same with libgomp, though, I'm not having any luck. I checked out gcc 5.5 from <a href="http://gcc.gnu.org/svn/gcc" rel="nofollow noreferrer">http://gcc.gnu.org/svn/gcc</a>, and tried building from the <code>gcc/libgomp</code> folder. There is a configure script already generated, but running it returns:</p>
  
  <pre><code>./config.status: line 1486: ./../../config-ml.in: No such file or directory
  </code></pre>
  
  <p>OK, apparently this has something to do with multilibrary support, which I don't believe I need. Running <code>./configure --help</code> shows that there is an <code>--enable-multilib</code> option with no obvious default, but setting <code>--enable-multilib=no</code> or <code>--disable-multilib</code> still returns the same error. I've also tried running <code>autoreconf -fiv</code> to regenerate the configure script, but I get this error:</p>
  
  <pre><code>configure.ac:5: error: Please use exactly Autoconf 2.64 instead of 2.69.
  </code></pre>
  
  <p>If I explicitly install and use autoreconf2.64, I get this one:</p>
  
  <pre><code>configure.ac:65: error: Autoconf version 2.65 or higher is required
  </code></pre>
  
  <p>What am I missing?</p>