On Thu, Apr 28, 2016 at 2:21 PM, Burlen Loring <burlen.lor...@gmail.com> wrote: > Hi Guys, > > I'd like to discuss changing the defaults of CMAKE_C/CXX_FLAGS_RELEASE on > gcc, and potentially gcc like compilers such as clang and intel. > > Currently the default is "-O3 -DNDEBUG". I would like to discuss changing > this to "-O3 -march=native -mtune=native -DNDEBUG". This change will enable > numerous optimizations and produce faster code targeted for the cpu in use > during the compilation. > As someone who was bitten by a project enabling -march=native in their CMake-based build system, and the days of debugging as this was a nested dependency built in a superbuild to create a package I hope we never make that a default.
As a former Gentoo developer who has seen that -O3 is often not the best default flag for optimized builds I would actually suggest changing the default to "-O2 -DNDEBUG". The binaries are normally smaller, compile times faster, and the resulting code faster. Quoting from the wiki (https://wiki.gentoo.org/wiki/GCC_optimization): '-O3: the highest level of optimization possible. It enables optimizations that are expensive in terms of compile time and memory usage. Compiling with -O3 is not a guaranteed way to improve performance, and in fact, in many cases, can slow down a system due to larger binaries and increased memory usage. -O3 is also known to break several packages. Using -O3 is not recommended.' I think adding a RelWithNative or RelAgressiveOpt might be an option, but there are a number of things like distcc that makes applying -march=native undesirable. For those that know what they are doing certainly, but there are side effects and debugging can be tricky for the poor packagers too (who often have limited resources, and do not expect this). My $0.03 cents as someone who may have lost a little hair over this ;-) Marcus -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake