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
Merged

Using Werror-all for Intel #2948

merged 14 commits into from Apr 14, 2021

Conversation

philbucher
Copy link
Contributor

@philbucher philbucher commented Apr 13, 2021

Description

For turning compiler warnings into errors with Intel I think it is necessary to use Werror-all instead of Werror
Source

EDIT Werror exists too, but Werror-all is more strict

I think there will be some minor things to be fixed, at least I had to do this in my project.
Lets see if the CI picks it up :)

Suggested changelog entry:

Changed ``Werror`` to stricter ``Werror-all`` for Intel compiler and fixed minor issues

@philbucher
Copy link
Contributor Author

ok the CI found the same issues I had in my code:

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_cross_module_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(147): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic push
                           ^

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(147): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic push
                           ^

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_cross_module_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(148): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic ignored "-Wplacement-new"
                           ^

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_cross_module_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(152): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic pop
                           ^

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(148): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic ignored "-Wplacement-new"
                           ^

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(152): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic pop
                           ^

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_cross_module_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(2287): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic pop
                           ^

In file included from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.h(2),
                 from /home/runner/work/pybind11/pybind11/tests/pybind11_tests.cpp(10):
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(2287): error #2282: unrecognized GCC pragma
  #  pragma GCC diagnostic pop
                           ^

my second commit should fix them

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

@henryiii
Copy link
Collaborator

Ignore the unrelated failure for Python 3.10, that's due to pytest-dev/pytest#8539

@philbucher
Copy link
Contributor Author

so now the ward issues are fixed, but there are two more warnings:

error #11074: Inlining inhibited by limit max-size 
error #11076: To get full report use -qopt-report=4 -qopt-report-phase ipo

I am not sure what to do about those. Maybe there are some limits or inlining specified? => see here

@philbucher philbucher changed the title correcting Werror for Intel Using Werror-all for Intel Apr 13, 2021
@henryiii
Copy link
Collaborator

I think we set something similar for the NVHPC (PGI) compiler, which I think shares some history with Intel (IIRC). -no-inline-max-size might force it? Though from what I can tell, it uses default heuristics, and that probably causes a few requested inlines to not happen (and hence, the warning becoming an error above). Maybe we can find the size with -qopt-report=4 -qopt-report-phase ipo and then set it a little larger than that with -max-size?

@rwgk rwgk self-requested a review April 14, 2021 00:00
@rwgk
Copy link
Collaborator

rwgk commented Apr 14, 2021

EDIT 4/14: I was wrong before (below), I overlooked that this PR does not affect the pragma block.

Note to myself: the smart_holder branch will need to be updated accordingly.

For the smart_holder branch I had to move the pragma block in pybind11.h (#2873), which wasn't supported by anyone unfortunately.

@philbucher
Copy link
Contributor Author

I think we set something similar for the NVHPC (PGI) compiler, which I think shares some history with Intel (IIRC). -no-inline-max-size might force it? Though from what I can tell, it uses default heuristics, and that probably causes a few requested inlines to not happen (and hence, the warning becoming an error above). Maybe we can find the size with -qopt-report=4 -qopt-report-phase ipo and then set it a little larger than that with -max-size?

this is what I get when enabling the report:

INLINING OPTION VALUES:
  -inline-factor: 100
  -inline-min-size: 30
  -inline-max-size: 230
  -inline-max-total-size: 2000
  -inline-max-per-routine: disabled
  -inline-max-per-compile: disabled

I then thought it would probably be better to disable the warnings for the following reasons:

  • The log is very large (~500K lines). Parsing it to find the max numbers is possible but I think it is dangerous if in the future the size increases further then suddenly the intel build will fail for a seemingly unrelated change
  • I also thought of removing the limits completely but this is
    • a behavior change
    • can lead to large memory consumption (which I already fought with quite a lot with GitHub Actions)
  • the limits for inlining are already used, but they werent noticed as the compiler didn't issue the warning

Bottom line now I disabled them, which I think is the best solution

Thx for your help, please let me know what you think

@philbucher
Copy link
Contributor Author

cool now the CI passes (except the build you said doesn't work)

Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

Looks good to me.

include/pybind11/pybind11.h Outdated Show resolved Hide resolved
tests/CMakeLists.txt Outdated Show resolved Hide resolved
philbucher and others added 2 commits April 14, 2021 16:37
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
@philbucher
Copy link
Contributor Author

thanks for the fast responses and help!

@henryiii henryiii merged commit 62976cf into pybind:master Apr 14, 2021
@henryiii
Copy link
Collaborator

Thanks!

@henryiii henryiii added bug compiler issue compiler: intel Related to the Intel compilers labels Apr 14, 2021
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Apr 14, 2021
@philbucher philbucher deleted the patch-1 branch April 14, 2021 18:23
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compiler: intel Related to the Intel compilers compiler issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants