We have some internal compiler options which can help with this. If you could provide me with the test case, I can help figuring out the issue.
Thanks and Regards
I don't have a simple test case that demonstrates the behavior. The code is foam extend 3.2 built against the SGI MPT mpi library. If you have access to such a system I can tell you how to reproduce it, but I don't have a concise listing to reproduce.
Option 1: You can try disabling vectorization using -no-vec with O2 optimization and see if this works.
Option 2: Try disabling Interprocedural optimization (IPO) and also try -fno-inline -no-ip.
Another option is to narrow down the file which is responsible by building part of the project with O1 but the rest with O2. Narrowing down the file and sharing that with us might help us understand things better. Let me know if you find anything from the above experiments.
Thanks and Regards
Indeed, using -O3 -no-vec works without error. I am going to try putting -O3 back to reproduce and then do ulimit -s unlimited to see if it is stack overflow. Unfortunately each experiment takes a lot of time. I have whittled down the number of files that get recompiled but it's still at 20 minutes per build. I will continue trying to get that down.
Edit: looking at ulimit -a does not give me a sense that unlimiting the stack size will help, but we will see.
-bash-4.1$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 127688
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 16384
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 127688
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
I guess it's not stack overflow if the error persists with ulimit -s unlimited. So -O2 or -O3 fails, -O1 passes. -O2 -no-vec and -O3 -no-vec work. I'm hoping allinea ddt can get me closer to the source of the error, but I'll take suggestions in the meantime.