bpf: Avoid implicit shorten-64-to-32 in clang 19#36186
Conversation
2a8187a to
8d9faf7
Compare
|
/test |
|
I'll do a more careful review of the converted places later, but first a question (trying to gather the context): since we aren't on LLVM 19 yet, are you testing it by just adding |
In clang 19, -Wshorten-64-to32 is enabled as part of -Wimplicit-int-conversion, so my local clang 19 complication just failed. This is mainly to fix my local dev, however, I am keen to work on llvm upgrade in near future as well. PS: I saw that you have the clang 18 upgrade merged in image-tools 🎖️ |
|
Thanks for the clarification! Let's coordinate our work on LLVM upgrades, so that it doesn't clash. I have a tracking issue here #32801 with the checklist of everything that needs to be done for the complete upgrade. It will be converted into an issue template in the future. As you said, the 18.1.8 upgrade has been merged to image-tools, but that's merely the first step, and I'll proceed with the other steps (i.e. do the actual switch to the new version and fix any new errors) when I have more cycles. That means, Cilium is still on LLVM 17 right now (previously, there was an attempt for 18.1.6, which was reverted due to waiting too long for another issue that blocked kernel upgrades in the CI.) So, my plan was to proceed with the upgrade to 18.1.8, and once it's done start the new iteration for the latest stable version at that moment. If you are planning to jump to 19 faster, you can go ahead, but I suggest using the same issue template and the same process for convenience and coordination. And, of course, you can merge fixes for future LLVM versions at any time — the checklist is for the upgrade itself ;) |
|
Thanks to your awesome work, the main branch is with llvm 18 now (#36197). I think we can slowly proceed with fixes for future LLVM versions now. |
8d9faf7 to
ebcb886
Compare
|
/test |
ldelossa
left a comment
There was a problem hiding this comment.
Running into this with latest Fedora builds.
I tested building and running this commit. Looks good to me.
ebcb886 to
eab2b77
Compare
As per the below PR, clang 19.1.x is having -Wshorten-64-to32 under the -Wimplicit-int-conversion, which is already forbidden in Makefile.bpf. This commit is to avoid the conversion error as per below sample ``` ./lib/nodeport.h:1825:18: error: implicit conversion loses integer precision: '__u64' (aka 'unsigned long long') to '__s32' (aka 'int') [-Werror,-Wshorten-64-to-32] 1825 | __s32 len_old = ctx_full_len(ctx); ``` Relates: llvm/llvm-project#80814 Signed-off-by: Tam Mach <[email protected]>
eab2b77 to
6cea350
Compare
|
/test |
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
```
bpf_nat_tests.c:1141:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1141 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_tcp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bpf_nat_tests.c:1272:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1272 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_udp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Relates: #36186
Signed-off-by: Tam Mach <[email protected]>
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
```
bpf_nat_tests.c:1141:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1141 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_tcp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bpf_nat_tests.c:1272:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1272 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_udp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Relates: #36186
Signed-off-by: Tam Mach <[email protected]>
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
```
bpf_nat_tests.c:1141:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1141 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_tcp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bpf_nat_tests.c:1272:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1272 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_udp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Relates: #36186
Signed-off-by: Tam Mach <[email protected]>
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
```
bpf_nat_tests.c:1141:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1141 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_tcp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bpf_nat_tests.c:1272:10: error: implicit conversion loses integer precision: 'long' to '__u32' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
1272 | iters = loop(SNAT_TEST_ITERATIONS, snat_callback_udp, &cb_ctx, 0);
| ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Relates: #36186
Signed-off-by: Tam Mach <[email protected]>
Relates: #36186 Signed-off-by: Tam Mach <[email protected]>
As per the below PR, clang 19.1.x is having -Wshorten-64-to32 under the -Wimplicit-int-conversion, which is already forbidden in Makefile.bpf. This commit is to avoid the conversion error as per below sample
Relates: llvm/llvm-project#80814
Fixes: #35162 35162