Skip to content

Enable additional compiler warnings for CMake build #283

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

Merged
merged 1 commit into from
Jul 29, 2017

Conversation

dgrove-oss
Copy link
Contributor

  1. add a CMake module to define additional warning flags to enable
    when compiling dispatch.

  2. enable the additional warning flags by default for CMake

  3. match autotools behavior of not including the BSD_OVERLAY
    when compiling the dispatch_c99 test case. This avoids
    a warning about __printflike being redefined when compiling
    this test case with the expanded set of warning flags.

@dgrove-oss
Copy link
Contributor Author

@compnerd please comment if there are better ways to do this in CMake. Thanks

@@ -0,0 +1,85 @@

macro(dispatch_common_warnings)
Copy link
Member

Choose a reason for hiding this comment

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

This definitely is problematic. You break cross-compiling for Windows this way. You should check if the compiler flag is supported and if you are using a GNU frontend before adding these options. This is also a very large set of flags that you are adding, maintaining this seems like a headache. How were these handled in autotools?

Copy link
Contributor

@das das Jul 26, 2017

Choose a reason for hiding this comment

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

these are the flags we have enabled in the darwin build internally (in Xcode, see the .xcconfig files in the repo), so shared code should be built with these enabled to avoid breaking the darwin build (and I want the darwin CMake build to definitely have these so that it matches the Xcode build as closely as possible).
We maintain these flags internally by hand by adding or removing new ones as clang adds support for them (based on -Weverything). Once the opensource buildsystem matches, we can start maintaining these in parallel.

If we need to opt out non-clang platforms like Windows that we don't build & support on a continual basis right now, that is a much lesser concern IMO

@@ -91,7 +91,7 @@ function(add_unit_test name)
if(WITH_BLOCKS_RUNTIME)
target_link_libraries(${name} PRIVATE BlocksRuntime)
endif()
if(BSD_OVERLAY_FOUND)
if(BSD_OVERLAY_FOUND AND (NOT ${name} MATCHES "dispatch_c99"))
Copy link
Member

Choose a reason for hiding this comment

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

These exclusions are ugly. How about adding a NO_BSD_OVERLAY keyword option to the add_unit_test so that it is generic.

@dgrove-oss dgrove-oss force-pushed the cmake-extended-warnings branch from cffdf51 to 881106d Compare July 26, 2017 17:50
@dgrove-oss
Copy link
Contributor Author

updated based on review comments.

@@ -0,0 +1,91 @@

# TODO: really should be checking for clang/gcc compatibile compiler
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
Copy link
Member

Choose a reason for hiding this comment

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

if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")

@@ -58,7 +58,7 @@ if(ENABLE_SWIFT)
swiftSwiftOnoneSupport)
endif()

function(add_unit_test name)
function(add_unit_test name uses_bsd_overlay)
Copy link
Member

Choose a reason for hiding this comment

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

Just make this a keyword argument (add NO_BSD_OVERLAY to the options list below), you can reference it as AUT_NO_BSD_OVERLAY then.

@dgrove-oss dgrove-oss force-pushed the cmake-extended-warnings branch from 881106d to d120813 Compare July 27, 2017 12:46
@dgrove-oss
Copy link
Contributor Author

updated again based on @compnerd feedback

@@ -60,6 +60,7 @@ endif()

function(add_unit_test name)
set(options DISABLED_TEST)
set(options NO_BSD_OVERLAY)
Copy link
Member

Choose a reason for hiding this comment

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

This drops the DISABLED_TEST since you overwrite the variable. Just append to it.

set(options DISABLED_TEST;NO_BSD_OVERLAY)

@@ -138,6 +138,8 @@ set(DISPATCH_C_TESTS
data
io_net
select)
set(DISPATCH_C99_TESTS
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't bother with a list for a single test. Just inline it below.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

We shouldn't drop the DISABLED_TEST option.

@dgrove-oss dgrove-oss force-pushed the cmake-extended-warnings branch from d120813 to 9babf1b Compare July 28, 2017 14:19
@dgrove-oss
Copy link
Contributor Author

updated.

There are probably going to be merge conflicts between this and #284. I'd suggest merging this one first and I will update #284 to resolve the conflicts after this is merged to master.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

This looks great! Im still not a fan of the management of the warnings, but if everyone else is okay with that, lets go with it.

@das
Copy link
Contributor

das commented Jul 28, 2017

@dgrove-oss sounds good, I've merged #284

@das
Copy link
Contributor

das commented Jul 28, 2017

argh, and now I re-read what you said and I did it the wrong way around... sorry!

@dgrove-oss
Copy link
Contributor Author

no worries; I can make it work either way. working on it now

1. add a CMake module to define additional warning flags to enable
   when compiling dispatch.

2. enable the additional warning flags by default for CMake

3. match autotools behavior of not including the BSD_OVERLAY
   when compiling the dispatch_c99 test case. This avoids
   a warning about __printflike being redefined when compiling
   this test case with the expanded set of warning flags.
@dgrove-oss dgrove-oss force-pushed the cmake-extended-warnings branch from 9babf1b to 0652ef8 Compare July 28, 2017 19:21
@dgrove-oss
Copy link
Contributor Author

ok. conflicts resolved. should be ready to go.

@das
Copy link
Contributor

das commented Jul 29, 2017

thanks!

@das das merged commit 291f34d into swiftlang:master Jul 29, 2017
@dgrove-oss dgrove-oss deleted the cmake-extended-warnings branch July 29, 2017 17:51
ktopley-apple pushed a commit that referenced this pull request Dec 6, 2018
Enable additional compiler warnings for CMake build

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants