title: g++: internal compiler error: Segmentation fault (program cc1plus) - where do I start?
body: <p>I am porting code that compiled on <strong>Ubuntu 14.04</strong> to <strong>16.04</strong>. I have cloned my git repo, installed dependencies and tried the usual <code>make</code> command, soon I hit a <code>g++: internal compiler error: Segmentation fault (program cc1plus)</code> ... yet I am not sure where to start to diagnose and resolve this issue.</p>
  
  <p>I will share as much as I can, see if someone can guide me through a resolution.</p>
  
  <h3>Ubuntu</h3>
  
  <pre><code>$ lsb_release -a 
  No LSB modules are available.
  Distributor ID: Ubuntu
  Description:    Ubuntu 16.04.2 LTS
  Release:    16.04
  Codename:   xenial
  </code></pre>
  
  <h3>g++</h3>
  
  <pre><code>$ g++ --version
  g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  </code></pre>
  
  <h3>python</h3>
  
  <pre><code>$ python --version
  Python 2.7.12
  </code></pre>
  
  <h3>Some environment variables</h3>
  
  <pre><code>PYTHON       /usr/bin/python2.7
  ARCH         x86_64
  OS           Linux
  VERSION      4.4.071generic
  PLATFORM     linux2
  HOSTNAME     deploy
  USER         myUser
  WUSS_BUILD   NO
  CCVER        gcc
  PYLIBDIR     build.x86_64-linux2
  LIBDIR       build.x86_64-linux2
  BINDIR       build.x86_64-linux2
  ODIR         build.x86_64-linux2-gcc
  STATICLIBDIR build-static.x86_64-linux2
  </code></pre>
  
  <h3>Error</h3>
  
  <p>The <code>make</code> command leads to</p>
  
  <pre><code>+++ Compile mycore/boost_json.cc to build.x86_64-linux2-gcc
  g++: internal compiler error: Segmentation fault (program cc1plus)   &lt;===
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See &lt;file:///usr/share/doc/gcc-5/README.Bugs&gt; for instructions.
  mk/makelib2.inc:48: recipe for target 'build.x86_64-linux2-gcc/mycore/boost_json.o' failed
  make[1]: *** [build.x86_64-linux2-gcc/mycore/boost_json.o] Error 4
  Makefile:152: recipe for target 'make.stage1c' failed
  make: *** [make.stage1c] Error 2
  </code></pre>
  
  <p>The error message seems to be pointing at a <code>g++</code> compiler error (?)</p>
  
  <p><code>makelib2.inc:48</code></p>
  
  <pre><code>$(ODIR)/%.o : %.c
          @mkdir -p $(dir $@)
          @echo "+++ Compile $&lt; to $(ODIR)"
          @$(CC) -MMD -MP -MF $(@:.o=.d) -c -I$(ODIR) $(CFLAGS) $(CFLAGS_$*) -o $@ $&lt;
  </code></pre>
  
  <p>I realize that this is going to be very difficult to craft a proper question that would lead to getting proper help. So please bear with me and feel free to suggest adding anything that may help. Unfortunately, I can't share the code.</p>
  
  <h1>Update</h1>
  
  <p>Going to try upgrade <code>g++</code> to a more recent version. Following <a href="https://askubuntu.com/questions/618474/how-to-install-the-latest-gcurrently-5-1-in-ubuntucurrently-14-04">this thread</a></p>
  
  <p><a href="https://askubuntu.com/questions/863517/how-do-i-install-g-7-on-ubuntu">HERE how to install <strong>g++ 7</strong> on Ubuntu</a></p>
  
  <p><a href="https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91" rel="noreferrer">HERE how to install <strong>gcc 6</strong> on Ubuntu</a></p>