This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined.
ClosedPublic

Authored by AlexM on Jun 27 2023, 12:40 PM.

Details

Summary

Disable this warning for specific cast in llvm_regcomp().

Diff Detail

Event Timeline

AlexM created this revision.Jun 27 2023, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2023, 12:40 PM
AlexM retitled this revision from [CMAKE] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined. to [cmake] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined..Jun 27 2023, 5:09 PM
AlexM added reviewers: dblaikie, nikic, MaskRay, rnk.
AlexM published this revision for review.Jun 27 2023, 5:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2023, 5:11 PM
dblaikie accepted this revision.Jun 28 2023, 12:20 PM

Sounds good to me

llvm/cmake/modules/HandleLLVMOptions.cmake
744

looks like in other cases C_FLAGS comes before CXX_FLAGS - maybe switch this around for consistency?

This revision is now accepted and ready to land.Jun 28 2023, 12:20 PM
AlexM updated this revision to Diff 535533.Jun 28 2023, 2:18 PM

switch C_FLAGS and CXX_FLAGS

AlexM marked an inline comment as done.Jun 28 2023, 2:20 PM

Fixed. @dblaikie could you please commit this on my behalf?

This revision was landed with ongoing or failed builds.Jul 18 2023, 4:45 PM
This revision was automatically updated to reflect the committed changes.

@AlexM @dblaikie Could you take care of c-index-test.c?

@AlexM @dblaikie Could you take care of c-index-test.c?

I saw the warning as well. See D155670 :)

Another fix for libunwind 32 bit builds: https://reviews.llvm.org/D155685

hctim added a subscriber: hctim.Jul 19 2023, 3:18 AM

Hi, we're still seeing sanitizer buildbot failures from what I assume is this patch.

https://lab.llvm.org/buildbot/#/builders/37/builds/23724

/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/profile/InstrProfilingValue.c:62:17: error: cast from 'const unsigned short *' to 'unsigned short *' drops const qualifier [-Werror,-Wcast-qual]
   62 |   *((uint16_t *)&Data->NumValueSites[ValueKind]) = NumValueSites;

Maybe it's worth reverting, doing the cleanup, and then re-submitting rather than trying to fix-forward? It would appear if there's a lot of cleanup required.

AlexM added a comment.Jul 19 2023, 8:45 AM

Hi, we're still seeing sanitizer buildbot failures from what I assume is this patch.

https://lab.llvm.org/buildbot/#/builders/37/builds/23724

/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/profile/InstrProfilingValue.c:62:17: error: cast from 'const unsigned short *' to 'unsigned short *' drops const qualifier [-Werror,-Wcast-qual]
   62 |   *((uint16_t *)&Data->NumValueSites[ValueKind]) = NumValueSites;

Maybe it's worth reverting, doing the cleanup, and then re-submitting rather than trying to fix-forward? It would appear if there's a lot of cleanup required.

I do not have commit access, but I think reverting this makes sense if it is causing build failures. Sorry for the inconvenience!

Hi, we're still seeing sanitizer buildbot failures from what I assume is this patch.

https://lab.llvm.org/buildbot/#/builders/37/builds/23724

/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/profile/InstrProfilingValue.c:62:17: error: cast from 'const unsigned short *' to 'unsigned short *' drops const qualifier [-Werror,-Wcast-qual]
   62 |   *((uint16_t *)&Data->NumValueSites[ValueKind]) = NumValueSites;

Maybe it's worth reverting, doing the cleanup, and then re-submitting rather than trying to fix-forward? It would appear if there's a lot of cleanup required.

I do not have commit access, but I think reverting this makes sense if it is causing build failures. Sorry for the inconvenience!

compiler-rt/lib/profile has been fixed by commit 51c8cacafd47b59e66816b10be357a9877187bc3.

RKSimon added inline comments.
llvm/lib/Support/regcomp.c
337

@AlexM We're still seeing Wcast-qual warnings on clang-cl builds - please can you take a look?