Skip to content

build: prepare builds for clang-cl, add cmake ossfuzz support - #1524

Closed
vszakats wants to merge 4 commits into
libssh2:masterfrom
vszakats:1-cm-ossfuzz-clangcl
Closed

vszakats wants to merge 4 commits into
libssh2:masterfrom
vszakats:1-cm-ossfuzz-clangcl

Conversation

@vszakats

@vszakats vszakats commented Jan 30, 2025 •

Copy link
Copy Markdown
Member
  • cmake: add support to build ossfuzz.
    Enable with -DBUILD_OSSFUZZ=ON.
    Also supports -DLIB_FUZZING_ENGINE= like autotools does.
  • check for __clang__ when suppressing warnings in source. Necessary
    for clang-cl, which set __clang__, but doesn't set __GNU__.
  • cmake: optimize out 4 picky warning option detections with gcc.
  • cmake: bring -pedantic-error, -Wall use closer to curl's.
  • cmake: set -Wno-language-extension-token for clang-cl.
  • cmake: escape only the necessary -W options for clang-cl.
  • cmake: apply picky warnings to C++.
  • cmake: replace unset(VAR) with set(VAR "") for init.
  • cmake: prefer dash-style MSVC options.
  • cmake: simplify MATCHES expression.
  • cmake: formatting/whitespace.
  • ci/GHA: bump actions/upload-artifact to v4

Cherry-picked from #1484

Bring `cmake/PickyWarning.cmake` closer to curl's.

- cmake: replace `unset(VAR)` with `set(VAR "")` for init
- cmake: add support to build ossfuzz
  Enable with `-DBUILD_OSSFUZZ=ON`.
  Also supports `-DLIB_FUZZING_ENGINE=` like autotools does.
- cmake: prefer dash-style MSVC options
- cmake: simplify MATCHES expression
- cmake: formatting/whitespace
@vszakats vszakats added the build label Jan 30, 2025
@vszakats vszakats closed this in 854cfa8 Jan 30, 2025
@vszakats
vszakats deleted the 1-cm-ossfuzz-clangcl branch January 30, 2025 21:03
vszakats added a commit that referenced this pull request Feb 2, 2025
- `set(VAR "${VAR}<value>")` ->
  `string(APPEND VAR "<value>")`
  Available since CMake 3.4:
  https://cmake.org/cmake/help/latest/command/string.html#append

- `set(VAR "${VAR2}-or-<value>;${VAR}")` ->
  `set(VAR "${VAR2}-or-<value>" ${VAR})`

- prefer dash-style MSVC option.
  Follow-up to 854cfa8 #1524

Closes #1533
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 26, 2025
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 26, 2025
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 27, 2025
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 28, 2025
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 6, 2025
vszakats added a commit that referenced this pull request May 7, 2025
- cmake: sync `-ftree-vrp` behavior with autotools.
- build: enable `-Wjump-misses-init` for GCC 4.5+.
  Credits-to: Marcel Raad
- packet: fix `-Wjump-misses-init` warnings.
  ```
  src/packet.c: In function ‘_libssh2_packet_add’:
  src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:920:31: note: ‘want_reply’ declared here
  src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:919:26: note: ‘len’ declared here
  src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:1121:31: note: ‘want_reply’ declared here
  src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:1120:26: note: ‘len’ declared here
  src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:1119:26: note: ‘channel’ declared here
  ```
- build: enable gcc-12/13+, clang-10+ picky warnings
- acinclude.m4: sync formatting/comments with curl.
- autotools: fix `-Wtrampolines` picky warning for gcc 4.x versions.
  Follow-up to 854cfa8 #1524
- cmake: enable `-Wall` for MSVC when `PICKY_COMPILER=ON`.
- MSVC: fix `-Wall` warnings.
  Seen on VS2015. Not seen on VS2022. Unknown for other versions.
  ```
  tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'std::size_t'
  tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%.*s' requires an argument of type 'int', but variadic argument 2 has type 'std::size_t'
  ```
- mbedtls: stop silencing warnings in 3rd-party header.
  Follow-up to a3aa6b4 #1525
- cmake: stop deleting `-W<n>` from `CMAKE_C_FLAGS` (MSVC)
  1. `CMAKE_C_FLAGS` may apply to other projects, and deleting/altering it
     may be unexpected.
  2. We pass `-W4`/`-Wall` internally now, which do override custom
     `-W<n>` options as tested with VS2008 and newer VS generators.

Closes #1588
vszakats added a commit to vszakats/libssh2 that referenced this pull request Sep 28, 2025
vszakats added a commit that referenced this pull request Sep 29, 2025
- prefer `set_property()` over `target_compile_options()`, to use
  the modern style.

  Follow-up to 8017592 #939

- prefer to append to compiler/linker options in examples/tests.
  To prevent accidentally overriding a previously set option.

  Follow-up to 14a709a #1686
  Follow-up to 854cfa8 #1524

- replace `LINK_FLAGS` with `LINK_OPTIONS` that superceded it, for
  CMake 3.13+.

  Follow-up to 854cfa8 #1524
  https://cmake.org/cmake/help/v4.1/prop_tgt/LINK_OPTIONS.html

Closes #1690
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant