Support for march=native and mtune=native combined with distcc or icecream
When using distcc or icecream, you cannot pass the flag -march=native
because that will generate code for whichever host happens to be compiling the file. It would be nice if there were some way to explicitly say "I want -march=native", and have CMake figure out the equivalent flags to pass when using a distributed build tool.
For instance, this StackOverflow answer suggests this command to get the flags from gcc: g++ -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'
, which outputs -march=nehalem -mmmx -msse -msse2 -msse3 -mssse3 -msahf -msse4.2 -msse4.1 -mfxsr --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=nehalem
on one of my systems.
However, that answer is gcc specific. It doesn't quite parse the flags when using clang, and I have no idea what happens with icc.
It would be very helpful if CMake could do this parsing once at configuration time and then pass those equivalent flags to my distributed compiler.