I don't know how, but it must be possible as this is how three-stage bootstraps of GCC are done. Your native compiler compiles a temporary GCC (xgcc), then xgcc compiles a proper GCC, then that GCC compiles a third GCC. The second and third GCC's are then binary diffed to determine whether some compiler along the way was faulty.

Good luck in finding, in the labyrinthine GCC build system, exactly how this is done.

Peter