polly icon indicating copy to clipboard operation
polly copied to clipboard

Using clang-analyze in Hunter build

Open oliverdaniell opened this issue 8 years ago • 4 comments

Should the clang-analyze script should continue to rebuild with clang after reporting warnings for a library using clang analyze?

I've attached my console log for a build which uses opencv, the build exits after opencv fails to build.

/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3650:13: warning: Access to field 'dims' results in a dereference of a null pointer (loaded from variable 'm')
    create( m->dims, &m->size[0], m->type );
            ^~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3741:19: warning: Access to field 'dims' results in a dereference of a null pointer (loaded from field 'hdr')
        m.create( hdr->dims, hdr->size, rtype );
                  ^~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3833:24: warning: Called C++ object pointer is null
    size_t hidx = h & (hdr->hashtab.size() - 1), nidx = hdr->hashtab[hidx];
                       ^~~~~~~~~~~~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3855:24: warning: Called C++ object pointer is null

[hunter ** FATAL ERROR **] Build step failed (dir: /home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV
[hunter ** FATAL ERROR **] [Directory:/home/oliver.daniell/jenkins/workspace/.hunter/_Base/Download/Hunter/0.11.18-seebyte/036f433/Unpacked/cmake/projects/OpenCV]

------------------------------ WIKI -------------------------------
    https://github.com/ruslo/hunter/wiki/error.external.build.failed
-------------------------------------------------------------------

CMake Error at /home/oliver.daniell/jenkins/workspace/.hunter/_Base/Download/Hunter/0.11.18-seebyte/036f433/Unpacked/cmake/modules/hunter_wiki.cmake:12 (message):
Call Stack (most recent call first):
  /home/oliver.daniell/jenkins/workspace/.hunter/_Base/Download/Hunter/0.11.18-seebyte/036f433/Unpacked/cmake/modules/hunter_fatal_error.cmake:20 (hunter_wiki)
  /home/oliver.daniell/jenkins/workspace/.hunter/_Base/Download/Hunter/0.11.18-seebyte/036f433/Unpacked/cmake/modules/hunter_download.cmake:384 (hunter_fatal_error)
  /home/oliver.daniell/jenkins/workspace/.hunter/_Base/Download/Hunter/0.11.18-seebyte/036f433/Unpacked/cmake/projects/OpenCV/hunter.cmake:165 (hunter_download)
  /home/oliver.daniell/jenkins/workspace/.hunter/_Base/Download/Hunter/0.11.18-seebyte/036f433/Unpacked/cmake/modules/hunter_add_package.cmake:87 (include)
  modules/CMakeLists.txt:3 (hunter_add_package)


    size_t hidx = h & (hdr->hashtab.size() - 1), nidx = hdr->hashtab[hidx];
                       ^~~~~~~~~~~~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3877:24: warning: Called C++ object pointer is null
    size_t hidx = h & (hdr->hashtab.size() - 1), nidx = hdr->hashtab[hidx];
                       ^~~~~~~~~~~~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3899:16: warning: Access to field 'dims' results in a dereference of a null pointer (loaded from field 'hdr')
    int i, d = hdr->dims;
               ^~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3924:24: warning: Called C++ object pointer is null
    size_t hidx = h & (hdr->hashtab.size() - 1), nidx = hdr->hashtab[hidx], previdx=0;
                       ^~~~~~~~~~~~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3943:24: warning: Called C++ object pointer is null
    size_t hidx = h & (hdr->hashtab.size() - 1), nidx = hdr->hashtab[hidx], previdx=0;
                       ^~~~~~~~~~~~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:3962:16: warning: Access to field 'dims' results in a dereference of a null pointer (loaded from field 'hdr')
    int i, d = hdr->dims;
               ^~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:4017:20: warning: Called C++ object pointer is null
    size_t hsize = hdr->hashtab.size();
                   ^~~~~~~~~~~~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:4228:26: warning: Array access (from variable 'minidx') results in a null pointer dereference
            _minidx[i] = minidx[i];
                         ^~~~~~~~~
/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Source/modules/core/src/matrix.cpp:4231:26: warning: Array access (from variable 'maxidx') results in a null pointer dereference
            _maxidx[i] = maxidx[i];
                         ^~~~~~~~~
31 warnings generated.
+ rm -f /tmp/polly-clang-analyze.out.3VF2M
+ rm -f /tmp/polly-clang-analyze.bin.83JNc
+ '[' 1 == 1 ']'
+ exit 1
make[5]: Leaving directory `/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Build/OpenCV-Release-prefix/src/OpenCV-Release-build'
make[4]: Leaving directory `/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Build/OpenCV-Release-prefix/src/OpenCV-Release-build'
make[5]: *** [modules/core/CMakeFiles/opencv_core.dir/src/matrix.cpp.o] Error 1
make[4]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make[3]: Leaving directory `/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Build/OpenCV-Release-prefix/src/OpenCV-Release-build'
make[3]: *** [all] Error 2
make[2]: Leaving directory `/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Build'
make[1]: Leaving directory `/home/oliver.daniell/jenkins/workspace/.hunter/_Base/036f433/9b60785/8934262/Build/OpenCV/Build'
make[2]: *** [OpenCV-Release-prefix/src/OpenCV-Release-stamp/OpenCV-Release-install] Error 2
make[1]: *** [CMakeFiles/OpenCV-Release.dir/all] Error 2
make: *** [all] Error 2
-- Configuring incomplete, errors occurred!
See also "/home/oliver.daniell/jenkins/workspace/MSHDF/b0491c07/_builds/analyze-Debug/CMakeFiles/CMakeOutput.log".
Command exit with status "1": [/home/oliver.daniell/jenkins/workspace/MSHDF/b0491c07]> "cmake" "-H." "-B/home/oliver.daniell/jenkins/workspace/MSHDF/b0491c07/_builds/analyze-Debug" "-DCMAKE_BUILD_TYPE=Debug" "-GUnix Makefiles" "-DCMAKE_TOOLCHAIN_FILE=/home/oliver.daniell/jenkins/workspace/MSHDF/b0491c07/polly/analyze.cmake" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DPOLLY_STATUS_DEBUG=ON" "-DHUNTER_STATUS_DEBUG=ON" 

Log: /home/oliver.daniell/jenkins/workspace/MSHDF/b0491c07/_builds/analyze-Debug/_3rdParty/polly/log.txt
*** FAILED ***
Run script: /home/oliver.daniell/jenkins/workspace/MSHDF/b0491c07/polly/bin/build.py
Toolchain: analyze
Config: Debug
Command '['/usr/bin/python3', '/home/oliver.daniell/jenkins/workspace/MSHDF/b0491c07/polly/bin/build.py', '--toolchain', 'analyze', '--config', 'Debug', '--verbose', '--clear', '--test']' returned non-zero exit status 1
None
Build step 'Conditional step (single)' marked build as failure
Finished: FAILURE```

oliverdaniell avatar Jul 16 '15 15:07 oliverdaniell

Should the clang-analyze script should continue to rebuild with clang after reporting warnings for a library using clang analyze?

It designed so it will stop the build with the error. The idea was to have additional toolchain in CI testing (like Travis) so one of the jobs report an error if any warning found. Then you explicitly mark the warning as ignored or fix it, and retrigger build again until you have greeny success status.

Quite the same happens if you use this toolchain in Hunter. Every package build such way, hence you see broken package.

What is the end goal? You want to analyze your current project which have 3rd parties from Hunter. Are you interested in warning from 3rd party?

ruslo avatar Jul 16 '15 16:07 ruslo

What is the end goal? You want to analyze your current project which have 3rd parties from Hunter. >Are you interested in warning from 3rd party?

Exactly this, I want to ignore the warnings from third parties and stop with an error on the package I am currently building

oliverdaniell avatar Jul 16 '15 19:07 oliverdaniell

Exactly this, I want to ignore the warnings from third parties and stop with an error on the package I am currently building

Okay. So the plan is to add some option/variable that can disable toolchain forwarding in Hunter. I'll think about it and let you know when it will be fixed.

As a workaround you can include analyze.cmake file with compiler settings manually without updating CMAKE_TOOLCHAIN_FILE value. Just set it after command project:

HunterGate(URL ... SHA1 ...)
project(...)
include("/path/to/polly/analyze.cmake")
add_executable(...)

If you're using build.py script pick for the --toolchain option some compatible toolchain (libcxx for example).

ruslo avatar Jul 16 '15 20:07 ruslo

As a workaround you can include analyze.cmake file with compiler settings manually without updating CMAKE_TOOLCHAIN_FILE value. Just set it after command project:

Thanks, this solves if for now!

oliverdaniell avatar Jul 17 '15 08:07 oliverdaniell