Skip to content

Commit 9635cb6

Browse files
committed
Restoring ICC pragma 2196, introducing PYBIND11_NOINLINE_FORCED, defined for testing.
1 parent 2c9daea commit 9635cb6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

include/pybind11/detail/common.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
# elif __INTEL_COMPILER < 1900 && defined(PYBIND11_CPP14)
5757
# error pybind11 supports only C++11 with Intel C++ compiler v18. Use v19 or newer for C++14.
5858
# endif
59+
/* The following pragma cannot be pop'ed:
60+
https://community.intel.com/t5/Intel-C-Compiler/Inline-and-no-inline-warning/td-p/1216764 */
61+
# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
5962
#elif defined(__clang__) && !defined(__apple_build_version__)
6063
# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 3)
6164
# error pybind11 requires clang 3.3 or newer
@@ -96,6 +99,17 @@
9699
# endif
97100
#endif
98101

102+
// For CUDA, GCC7, GCC8 (and maybe some other platforms):
103+
// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
104+
// When defining PYBIND11_NOINLINE_FORCED, it is best to also use
105+
// `-Wno-attributes` (or not to use `-Werror` and ignore the warnings).
106+
#define PYBIND11_NOINLINE_FORCED
107+
#if !defined(PYBIND11_NOINLINE_FORCED) && \
108+
(defined(__CUDACC__) || \
109+
(defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
110+
# define PYBIND11_NOINLINE_DISABLED
111+
#endif
112+
99113
#if defined(PYBIND11_NOINLINE_DISABLED)
100114
# define PYBIND11_NOINLINE_DCL inline
101115
# define PYBIND11_NOINLINE_FWD inline
@@ -110,6 +124,11 @@
110124
# define PYBIND11_NOINLINE_FWD
111125
#endif
112126

127+
// DECISION TO BE MADE before this PR is merged:
128+
// ----------------------------------------------------------------------------
129+
// This code and the 9 x 2 pragma blocks referring to
130+
// PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED could be purged.
131+
// ----------------------------------------------------------------------------
113132
#if !defined(PYBIND11_NOINLINE_GCC_PRAGMA_ATTRIBUTES_NEEDED) && \
114133
!defined(PYBIND11_NOINLINE_DISABLED) && \
115134
(defined(__CUDACC__) || \

0 commit comments

Comments
 (0)