diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index c5b20303bba9..060c2f65664f 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -2228,12 +2228,20 @@ bool CommandLineInterface::WriteDescriptorSet( } io::FileOutputStream out(fd); - if (!file_set.SerializeToZeroCopyStream(&out)) { - std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno()) - << std::endl; - out.Close(); - return false; + + { + io::CodedOutputStream coded_out(&out); + // Determinism is useful here because build outputs are sometimes checked + // into version control. + coded_out.SetSerializationDeterministic(true); + if (!file_set.SerializeToCodedStream(&coded_out)) { + std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno()) + << std::endl; + out.Close(); + return false; + } } + if (!out.Close()) { std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno()) << std::endl;