Bug 29926 - debuginfod using deprecated curl (since 7.55.0) API, fails to build with 7.87.0
Summary: debuginfod using deprecated curl (since 7.55.0) API, fails to build with 7.87.0
Status: RESOLVED FIXED
Alias: None
Product: elfutils
Classification: Unclassified
Component: debuginfod (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-21 15:41 UTC by Andrew Paprocki
Modified: 2023-01-11 14:17 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2023-01-10 00:00:00


Attachments
Fix selection of non-deprecated Curl API (945 bytes, patch)
2022-12-21 16:27 UTC, Andrew Paprocki
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Paprocki 2022-12-21 15:41:28 UTC
The debuginfod build fails because it is using deprecated curl APIs that were marked deprecated in 7.55 and hard-deprecated in 7.87, triggering -Werror=deprecated-declarations errors:


../../debuginfod/debuginfod-client.c: In function 'debuginfod_query_server':
../../debuginfod/debuginfod-client.c:895:15: error: 'CURLINFO_SIZE_DOWNLOAD' is deprecated: since 7.55.0. Use CURLINFO_SIZE_DOWNLOAD_T [-Werror=deprecated-declarations]
  895 |               curl_res = curl_easy_getinfo(target_handle,
      |               ^~~~~~~~
In file included from ../../debuginfod/debuginfod-client.c:86:
/opt/bbinfra/include/curl/curl.h:2836:3: note: declared here
 2836 |   CURLINFO_SIZE_DOWNLOAD
      |   ^~~~~~~~~~~~~~~~~~~~~~
../../debuginfod/debuginfod-client.c:913:15: error: 'CURLINFO_CONTENT_LENGTH_DOWNLOAD' is deprecated: since 7.55.0. Use CURLINFO_CONTENT_LENGTH_DOWNLOAD_T [-Werror=deprecated-declarations]
  913 |               curl_res = curl_easy_getinfo(target_handle,
      |               ^~~~~~~~
In file included from ../../debuginfod/debuginfod-client.c:86:
/opt/bbinfra/include/curl/curl.h:2853:3: note: declared here
 2853 |   CURLINFO_CONTENT_LENGTH_DOWNLOAD
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../debuginfod/debuginfod-client.c: In function 'debuginfod_query_server':
../../debuginfod/debuginfod-client.c:895:15: error: 'CURLINFO_SIZE_DOWNLOAD' is deprecated: since 7.55.0. Use CURLINFO_SIZE_DOWNLOAD_T [-Werror=deprecated-declarations]
  895 |               curl_res = curl_easy_getinfo(target_handle,
      |               ^~~~~~~~
In file included from ../../debuginfod/debuginfod-client.c:86:
/opt/bbinfra/include/curl/curl.h:2836:3: note: declared here
 2836 |   CURLINFO_SIZE_DOWNLOAD
      |   ^~~~~~~~~~~~~~~~~~~~~~
../../debuginfod/debuginfod-client.c:913:15: error: 'CURLINFO_CONTENT_LENGTH_DOWNLOAD' is deprecated: since 7.55.0. Use CURLINFO_CONTENT_LENGTH_DOWNLOAD_T [-Werror=deprecated-declarations]
  913 |               curl_res = curl_easy_getinfo(target_handle,
      |               ^~~~~~~~
In file included from ../../debuginfod/debuginfod-client.c:86:
/opt/bbinfra/include/curl/curl.h:2853:3: note: declared here
 2853 |   CURLINFO_CONTENT_LENGTH_DOWNLOAD
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors


This is due to the code having an `#ifdef` fallback on the old identifiers that must be removed to compile with 7.87.
Comment 1 Andrew Paprocki 2022-12-21 16:27:48 UTC
Created attachment 14535 [details]
Fix selection of non-deprecated Curl API

The `CURLINFO_SIZE_DOWNLOAD_T` and `CURLINFO_CONTENT_LENGTH_DOWNLOAD_T`
identifiers are `enum`s, not pre-processor definitions, so the current
`#ifdef` logic is not selecting the newer API.  This results in the
older identifiers being used and they now generate errors when compiled
against Curl 7.87, which has silently deprecated them, causing GCC to
emit `-Werror=deprecated-declarations`.

Instead, the newer identifiers were added in Curl 7.55, so explicitly
check for `CURL_AT_LEAST_VERSION(7, 55, 0)` instead of the current
logic.  This eliminates the error when compiling against Curl 7.87.

Ref: https://github.com/curl/curl/pull/1511
Comment 2 Frank Ch. Eigler 2022-12-21 16:39:59 UTC
Thanks, merged!
Comment 3 Ross Burton 2023-01-06 15:53:19 UTC
I can't reopen this but I'm still seeing errors:

elfutils-0.188/debuginfod/debuginfod-client.c:1330:7: error: ‘CURLOPT_PROTOCOLS’ is deprecated: since 7.85.0. Use CURLOPT_PROTOCOLS_STR [-Werror=deprecated-declarations]
  1330 |       curl_easy_setopt_ck(data[i].handle, CURLOPT_PROTOCOLS,
       |       ^~~~~~~~~~~~~~~~~~~

CURLOPT_PROTOCOLS was deprecated in 7.85.0 and the replacement CURLOPT_PROTOCOLS_STR introduced in 7.85.0.

May I suggest building without fatal deprecation warnings by default?
Comment 4 Mark Wielaard 2023-01-10 22:23:44 UTC
Does the following work for you?

diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index a16165bd..1ce45632 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -1336,8 +1336,13 @@ debuginfod_query_server (debuginfod_client *c,
 
       /* Only allow http:// + https:// + file:// so we aren't being
         redirected to some unsupported protocol.  */
+#if CURL_AT_LEAST_VERSION(7, 85, 0)
+      curl_easy_setopt_ck(data[i].handle, CURLOPT_PROTOCOLS_STR,
+                         "http,https,file");
+#else
       curl_easy_setopt_ck(data[i].handle, CURLOPT_PROTOCOLS,
                          (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FILE));
+#endif
       curl_easy_setopt_ck(data[i].handle, CURLOPT_URL, data[i].url);
       if (vfd >= 0)
        curl_easy_setopt_ck(data[i].handle, CURLOPT_ERRORBUFFER,

https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=protocols_str
Comment 5 Mark Wielaard 2023-01-11 14:17:03 UTC
Sorry, pushed this slightly too early. But the try bots seemed happy.
Please feel free to loudly complain if this not actually solved your issue.

commit 6560fb26a62ef135a804357ef4f15a47de3e49b3
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Jan 10 23:20:41 2023 +0100

    debuginfod-client: Use CURLOPT_PROTOCOLS_STR for libcurl >= 7.85.0
    
    https://sourceware.org/bugzilla/show_bug.cgi?id=29926
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>