From ff610f5f0396fe8288c17c46eca845158f1879c4 Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Mon, 11 Aug 2025 14:56:02 -0700 Subject: [PATCH] Fix compilation with NVCC + Clang Compilation with nvcc + clang on linux hits an error trying to understand the builtin assembly within the byteswap header. When on device, NVCC won't have access to the linux assembly anyways, so it should use the fallback implementation. PiperOrigin-RevId: 793808521 --- src/google/protobuf/stubs/port.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 9e13a7ee478de..a5752416b9f2d 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -27,7 +27,8 @@ #include #elif defined(__APPLE__) #include -#elif defined(__linux__) || defined(__ANDROID__) || defined(__CYGWIN__) +#elif !defined(__NVCC__) && \ + (defined(__linux__) || defined(__ANDROID__) || defined(__CYGWIN__)) #include // IWYU pragma: export #endif @@ -126,7 +127,8 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64_t v) { #define bswap_32(x) OSSwapInt32(x) #define bswap_64(x) OSSwapInt64(x) -#elif !defined(__linux__) && !defined(__ANDROID__) && !defined(__CYGWIN__) +#elif defined(__NVCC__) || \ + (!defined(__linux__) && !defined(__ANDROID__) && !defined(__CYGWIN__)) #ifndef bswap_16 static inline uint16_t bswap_16(uint16_t x) {