Skip to content
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

cmake: fix -Wredundant-decls in unity/mingw-w64/gcc/curldebug/DLL builds #13705

Closed
wants to merge 2 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented May 19, 2024

It affected cmake-unity shared-curltool curldebug mingw-w64 gcc builds
when building the testdeps target.

Apply the solution already used in lib/base64.c and lib/dynbuf.c to
fix it.

Also update an existing GHA CI job to test the issue fixed.

In file included from curl/lib/version_win32.c:35,
                 from curl/_bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:145:
curl/lib/memdebug.h:52:14: error: redundant redeclaration of 'curl_dbg_logfile' [-Werror=redundant-decls]
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
In file included from curl/src/slist_wc.c:32,
                 from curl/_bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:4:
curl/lib/memdebug.h:52:14: note: previous declaration of 'curl_dbg_logfile' with type 'FILE *' {aka 'struct _iobuf *'}
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
curl/lib/memdebug.h:55:44: error: redundant redeclaration of 'curl_dbg_malloc' [-Werror=redundant-decls]
   55 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE(1) void *curl_dbg_malloc(size_t size,
      |                                            ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:55:44: note: previous declaration of 'curl_dbg_malloc' with type 'void *(size_t,  int,  const char *)' {aka 'void *(long long unsigned int,  int,  const char *)'}
   55 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE(1) void *curl_dbg_malloc(size_t size,
      |                                            ^~~~~~~~~~~~~~~
[...]
curl/lib/memdebug.h:110:17: error: redundant redeclaration of 'curl_dbg_fclose' [-Werror=redundant-decls]
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:110:17: note: previous declaration of 'curl_dbg_fclose' with type 'int(FILE *, int,  const char *)' {aka 'int(struct _iobuf *, int,  const char *)'}
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~

Ref: https://ci.appveyor.com/project/curlorg/curl/builds/49840554/job/a4aoet17e9qnqx1a#L362

After: https://ci.appveyor.com/project/curlorg/curl/builds/49843735/job/hbo2uah2vj0ns523

Ref: #13689 (CI testing this PR with DEBUGBUILD/CURLDEBUG/shared-static combinations)
Depends-on: #13694
Depends-on: #13800
Closes #13705


Depends-on (fix separate issues also required to pass the updated test):

@vszakats vszakats added cmake tests Windows Windows-specific labels May 19, 2024
vszakats added a commit to vszakats/curl that referenced this pull request May 19, 2024
@github-actions github-actions bot added the CI Continuous Integration label May 19, 2024
vszakats added a commit to vszakats/curl that referenced this pull request May 20, 2024
@vszakats vszakats force-pushed the cmake-mingw-gcc-unity-warning branch from c3ec279 to 17763ae Compare May 20, 2024 23:00
vszakats added a commit that referenced this pull request May 27, 2024
- fix `DEBUGBUILD` guards that should be `UNITTESTS`, in libcurl code
  used by unit tests.
- fix guards for libcurl functions used in unit tests only.
- sync `UNITTEST` attribute between declarations and definitions.
- drop `DEBUGBUILD` guard from test `unit2600`.
- fix guards for libcurl HSTS code used by both a unit test (`unit1660`)
  and `test0446`.
- update an existing AppVeyor CI job to test the issues fixed.

This fixes building tests with `CURLDEBUG` enabled but `DEBUGBUILD`
disabled. This can happen when building tests with CMake with
`ENABLE_DEBUG=ON` in Release config, or with `ENABLE_CURLDEBUG=ON`
and _without_ `ENABLE_DEBUG=ON`. Possibly also with autotools
when using `--enable-curldebug` without `--enable-debug`.

Test results:
- before:
  https://ci.appveyor.com/project/curlorg/curl/builds/49835609
  https://ci.appveyor.com/project/curlorg/curl/builds/49898529/job/k8qpbs8idby70smw
  https://github.com/curl/curl/actions/runs/9259078835/job/25470318167?pr=13798#step:13:821
- after: https://ci.appveyor.com/project/curlorg/curl/builds/49839255
  (the two failures are unrelated, subject to PR #13705)

Ref: #13592 (issue discovery)
Ref: #13689 (CI testing this PR with `DEBUGBUILD`/`CURLDEBUG` combinations)
Closes #13694
vszakats added a commit to vszakats/curl that referenced this pull request May 27, 2024
@vszakats vszakats force-pushed the cmake-mingw-gcc-unity-warning branch from 17763ae to 79b02ec Compare May 27, 2024 19:23
…d builds

It affected cmake-unity shared-curltool curldebug mingw-w64 gcc
builds when building the `testdeps` target.

Apply the solution already used in `lib/base64.c` and `lib/dynbuf.c`
to fix it.

```
In file included from curl/lib/version_win32.c:35,
                 from curl/_bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:145:
curl/lib/memdebug.h:52:14: error: redundant redeclaration of 'curl_dbg_logfile' [-Werror=redundant-decls]
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
In file included from curl/src/slist_wc.c:32,
                 from curl/_bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:4:
curl/lib/memdebug.h:52:14: note: previous declaration of 'curl_dbg_logfile' with type 'FILE *' {aka 'struct _iobuf *'}
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
curl/lib/memdebug.h:55:44: error: redundant redeclaration of 'curl_dbg_malloc' [-Werror=redundant-decls]
   55 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE(1) void *curl_dbg_malloc(size_t size,
      |                                            ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:55:44: note: previous declaration of 'curl_dbg_malloc' with type 'void *(size_t,  int,  const char *)' {aka 'void *(long long unsigned int,  int,  const char *)'}
   55 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE(1) void *curl_dbg_malloc(size_t size,
      |                                            ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:58:48: error: redundant redeclaration of 'curl_dbg_calloc' [-Werror=redundant-decls]
   58 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE2(1, 2) void *curl_dbg_calloc(size_t elements,
      |                                                ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:58:48: note: previous declaration of 'curl_dbg_calloc' with type 'void *(size_t,  size_t,  int,  const char *)' {aka 'void *(long long unsigned int,  long long unsigned int,  int,  const char *)'}
   58 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE2(1, 2) void *curl_dbg_calloc(size_t elements,
      |                                                ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:60:33: error: redundant redeclaration of 'curl_dbg_realloc' [-Werror=redundant-decls]
   60 | CURL_EXTERN ALLOC_SIZE(2) void *curl_dbg_realloc(void *ptr,
      |                                 ^~~~~~~~~~~~~~~~
curl/lib/memdebug.h:60:33: note: previous declaration of 'curl_dbg_realloc' with type 'void *(void *, size_t,  int,  const char *)' {aka 'void *(void *, long long unsigned int,  int,  const char *)'}
   60 | CURL_EXTERN ALLOC_SIZE(2) void *curl_dbg_realloc(void *ptr,
      |                                 ^~~~~~~~~~~~~~~~
curl/lib/memdebug.h:64:18: error: redundant redeclaration of 'curl_dbg_free' [-Werror=redundant-decls]
   64 | CURL_EXTERN void curl_dbg_free(void *ptr, int line, const char *source);
      |                  ^~~~~~~~~~~~~
curl/lib/memdebug.h:64:18: note: previous declaration of 'curl_dbg_free' with type 'void(void *, int,  const char *)'
   64 | CURL_EXTERN void curl_dbg_free(void *ptr, int line, const char *source);
      |                  ^~~~~~~~~~~~~
curl/lib/memdebug.h:65:30: error: redundant redeclaration of 'curl_dbg_strdup' [-Werror=redundant-decls]
   65 | CURL_EXTERN ALLOC_FUNC char *curl_dbg_strdup(const char *str, int line,
      |                              ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:65:30: note: previous declaration of 'curl_dbg_strdup' with type 'char *(const char *, int,  const char *)'
   65 | CURL_EXTERN ALLOC_FUNC char *curl_dbg_strdup(const char *str, int line,
      |                              ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:68:33: error: redundant redeclaration of 'curl_dbg_wcsdup' [-Werror=redundant-decls]
   68 | CURL_EXTERN ALLOC_FUNC wchar_t *curl_dbg_wcsdup(const wchar_t *str,
      |                                 ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:68:33: note: previous declaration of 'curl_dbg_wcsdup' with type 'wchar_t *(const wchar_t *, int,  const char *)' {aka 'short unsigned int *(const short unsigned int *, int,  const char *)'}
   68 | CURL_EXTERN ALLOC_FUNC wchar_t *curl_dbg_wcsdup(const wchar_t *str,
      |                                 ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:73:18: error: redundant redeclaration of 'curl_dbg_memdebug' [-Werror=redundant-decls]
   73 | CURL_EXTERN void curl_dbg_memdebug(const char *logname);
      |                  ^~~~~~~~~~~~~~~~~
curl/lib/memdebug.h:73:18: note: previous declaration of 'curl_dbg_memdebug' with type 'void(const char *)'
   73 | CURL_EXTERN void curl_dbg_memdebug(const char *logname);
      |                  ^~~~~~~~~~~~~~~~~
curl/lib/memdebug.h:74:18: error: redundant redeclaration of 'curl_dbg_memlimit' [-Werror=redundant-decls]
   74 | CURL_EXTERN void curl_dbg_memlimit(long limit);
      |                  ^~~~~~~~~~~~~~~~~
curl/lib/memdebug.h:74:18: note: previous declaration of 'curl_dbg_memlimit' with type 'void(long int)'
   74 | CURL_EXTERN void curl_dbg_memlimit(long limit);
      |                  ^~~~~~~~~~~~~~~~~
curl/lib/memdebug.h:75:18: error: redundant redeclaration of 'curl_dbg_log' [-Werror=redundant-decls]
   75 | CURL_EXTERN void curl_dbg_log(const char *format, ...) CURL_PRINTF(1, 2);
      |                  ^~~~~~~~~~~~
curl/lib/memdebug.h:75:18: note: previous declaration of 'curl_dbg_log' with type 'void(const char *, ...)'
   75 | CURL_EXTERN void curl_dbg_log(const char *format, ...) CURL_PRINTF(1, 2);
      |                  ^~~~~~~~~~~~
curl/lib/memdebug.h:78:27: error: redundant redeclaration of 'curl_dbg_socket' [-Werror=redundant-decls]
   78 | CURL_EXTERN curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
      |                           ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:78:27: note: previous declaration of 'curl_dbg_socket' with type 'curl_socket_t(int,  int,  int,  int,  const char *)' {aka 'long long unsigned int(int,  int,  int,  int,  const char *)'}
   78 | CURL_EXTERN curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
      |                           ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:80:18: error: redundant redeclaration of 'curl_dbg_mark_sclose' [-Werror=redundant-decls]
   80 | CURL_EXTERN void curl_dbg_mark_sclose(curl_socket_t sockfd,
      |                  ^~~~~~~~~~~~~~~~~~~~
curl/lib/memdebug.h:80:18: note: previous declaration of 'curl_dbg_mark_sclose' with type 'void(curl_socket_t,  int,  const char *)' {aka 'void(long long unsigned int,  int,  const char *)'}
   80 | CURL_EXTERN void curl_dbg_mark_sclose(curl_socket_t sockfd,
      |                  ^~~~~~~~~~~~~~~~~~~~
curl/lib/memdebug.h:82:17: error: redundant redeclaration of 'curl_dbg_sclose' [-Werror=redundant-decls]
   82 | CURL_EXTERN int curl_dbg_sclose(curl_socket_t sockfd,
      |                 ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:82:17: note: previous declaration of 'curl_dbg_sclose' with type 'int(curl_socket_t,  int,  const char *)' {aka 'int(long long unsigned int,  int,  const char *)'}
   82 | CURL_EXTERN int curl_dbg_sclose(curl_socket_t sockfd,
      |                 ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:84:27: error: redundant redeclaration of 'curl_dbg_accept' [-Werror=redundant-decls]
   84 | CURL_EXTERN curl_socket_t curl_dbg_accept(curl_socket_t s, void *a, void *alen,
      |                           ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:84:27: note: previous declaration of 'curl_dbg_accept' with type 'curl_socket_t(curl_socket_t,  void *, void *, int,  const char *)' {aka 'long long unsigned int(long long unsigned int,  void *, void *, int,  const char *)'}
   84 | CURL_EXTERN curl_socket_t curl_dbg_accept(curl_socket_t s, void *a, void *alen,
      |                           ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:93:28: error: redundant redeclaration of 'curl_dbg_send' [-Werror=redundant-decls]
   93 | CURL_EXTERN SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
      |                            ^~~~~~~~~~~~~
curl/lib/memdebug.h:93:28: note: previous declaration of 'curl_dbg_send' with type 'int(SOCKET,  const char *, int,  int,  int,  const char *)' {aka 'int(long long unsigned int,  const char *, int,  int,  int,  const char *)'}
   93 | CURL_EXTERN SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
      |                            ^~~~~~~~~~~~~
curl/lib/memdebug.h:98:28: error: redundant redeclaration of 'curl_dbg_recv' [-Werror=redundant-decls]
   98 | CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd,
      |                            ^~~~~~~~~~~~~
curl/lib/memdebug.h:98:28: note: previous declaration of 'curl_dbg_recv' with type 'int(SOCKET,  char *, int,  int,  int,  const char *)' {aka 'int(long long unsigned int,  char *, int,  int,  int,  const char *)'}
   98 | CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd,
      |                            ^~~~~~~~~~~~~
curl/lib/memdebug.h:105:30: error: redundant redeclaration of 'curl_dbg_fopen' [-Werror=redundant-decls]
  105 | CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fopen(const char *file, const char *mode,
      |                              ^~~~~~~~~~~~~~
curl/lib/memdebug.h:105:30: note: previous declaration of 'curl_dbg_fopen' with type 'FILE *(const char *, const char *, int,  const char *)' {aka 'struct _iobuf *(const char *, const char *, int,  const char *)'}
  105 | CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fopen(const char *file, const char *mode,
      |                              ^~~~~~~~~~~~~~
curl/lib/memdebug.h:107:30: error: redundant redeclaration of 'curl_dbg_fdopen' [-Werror=redundant-decls]
  107 | CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode,
      |                              ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:107:30: note: previous declaration of 'curl_dbg_fdopen' with type 'FILE *(int,  const char *, int,  const char *)' {aka 'struct _iobuf *(int,  const char *, int,  const char *)'}
  107 | CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode,
      |                              ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:110:17: error: redundant redeclaration of 'curl_dbg_fclose' [-Werror=redundant-decls]
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:110:17: note: previous declaration of 'curl_dbg_fclose' with type 'int(FILE *, int,  const char *)' {aka 'int(struct _iobuf *, int,  const char *)'}
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/49840554/job/a4aoet17e9qnqx1a#L362

Ref: curl#13689 (CI testing this PR with `DEBUGBUILD`/`CURLDEBUG` combinations)
Closes #xxxxx
@vszakats vszakats force-pushed the cmake-mingw-gcc-unity-warning branch from 79b02ec to 963327c Compare May 27, 2024 20:30
@vszakats vszakats closed this in 0fd794d May 27, 2024
@vszakats vszakats deleted the cmake-mingw-gcc-unity-warning branch May 27, 2024 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration cmake tests Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

None yet

1 participant