Dune decides whether to pass -fdiagnostics-color to the (GCC-style) C compiler or not depending on whether stderr is a terminal or not. This means that if one does dune build 2>/dev/null followed by dune build, the second command will rebuild all C stubs, which seems wrong.
One way to approach this may be to always make pass the -fdiagnostics-color flag to GCC, but filter out the ANSI codes in Dune, like it does in other cases (if I understand correctly).