git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/2] ci: detect more warnings via `-Og`

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 6, 2024, 09:31 UTC
Message-ID
<cover.1717662814.git.ps@pks.im>
In-Reply-To
<20240606080552.GA658959@coredump.intra.peff.net>
Hi,

this is the second version of my patch series that modifies one of our CI jobs to compile with `-Og`. We have noticed that it may surface more warnings that we do not see with `-O2`, so this should help to find more bugs up front.

Changes compared to v1:
  - Instead of adapting the "pedantic" job, we now adapt
    "linux-gcc-default" to compile with `-Og`. This is because that job
    uses ubuntu:latest and thus a recent compiler, and there are other
    jobs with ubuntu:latest that continue to compile with `-O2`. So this
    is a strict improvement of coverage for diagnostics.
  - Add a way to override the optimization level to our Makefile, as
    suggested by Peff.
Patrick
Patrick Steinhardt (2):
  ci: fix check for Ubuntu 20.04
  ci: compile "linux-gcc-default" job with -Og
 Makefile                  | 3 ++-
 ci/lib.sh                 | 2 +-
 ci/run-build-and-tests.sh | 9 +++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
Range-diff against v1:
1:  f91004a438 = 1:  f91004a438 ci: fix check for Ubuntu 20.04
2:  351dec4a4d ! 2:  bdf0e40a77 ci: let pedantic job compile with -Og
    @@ Metadata
     Author: Patrick Steinhardt <ps@pks.im>
     
      ## Commit message ##
    -    ci: let pedantic job compile with -Og
    +    ci: compile "linux-gcc-default" job with -Og
     
         We have recently noticed that our CI does not always notice variables
         that may be used uninitialized. While it is expected that compiler
    @@ Commit message
     
         While we could adapt all jobs to compile with `-Og` now, that would
         potentially mask other warnings that only get diagnosed with `-O2`.
    -    Instead, only adapt the "pedantic" job to compile with `-Og`.
    +    Instead, adapt the "linux-gcc-default" job to compile with `-Og`. This
    +    job is chosen because it uses the "ubuntu:latest" image and should thus
    +    have a comparatively recent compiler toolchain, and because we have
    +    other jobs that use "ubuntu:latest" so that we do not loose coverage for
    +    warnings diagnosed only on `-O2` level.
    +
    +    To make it easier to set up the optimization level in our CI, add
    +    support in our Makefile to specify the level via an environment
    +    variable.
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
    + ## Makefile ##
    +@@ Makefile: endif
    + # tweaked by config.* below as well as the command-line, both of
    + # which'll override these defaults.
    + # Older versions of GCC may require adding "-std=gnu99" at the end.
    +-CFLAGS = -g -O2 -Wall
    ++O ?= 2
    ++CFLAGS = -g -O$(O) -Wall
    + LDFLAGS =
    + CC_LD_DYNPATH = -Wl,-rpath,
    + BASIC_CFLAGS = -I.
    +
      ## ci/run-build-and-tests.sh ##
    -@@ ci/run-build-and-tests.sh: pedantic)
    - 	# Don't run the tests; we only care about whether Git can be
    - 	# built.
    - 	export DEVOPTS=pedantic
    +@@ ci/run-build-and-tests.sh: esac
    + run_tests=t
    + 
    + case "$jobname" in
    ++linux-gcc-default)
     +	# Warnings generated by compilers are unfortunately specific to the
     +	# optimization level. With `-O0`, many warnings won't be shown at all,
     +	# whereas the optimizations performed by our default optimization level
     +	# `-O2` will mask others. We thus use `-Og` here just so that we have
     +	# at least one job with a different optimization level so that we can
     +	# overall surface more warnings.
    -+	cat >config.mak <<-EOF
    -+	export CFLAGS=-Og
    -+	EOF
    - 	run_tests=
    ++	export O=g
    ++	;;
    + linux-gcc)
    + 	export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
      	;;
    - esac
-- 
2.45.2.409.g7b0defb391.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 10 of 48 in “ci: detect more warnings via `-Og`”
  1. 0/2 ci: detect more warnings via `-Og`Patrick Steinhardt, Jun 6, 2024
  2. 1/2 ci: fix check for Ubuntu 20.04Patrick Steinhardt, Jun 6, 2024
  3. Jeff KingJun 6, 2024
  4. Patrick SteinhardtJun 6, 2024
  5. 2/2 ci: let pedantic job compile with -OgPatrick Steinhardt, Jun 6, 2024
  6. Jeff KingJun 6, 2024
  7. Patrick SteinhardtJun 6, 2024
  8. Jeff KingJun 6, 2024
  9. Patrick SteinhardtJun 6, 2024
  10. 0/2 ci: detect more warnings via `-Og`Patrick Steinhardt, Jun 6, 2024
  11. 1/2 ci: fix check for Ubuntu 20.04Patrick Steinhardt, Jun 6, 2024
  12. 2/2 ci: compile "linux-gcc-default" job with -OgPatrick Steinhardt, Jun 6, 2024
  13. Justin ToblerJun 6, 2024
  14. Junio C HamanoJun 6, 2024
  15. Patrick SteinhardtJun 7, 2024
  16. Junio C HamanoJun 7, 2024
  17. Jeff KingJun 8, 2024
  18. Junio C HamanoJun 7, 2024
  19. Junio C HamanoJun 7, 2024
  20. 0/4 ci: detect more warnings via `-Og`Patrick Steinhardt, Jun 7, 2024
  21. 1/4 ci: fix check for Ubuntu 20.04Patrick Steinhardt, Jun 7, 2024
  22. 2/4 Makefile: add ability to append to CFLAGS and LDFLAGSPatrick Steinhardt, Jun 7, 2024
  23. Jeff KingJun 8, 2024
  24. Junio C HamanoJun 8, 2024
  25. Patrick SteinhardtJun 10, 2024
  26. 3/4 ci: compile code with V=1Patrick Steinhardt, Jun 7, 2024
  27. 4/4 ci: compile "linux-gcc-default" job with -OgPatrick Steinhardt, Jun 7, 2024
  28. Junio C HamanoJun 7, 2024
  29. Jeff KingJun 8, 2024
  30. Junio C HamanoJun 8, 2024
  31. Patrick SteinhardtJun 10, 2024
  32. Junio C HamanoJun 6, 2024
  33. Patrick SteinhardtJun 7, 2024
  34. Junio C HamanoJun 7, 2024
  35. 0/2 ci: detect more warnings via `-Og`Patrick Steinhardt, Jun 10, 2024
  36. 1/2 Makefile: add ability to append to CFLAGS and LDFLAGSPatrick Steinhardt, Jun 10, 2024
  37. 2/2 ci: compile "linux-gcc-default" job with -OgPatrick Steinhardt, Jun 10, 2024
  38. Junio C HamanoJun 10, 2024
  39. 1/2 DONTAPPLY: -Og fallout workaroundJunio C Hamano, Jun 10, 2024
  40. Junio C HamanoJun 10, 2024
  41. Patrick SteinhardtJun 11, 2024
  42. Junio C HamanoJun 11, 2024
  43. Patrick SteinhardtJun 12, 2024
  44. Patrick SteinhardtJun 12, 2024
  45. 2/2 DONTAPPLY: -Os fallout workaroundJunio C Hamano, Jun 10, 2024
  46. Junio C HamanoJun 12, 2024
  47. Jeff KingJun 13, 2024
  48. Junio C HamanoJun 13, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.