Repository navigation
task: capture SYCL sources in the Coverity scan #2401
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
Open
jharlow-intel
wants to merge
1
commit into
master
Choose a base branch
from
task/coverity-intel-comptype
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−11
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,33 +79,80 @@ jobs: | |
| echo "${PWD}/cov-analysis/bin" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Configure Coverity for the DPC++ compiler | ||
| env: | ||
| # icx/icpx are not in Coverity's list of known compilers, so the | ||
| # clang-based templates below have to be accepted explicitly | ||
| COVERITY_UNSUPPORTED: 1 | ||
| run: | | ||
| source "${ONEAPI_ROOT}/setvars.sh" | ||
| # Cython-generated sources and the pybind11 extensions go through | ||
| # icpx, the sysroot/driver probing bits still use gcc | ||
| cov-configure --gcc | ||
| cov-configure --template --comptype clangcc --compiler icx | ||
| cov-configure --template --comptype clangcxx --compiler icpx | ||
| # Register icx/icpx with Coverity's native Intel oneAPI compiler type. | ||
| # The generic clangcc/clangcxx templates parse <sycl/sycl.hpp> without | ||
| # SYCL mode and fail on device-only builtins (__ocl_sampler_t, | ||
| # __ocl_image2d_ro_t, ...), which left 21 of 30 sources uncaptured. | ||
| # The native type emits each SYCL source twice, as a host pass and a | ||
| # spir64 device pass; see the capture check below for the latter. | ||
| # intel_oneapi_icx is current; intel_icx:linux is the older spelling | ||
| # the Scan build tool still ships (what mkl_umath's scan resolves to). | ||
| comptypes="$(cov-configure --list-compiler-types | cut -d, -f1)" | ||
| comptype="" | ||
| for candidate in intel_oneapi_icx intel_oneapi_icx:linux intel_icx:linux; do | ||
| if grep -qxF "${candidate}" <<< "${comptypes}"; then | ||
| comptype="${candidate}" | ||
| break | ||
| fi | ||
| done | ||
| if [ -z "${comptype}" ]; then | ||
| echo "::error::No Intel oneAPI compiler type in this cov-analysis; refusing to fall back to the generic Clang configuration." | ||
| exit 1 | ||
| fi | ||
| echo "Using Coverity compiler type: ${comptype}" | ||
| # With --template, --compiler takes a bare executable name; capture | ||
| # matches on the name of the spawned executable, so this also covers | ||
| # the absolute icx/icpx paths CMake resolves. | ||
|
Comment on lines
+108
to
+110
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, very verbose |
||
| cov-configure --template --comptype "${comptype}" --compiler icx | ||
| cov-configure --template --comptype "${comptype}" --compiler icpx | ||
|
|
||
| - name: Build under cov-build | ||
| timeout-minutes: 90 | ||
| env: | ||
| COVERITY_UNSUPPORTED: 1 | ||
| run: | | ||
| set -o pipefail | ||
| source "${ONEAPI_ROOT}/setvars.sh" | ||
| rm -rf _skbuild | ||
| # --skip-editable: the in-place build_ext already compiled everything | ||
| # Coverity needs to see, a pip install would only repeat it | ||
| cov-build --dir cov-int \ | ||
| python scripts/build_locally.py --oneapi --skip-editable --verbose \ | ||
| 2>&1 | tee cov-build.log | ||
| if ! grep -qE "Emitted [1-9][0-9]* .*compilation unit" cov-build.log; then | ||
| echo "::error::Coverity captured 0 compilation units — the C++ build did not run under cov-build." | ||
| { | ||
| echo "### Coverity capture" | ||
| echo '```' | ||
| grep -E "Emitted .*compilation unit|are ready for analysis" cov-build.log || true | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| # A partial capture still uploads happily and uses up a scan, so | ||
| # require every project source to be emitted. This is checked per | ||
| # source rather than via the "Emitted N (P%)" total because that | ||
| # total also counts the spir64 device passes, which the Scan build | ||
| # tool's emitter cannot parse (it trips over and then crashes in the | ||
| # SPIR-V builtin headers), capping P at 66% here. The host pass of | ||
| # each source is what gets analyzed. CMake's own try-compile probes | ||
| # under CMakeFiles/ are not project code and often fail. | ||
| # `|| true` because a no-match grep would otherwise trip pipefail and | ||
| # end the step before the errors below are printed. | ||
|
Comment on lines
+130
to
+139
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also quite verbose |
||
| log=cov-int/build-log.txt | ||
| compiled="$(grep -oP '\[STATUS\] Compiling \K\S+' "${log}" | grep -F "${GITHUB_WORKSPACE}/" | grep -vF /CMakeFiles/ | sort -u || true)" | ||
| # Unanchored: parallel compiles can splice another unit's output onto | ||
| # the same line of the log. | ||
| emitted="$(grep -oP "Emit for file '\K[^']+(?=' \(TU [0-9]+\) complete\.)" "${log}" | sort -u || true)" | ||
| missing="$(comm -23 <(echo "${compiled}") <(echo "${emitted}"))" | ||
| total="$(grep -c . <<< "${compiled}" || true)" | ||
| nmissing="$(grep -c . <<< "${missing}" || true)" | ||
| echo "Coverity emitted $(( total - nmissing )) of ${total} project sources" | tee -a "$GITHUB_STEP_SUMMARY" | ||
| if [ "${total}" -eq 0 ]; then | ||
| echo "::error::No project sources were compiled under cov-build." | ||
| exit 1 | ||
| fi | ||
| if [ "${nmissing}" -gt 0 ]; then | ||
| echo "${missing}" | ||
| echo "::error::Coverity did not emit ${nmissing} of ${total} project sources (listed above)." | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
@@ -121,6 +168,9 @@ jobs: | |
| if-no-files-found: warn | ||
|
|
||
| - name: Submit results to Coverity Scan | ||
| # Scan keeps only the latest build, so a run dispatched on a feature | ||
| # branch would replace master's results; such runs stop after capture. | ||
| if: github.ref == 'refs/heads/master' | ||
| timeout-minutes: 15 | ||
| env: | ||
| COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we shorten this comment?