Fix #4829 (build does not respect --with-gcc option)