Add the warning flag to the C/C++ compiler invocation #11535
+73
−54
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.
See Sets of warnings for foreign stubs #8597.
There are some preliminary commits around naming in the C/C++ compiler handling code, to align the terminology with the upstream OCaml compiler, then a few fixes, then the gist of it.
I add
-Wall
to the C/C++ compiler invocation if GCC/clang are detected, and-W2
if MSVC or clang-cl are detected. This should help C/C++ OCaml FFI writers to set warnings on by default, which they tend to forget, and that's a huge mistake. It is hard to add the right set of warnings in Dune files, see below. If they simply add-Wall
, they forget about MSVC and clang-cl. Users usually don't know or don't care about these toolchains. Bugs, typos, anything can creep up. Some packages use a discover script with dune-configurator. This is another possible way of forgetting warnings. I believe we should help users catching problems early on by turning on the C/C++ warnings for them.Note that as long as we don't set the warning as error flag (
-Werror
on cc or-WX
for msvc), compilation can't fail. No workflow should be broken, the user will just see new warnings reported by the compiler. Users should still be able to disable these flags with:standard \ -Wall
.This PR is best reviewed commit by commit.
cc @voodoos @rgrinberg @nojb