osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

MinGW Compiler Optimizations Break osgEarthAnnotation

Open ghost opened this issue 4 years ago • 1 comments

System info: mingw-w64-i686 (dw2) (provided by MSYS2) Windows 10 1903

When using osgEarthAnnotation built with -O2 (this is the default for RelWithDebInfo) the annotations flicker and rotate like crazy. Every slight movement of the camera causes the annotations to rotate about their anchor points to a new (seemingly random) orientation every frame and it looks awful. On a hunch I rebuilt with the debug configuration (no compiler optimizations) and dropped in the new DLL and the problem was fixed.

This page describes the compiler optimizations present in GCC. These are the optimizations enabled by -O2

-fauto-inc-dec 
-fbranch-count-reg 
-fcombine-stack-adjustments 
-fcompare-elim 
-fcprop-registers 
-fdce 
-fdefer-pop 
-fdelayed-branch 
-fdse 
-fforward-propagate 
-fguess-branch-probability 
-fif-conversion 
-fif-conversion2 
-finline-functions-called-once 
-fipa-profile 
-fipa-pure-const 
-fipa-reference 
-fipa-reference-addressable 
-fmerge-constants 
-fmove-loop-invariants 
-fomit-frame-pointer 
-freorder-blocks 
-fshrink-wrap 
-fshrink-wrap-separate 
-fsplit-wide-types 
-fssa-backprop 
-fssa-phiopt 
-ftree-bit-ccp 
-ftree-ccp 
-ftree-ch 
-ftree-coalesce-vars 
-ftree-copy-prop 
-ftree-dce 
-ftree-dominator-opts 
-ftree-dse 
-ftree-forwprop 
-ftree-fre 
-ftree-phiprop 
-ftree-pta 
-ftree-scev-cprop 
-ftree-sink 
-ftree-slsr 
-ftree-sra 
-ftree-ter 
-funit-at-a-time
-falign-functions  -falign-jumps 
-falign-labels  -falign-loops 
-fcaller-saves 
-fcode-hoisting 
-fcrossjumping 
-fcse-follow-jumps  -fcse-skip-blocks 
-fdelete-null-pointer-checks 
-fdevirtualize  -fdevirtualize-speculatively 
-fexpensive-optimizations 
-ffinite-loops 
-fgcse  -fgcse-lm  
-fhoist-adjacent-loads 
-finline-functions 
-finline-small-functions 
-findirect-inlining 
-fipa-bit-cp  -fipa-cp  -fipa-icf 
-fipa-ra  -fipa-sra  -fipa-vrp 
-fisolate-erroneous-paths-dereference 
-flra-remat 
-foptimize-sibling-calls 
-foptimize-strlen 
-fpartial-inlining 
-fpeephole2 
-freorder-blocks-algorithm=stc 
-freorder-blocks-and-partition  -freorder-functions 
-frerun-cse-after-loop  
-fschedule-insns  -fschedule-insns2 
-fsched-interblock  -fsched-spec 
-fstore-merging 
-fstrict-aliasing 
-fthread-jumps 
-ftree-builtin-call-dce 
-ftree-pre 
-ftree-switch-conversion  -ftree-tail-merge 
-ftree-vrp

I have not been able to isolate the optimization which causes this problem. Curiously -ffast-math is not in the above list. This feels similar to a bug I encountered in the VS2017/2019 compiler in which shoddy floating-point code generation caused horrible visual artifacts in Qt. If someone could help me pinpoint the offending optimization flag it would be appreciated.

ajud

ghost avatar Nov 05 '19 03:11 ghost

One possibility is an uninitialized variable. In the VS Debug config these get auto-initialized, but I don't know about mingw.

gwaldron avatar Nov 05 '19 12:11 gwaldron