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

Using Werror-all for Intel #2948

Merged
merged 14 commits into from Apr 14, 2021
6 changes: 3 additions & 3 deletions include/pybind11/pybind11.h
Expand Up @@ -143,12 +143,12 @@ class cpp_function : public function {
/* Without these pragmas, GCC warns that there might not be
enough space to use the placement new operator. However, the
'if' statement above ensures that this is the case. */
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6 && !defined(__INTEL_COMPILER)
philbucher marked this conversation as resolved.
Show resolved Hide resolved
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wplacement-new"
#endif
new ((capture *) &rec->data) capture { std::forward<Func>(f) };
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 6 && !defined(__INTEL_COMPILER)
# pragma GCC diagnostic pop
#endif
if (!std::is_trivially_destructible<Func>::value)
Expand Down Expand Up @@ -2283,6 +2283,6 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
# pragma warning(pop)
#elif defined(__GNUG__) && !defined(__clang__)
#elif defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma GCC diagnostic pop
#endif
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Expand Up @@ -268,8 +268,10 @@ function(pybind11_enable_warnings target_name)
target_compile_options(${target_name} PRIVATE /WX)
elseif(PYBIND11_CUDA_TESTS)
target_compile_options(${target_name} PRIVATE "SHELL:-Werror all-warnings")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
philbucher marked this conversation as resolved.
Show resolved Hide resolved
target_compile_options(${target_name} PRIVATE -Werror)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true for both Intel compilers? (IntelLLVM and classic Intel; both will match here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for the fast reply

No clue tbh. This is the first time I learned about IntelLLVM. I took a brief look at their docs but couldn't find it

Are you sure it would match both? According to CMake the CMAKE_CXX_COMPILER_ID for IntelLLVM is IntelLLVM

also checking the docs more in detail I noticed that Werror does exist, but it is not as strict as Werror-all. Maybe Werror-all is too strict? What do you think

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MATCH will find the word anywhere; Clang and AppleClang MATCH. So IntelLLVM will MATCH Intel. (I guess they chose LLVM to avoid MATCHing with Clang, as IntelClang would have matched, and due to the AppleClang compiler, that's a very common expression in CMakeLists.

The Clang-based Intel compiler is the "new" compiler, and the one they are supporting going forward. The old compiler is now renamed "Classic Intel" (as you can see in the docs), and is being killed off.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new compiler is called "Intel® oneAPI DPC++/C++ Compiler", the old one "Intel® C++ Compiler Classic", as you can see here: https://software.intel.com/content/www/us/en/develop/tools/oneapi/all-toolkits.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for the explanation.
I used STREQUAL now, please let me know if it is ok

target_compile_options(${target_name} PRIVATE -Werror-all)
endif()
endif()

Expand Down
8 changes: 4 additions & 4 deletions tests/test_constants_and_functions.cpp
Expand Up @@ -56,12 +56,12 @@ int f1(int x) noexcept { return x+1; }
#endif
int f2(int x) noexcept(true) { return x+2; }
int f3(int x) noexcept(false) { return x+3; }
#if defined(__GNUG__)
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated"
#endif
int f4(int x) throw() { return x+4; } // Deprecated equivalent to noexcept(true)
#if defined(__GNUG__)
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
# pragma GCC diagnostic pop
#endif
struct C {
Expand All @@ -71,13 +71,13 @@ struct C {
int m4(int x) const noexcept(true) { return x-4; }
int m5(int x) noexcept(false) { return x-5; }
int m6(int x) const noexcept(false) { return x-6; }
#if defined(__GNUG__)
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated"
#endif
int m7(int x) throw() { return x-7; }
int m8(int x) const throw() { return x-8; }
#if defined(__GNUG__)
#if defined(__GNUG__) && !defined(__INTEL_COMPILER)
# pragma GCC diagnostic pop
#endif
};
Expand Down
4 changes: 2 additions & 2 deletions tests/test_operator_overloading.cpp
Expand Up @@ -80,8 +80,8 @@ std::string abs(const Vector2&) {
return "abs(Vector2)";
}

// MSVC warns about unknown pragmas, and warnings are errors.
#ifndef _MSC_VER
// MSVC & Intel warns about unknown pragmas, and warnings are errors.
#if !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#pragma GCC diagnostic push
// clang 7.0.0 and Apple LLVM 10.0.1 introduce `-Wself-assign-overloaded` to
// `-Wall`, which is used here for overloading (e.g. `py::self += py::self `).
Expand Down