Clean up repeated field shared library exports.

This removes the built in "extern template" declarations because they continue to cause issues in shared library builds.  Users who need this optimization can define it themselves.  This also adds PROTOBUF_EXPORT to some symbols that were previously missing it.

PiperOrigin-RevId: 500223387
diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc
index 3f20db1..de3a982 100644
--- a/src/google/protobuf/repeated_field.cc
+++ b/src/google/protobuf/repeated_field.cc
@@ -107,25 +107,6 @@
   }
 }
 
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<bool>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<int32_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<uint32_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<int64_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<uint64_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<float>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<double>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<absl::Cord>;
-
-namespace internal {
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<bool>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<int32_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<uint32_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<int64_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<uint64_t>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<float>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<double>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<absl::Cord>;
-}  // namespace internal
 
 }  // namespace protobuf
 }  // namespace google
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index 8e6295e..f765a0c 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -1032,36 +1032,40 @@
 // some specializations for them.  Some definitions are in the .cc file.
 
 template <>
-inline void RepeatedField<absl::Cord>::RemoveLast() {
+PROTOBUF_EXPORT inline void RepeatedField<absl::Cord>::RemoveLast() {
   GOOGLE_ABSL_DCHECK_GT(current_size_, 0);
   Mutable(size() - 1)->Clear();
   ExchangeCurrentSize(current_size_ - 1);
 }
 
 template <>
-void RepeatedField<absl::Cord>::Clear();
+PROTOBUF_EXPORT void RepeatedField<absl::Cord>::Clear();
 
 template <>
-inline void RepeatedField<absl::Cord>::SwapElements(int index1, int index2) {
+PROTOBUF_EXPORT inline void RepeatedField<absl::Cord>::SwapElements(
+    int index1, int index2) {
   Mutable(index1)->swap(*Mutable(index2));
 }
 
 template <>
-size_t RepeatedField<absl::Cord>::SpaceUsedExcludingSelfLong() const;
+PROTOBUF_EXPORT size_t
+RepeatedField<absl::Cord>::SpaceUsedExcludingSelfLong() const;
 
 template <>
-void RepeatedField<absl::Cord>::Truncate(int new_size);
+PROTOBUF_EXPORT void RepeatedField<absl::Cord>::Truncate(int new_size);
 
 template <>
-void RepeatedField<absl::Cord>::Resize(int new_size, const absl::Cord& value);
+PROTOBUF_EXPORT void RepeatedField<absl::Cord>::Resize(int new_size,
+                                                       const absl::Cord& value);
 
 template <>
-void RepeatedField<absl::Cord>::MoveArray(absl::Cord* to, absl::Cord* from,
-                                          int size);
+PROTOBUF_EXPORT void RepeatedField<absl::Cord>::MoveArray(absl::Cord* to,
+                                                          absl::Cord* from,
+                                                          int size);
 
 template <>
-void RepeatedField<absl::Cord>::CopyArray(absl::Cord* to,
-                                          const absl::Cord* from, int size);
+PROTOBUF_EXPORT void RepeatedField<absl::Cord>::CopyArray(
+    absl::Cord* to, const absl::Cord* from, int size);
 
 // -------------------------------------------------------------------
 
@@ -1236,32 +1240,6 @@
   return internal::RepeatedFieldBackInsertIterator<T>(mutable_field);
 }
 
-// Extern declarations of common instantiations to reduce library bloat.
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<bool>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int32_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint32_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int64_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint64_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<float>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<double>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
-    RepeatedField<absl::Cord>;
-
-namespace internal {
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<bool>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
-    RepeatedIterator<int32_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
-    RepeatedIterator<uint32_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
-    RepeatedIterator<int64_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
-    RepeatedIterator<uint64_t>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<float>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<double>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
-    RepeatedIterator<absl::Cord>;
-}  // namespace internal
 
 }  // namespace protobuf
 }  // namespace google