Skip to content

build: speed up and extend picky compiler options#952

Closed
vszakats wants to merge 55 commits intolibssh2:masterfrom
vszakats:autotools-more-warnings
Closed

build: speed up and extend picky compiler options#952
vszakats wants to merge 55 commits intolibssh2:masterfrom
vszakats:autotools-more-warnings

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Apr 11, 2023

Implement picky warnings with clang in autotools. Extend picky gcc
warnings, sync them between build tools and compilers and greatly
speed up detection in CMake.

  • autotools: enable clang compiler warnings with --enable-debug.

  • autotools: enable more gcc compiler warnings with --enable-debug.

  • autotools/cmake: sync compiler warning options between gcc and clang.

  • sync compiler warning options between autotools and cmake.

  • cmake: reduce option-checks to speed up the detection phase.
    Bring them down to 3 (from 35). Leaving some checks to keep the
    CMake logic alive and for an easy way to add new options.

    clang 3.0 (2011-11-29) and gcc 2.95 (1999-07-31) now required.

  • autotools logic copied from curl, with these differences:

    • delete -Wimplicit-fallthrough=4 due to a false positive.

    • reduce -Wformat-truncation=2 to 1 due to a false positive.

    • simplify MinGW detection for -Wno-pedantic-ms-format.

  • cmake: show enabled picky compiler options (like autotools).

  • cmake: do compile tests/simple.c and tests/ssh2.c.

  • fix new compiler warnings.

  • tests/CMakeLists.txt: fix indentation.

Original source of autotools logic:

Notice that the autotools implementation considers Apple clang as
legacy clang 3.7. CMake detection works more accurately, at the same
time more error-prone and difficult to update due to the sparsely
documented nature of Apple clang option evolution.

Closes #952


Without whitespace changes: https://github.com/libssh2/libssh2/pull/952/files?w=1

@vszakats vszakats force-pushed the autotools-more-warnings branch 8 times, most recently from 5eab2aa to 84b70ef Compare April 12, 2023 02:06
@vszakats vszakats changed the title autotools: more gcc warnings and clang warnings build: enable more clang and gcc warnings Apr 12, 2023
@vszakats vszakats force-pushed the autotools-more-warnings branch 2 times, most recently from 238d329 to 2a3d85e Compare April 12, 2023 12:23
@vszakats vszakats changed the title build: enable more clang and gcc warnings build: sync clang/gcc warnings between autotools and cmake Apr 12, 2023
@vszakats vszakats changed the title build: sync clang/gcc warnings between autotools and cmake build: sync clang/gcc picky warnings between autotools/cmake Apr 12, 2023
@vszakats vszakats changed the title build: sync clang/gcc picky warnings between autotools/cmake build: sync clang/gcc picky warnings between autotools-cmake Apr 12, 2023
@vszakats vszakats force-pushed the autotools-more-warnings branch from 8535a63 to 88d10ed Compare April 12, 2023 18:45
@vszakats vszakats changed the title build: sync clang/gcc picky warnings between autotools-cmake build: speed-up and extend picky compiler options Apr 12, 2023
@vszakats vszakats force-pushed the autotools-more-warnings branch from 88d10ed to 0202879 Compare April 13, 2023 01:13
@vszakats vszakats changed the title build: speed-up and extend picky compiler options build: speed up and extend picky compiler options Apr 13, 2023
@vszakats vszakats closed this in ec0feae Apr 13, 2023
@vszakats vszakats deleted the autotools-more-warnings branch April 13, 2023 11:14
vszakats added a commit to vszakats/curl that referenced this pull request Apr 16, 2023
Extend existing picky compiler options with ones missing compared to
autotools builds. Also sync options between clang and gcc.

Redesign the way we enable these options to avoid the slow option
detection almost completely.

This reduces the number of detections from 35 to zero for clang
and 3 for gcc, even after adding a bunch of new options.

clang 3.0 (2011-11-29) and gcc 2.95 (1999-07-31) now required.

Also show enabled picky options.

Ref: libssh2/libssh2#952

Closes #xxxxx
vszakats added a commit to curl/curl that referenced this pull request Apr 16, 2023
Extend existing picky compiler options with ones missing compared to
autotools builds. Also sync options between clang and gcc.

Redesign the way we enable these options to avoid the slow option
detection almost completely.

This reduces the number of detections from 35 to zero for clang and
3 for gcc, even after adding a bunch of new options.

clang 3.0 (2011-11-29) and gcc 2.95 (1999-07-31) now required.

Also show enabled picky options.

Ref: libssh2/libssh2#952

Reviewed-by: Daniel Stenberg
Closes #10973
bch pushed a commit to bch/curl that referenced this pull request Jul 19, 2023
Extend existing picky compiler options with ones missing compared to
autotools builds. Also sync options between clang and gcc.

Redesign the way we enable these options to avoid the slow option
detection almost completely.

This reduces the number of detections from 35 to zero for clang and
3 for gcc, even after adding a bunch of new options.

clang 3.0 (2011-11-29) and gcc 2.95 (1999-07-31) now required.

Also show enabled picky options.

Ref: libssh2/libssh2#952

Reviewed-by: Daniel Stenberg
Closes curl#10973
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Implement picky warnings with clang in autotools. Extend picky gcc
warnings, sync them between build tools and compilers and greatly
speed up detection in CMake.

- autotools: enable clang compiler warnings with `--enable-debug`.

- autotools: enable more gcc compiler warnings with `--enable-debug`.

- autotools/cmake: sync compiler warning options between gcc and clang.

- sync compiler warning options between autotools and cmake.

- cmake: reduce option-checks to speed up the detection phase.
  Bring them down to 3 (from 35). Leaving some checks to keep the
  CMake logic alive and for an easy way to add new options.

  clang 3.0 (2011-11-29) and gcc 2.95 (1999-07-31) now required.

- autotools logic copied from curl, with these differences:

  - delete `-Wimplicit-fallthrough=4` due to a false positive.

  - reduce `-Wformat-truncation=2` to `1` due to a false positive.

  - simplify MinGW detection for `-Wno-pedantic-ms-format`.

- cmake: show enabled picky compiler options (like autotools).

- cmake: do compile `tests/simple.c` and `tests/ssh2.c`.

- fix new compiler warnings.

- `tests/CMakeLists.txt`: fix indentation.

Original source of autotools logic:
- https://github.com/curl/curl/blob/a8fbdb461cecbfe1ac6ecc5d8f6cf181e1507da8/acinclude.m4
- https://github.com/curl/curl/blob/a8fbdb461cecbfe1ac6ecc5d8f6cf181e1507da8/m4/curl-compilers.m4

Notice that the autotools implementation considers Apple clang as
legacy clang 3.7. CMake detection works more accurately, at the same
time more error-prone and difficult to update due to the sparsely
documented nature of Apple clang option evolution.

Closes libssh2#952
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.

1 participant