Fix enum math in verbs.h for CUDA C++20 upgrade via reversions and casts#2147
Closed
r-barnes wants to merge 1 commit intometa-pytorch:mainfrom
Closed
Fix enum math in verbs.h for CUDA C++20 upgrade via reversions and casts#2147r-barnes wants to merge 1 commit intometa-pytorch:mainfrom
r-barnes wants to merge 1 commit intometa-pytorch:mainfrom
Conversation
Summary:
Generated by running
```
hg backout D88882181
hg backout D89083275
hg backout D88911049
```
and then adding explicit casts.
`infiniband/verbs.h` caused C++20 compilation failures due to enum-enum math which could not simply be suppressed because it's a header file.
D88882181 converted `enum` to constants to allow the math to work and because the enums themselves seemed suspect. This caused compilation to succeed with C++20 and unblock a number of broken tests.
But it broke Rust! D89083275 and D88911049 fix Rust by artificially restoring the `enum` values. But that's a mess.
Here we back out both D88882181 and D89083275 and D88911049. Doing so brings us back to a state where the following compilation error would arise:
```
buck-out/v2/gen/fbsource/third-party/rdma-core/stablev60/__ibverbs__/c01e142197f8fe04/buck-headers/infiniband/verbs.h:573:59: error: bitwise operation between different enumeration types ('(unnamed enum at buck-out/v2/gen/fbsource/third-party/rdma-core/stablev60/__ibverbs__/c01e142197f8fe04/buck-headers/infiniband/verbs.h:562:1)' and 'ibv_create_cq_wc_flags') is deprecated [-Werror,-Wdeprecated-anon-enum-enum-conversion]
573 | IBV_CREATE_CQ_SUP_WC_FLAGS = ((((((IBV_WC_STANDARD_FLAGS) | (IBV_WC_EX_WITH_COMPLETION_TIMESTAMP)) | (IBV_WC_EX_WITH_CVLAN)) | (IBV_WC_EX_WITH_FLOW_TAG)) | (IBV_WC_EX_WITH_TM_INFO)) | (IBV_WC_EX_WITH_COMPLETION_TIMESTAMP_WALLCLOCK))
| ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
This time we fix the error by adding explicit `(int)` casts to the affected Line 573.
The result is code that:
* Compiles with C++20 by explicitly suppressing the issue causing the compilation failure
* Retains the enums so that builds with Rust work.
Upstream PR: linux-rdma/rdma-core#1671
See discussion [here](https://fb.workplace.com/groups/rust.language/permalink/30268407786114448/).
Reviewed By: peterdelevoryas
Differential Revision: D89088011
|
This pull request has been merged in 8c0401b. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Generated by running
and then adding explicit casts.
infiniband/verbs.hcaused C++20 compilation failures due to enum-enum math which could not simply be suppressed because it's a header file.D88882181 converted
enumto constants to allow the math to work and because the enums themselves seemed suspect. This caused compilation to succeed with C++20 and unblock a number of broken tests.But it broke Rust! D89083275 and D88911049 fix Rust by artificially restoring the
enumvalues. But that's a mess.Here we back out both D88882181 and D89083275 and D88911049. Doing so brings us back to a state where the following compilation error would arise:
This time we fix the error by adding explicit
(int)casts to the affected Line 573.The result is code that:
Upstream PR: linux-rdma/rdma-core#1671
See discussion here.
Reviewed By: peterdelevoryas
Differential Revision: D89088011