From 8ea3bb17cbf7f19922f5d0443b8dd9080c596ea1 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Fri, 30 Aug 2024 10:37:00 -0700 Subject: [PATCH] Fix compiler error with `StrongReferenceToType()` For some reason, Clang 19 appears to raise an error in some situations unless we explicitly inline the implementation of `StrongPointer()` here. PiperOrigin-RevId: 669373421 --- src/google/protobuf/port.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/port.h b/src/google/protobuf/port.h index 27f19d43a862..182f5786fb79 100644 --- a/src/google/protobuf/port.h +++ b/src/google/protobuf/port.h @@ -64,7 +64,10 @@ inline PROTOBUF_ALWAYS_INLINE void StrongPointer() { template inline PROTOBUF_ALWAYS_INLINE void StrongReferenceToType() { static constexpr auto ptr = T::template GetStrongPointerForType(); - return StrongPointer(); + // This is identical to the implementation of StrongPointer() above, but it + // has to be explicitly inlined here or else Clang 19 will raise an error in + // some configurations. + asm(".reloc ., BFD_RELOC_NONE, %p0" ::"Ws"(ptr)); } #else // .reloc // Portable fallback. It usually generates a single LEA instruction or