Skip to content
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

Make compilation warnings as errors #9632

Closed
wangkuiyi opened this issue Apr 4, 2018 · 0 comments
Closed

Make compilation warnings as errors #9632

wangkuiyi opened this issue Apr 4, 2018 · 0 comments
Assignees

Comments

@wangkuiyi
Copy link
Collaborator

Compilation warnings are annoying. PaddlePaddle used to suffer from many warnings of "comparing signed and unsigned integers". These warnings make it hard to go over the build log and find out errors. We tried hard to fix warnings; it was a hard work. Recently, we see warnings again. With the growing of contributors, the trend is clear.

  • I propose to add the compiler flag -Werror, which considers warnings and errors, and
  • we'd only want to apply this to PaddlePaddle's code, but not its dependents built using CMake.

Thanks to @gangliao who pointed the solution

  1. Add -Werror to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. This would apply -Werror to PaddlePaddle.

  2. Define PADDLE_DEPS_CXX_FLAGS and PADDLE_DEPS_C_FLAGS, which don't include -Werror.

  3. Edit /cmake/external/*.cmake, add set the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS variables of these dependents to be the value of PADDLE_DEPS_CXX_FLAGS and PADDLE_DEPS_C_FLAGS.
    For example:

    ExternalProject_Add(
     extern_glog
     ...
     CMAKE_ARGS      -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
                     -DCMAKE_C_COMPILER=${PADDLE_DEPS_C_COMPILER}
                     -DCMAKE_CXX_FLAGS=${PADDLE_DEPS_CXX_FLAGS}
                     -DCMAKE_C_FLAGS=${PADDLE_DEPS_C_FLAGS}
    
@wangkuiyi wangkuiyi self-assigned this Apr 4, 2018
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

No branches or pull requests

2 participants