summaryrefslogtreecommitdiff
path: root/sci-libs/caffe2/files/caffe2-1.12.0-clang.patch
blob: dd43b06a97a1968de9a2f6fb0bb8463fbcc157a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From bfdc0358dc37c55af6118fe5d8b6ccd898e003fd Mon Sep 17 00:00:00 2001
From: Kazuki Sakamoto <kaz@meta.com>
Date: Wed, 21 Dec 2022 11:19:58 +0000
Subject: [PATCH] Compile fix for Clang + libc++ (#91212)

Summary:
LLVM 15 has a compile issue with the deprecated __has_trivial_copy. Update the GCC ifdef logic to exclude Clang + libc++.

```
caffe2/c10/util/Optional.h:536:13: error: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Werror,-Wdeprecated-builtins]
            C10_IS_TRIVIALLY_COPYABLE(T) &&
            ^
caffe2/c10/macros/Macros.h:438:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
#define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
```

Test Plan: CI

Reviewed By: kit1980

Differential Revision: D42180203

Pull Request resolved: https://github.com/pytorch/pytorch/pull/91212
Approved by: https://github.com/kit1980, https://github.com/soumith
---
 c10/macros/Macros.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/c10/macros/Macros.h b/c10/macros/Macros.h
index 9098a294228f4..09e57ca0a4d6a 100644
--- a/c10/macros/Macros.h
+++ b/c10/macros/Macros.h
@@ -434,7 +434,8 @@ __device__ __attribute__((noinline)) __attribute__((weak)) void __assert_fail(
 // Warning: __has_trivial_copy for GCC may not always detect the non-POD
 // correctly. For example, T = std::unique_ptr may evaluate to true and be
 // treated as POD. This can cause unexpected behavior.
-#if defined(__GNUG__) && __GNUC__ < 5
+#if defined(__GNUG__) && __GNUC__ < 5 && \
+    !(defined(__clang__) && defined(_LIBCPP_VERSION))
 #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
 #else
 #define C10_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value