Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `google::protobuf::internal::Release_CompareAndSwap #3937

Closed
Nayana-ibm opened this issue Nov 22, 2017 · 2 comments
Closed

Comments

@Nayana-ibm
Copy link
Contributor

While compiling protobuf v3.5.0 on big endian, facing an issue
undefined reference to google::protobuf::internal::Release_CompareAndSwap(long volatile*, long, long)'`

Need to add 64-bit version to protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h

Similar issue was raised to add 64-bit versions: #1044

@Nayana-ibm Nayana-ibm changed the title undefined reference to `google::protobuf::internal::Release_CompareAndSwap(long volatile*, long, long)' undefined reference to `google::protobuf::internal::Release_CompareAndSwap Nov 22, 2017
@xfxyjwf
Copy link
Contributor

xfxyjwf commented Nov 22, 2017

Thanks for the report. Feel free to send us a pull request if you know of a working fix.

@Nayana-ibm
Copy link
Contributor Author

Requires below patch in file protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h


--- a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
@@ -146,6 +146,15 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
   return __atomic_load_n(ptr, __ATOMIC_RELAXED);
 }

+inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
+                                       Atomic64 old_value,
+                                       Atomic64 new_value) {
+  __atomic_compare_exchange_n(ptr, &old_value, new_value, false,
+                              __ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
+  return old_value;
+}
+
+
 #endif // defined(__LP64__)


 }  // namespace internal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants