title: Error compiling Go from source in an Alpine Docker container: "loadinternal: cannot find runtime/cgo"
body: <p>I'm trying to build an Alpine Docker image for the FIPS-enabled version of Go. To do this, I am trying to build Go from source using the <code>dev.boringcrypto</code> branch of the <code>golang/go</code> repository.</p>
  
  <p>Upon running <code>./all.bash</code>, I get the following errors:</p>
  
  <pre><code>Step 4/4 : RUN cd go/src &amp;&amp; ./all.bash
   ---&gt; Running in 00db552598f7
  Building Go cmd/dist using /usr/lib/go.
  # _/go/src/cmd/dist
  loadinternal: cannot find runtime/cgo
  /usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
  /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64- 
  alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
  /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64- 
  alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
  /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
  collect2: error: ld returned 1 exit status
  
  The command '/bin/bash -c cd go/src &amp;&amp; ./all.bash' returned a non-zero code: 2
  </code></pre>
  
  <p>Which causes the installation tests to fail and kicks me out of the Docker image build.</p>
  
  <p>I have the <code>gcc</code> installed on the image, and tried setting the environment variable <code>CGO_ENABLED=0</code> as suggested in other questions, but neither of these things seem to alleviate the problem.</p>
  
  <p>I'm at my wits end with this problem. Has anybody else run into similar issues in the past? I don't understand why this is happening, as the build runs fine in an Ubuntu container.</p>
  
  <p>Thanks!</p>