Skip to content

Certain modern Linux hosts will fail to build due to sys/sysctl.h deprecation #2

@ardnew

Description

@ardnew

Been trying for a couple hours hunting down where a particular define gets introduced that is forcing a preprocessor conditional to immediately halt the build as as failure. I'll try to keep this brief.

Currently, with no modification to source code or Makefile, building openocd errors out with:

In file included from src/helper/options.c:38:
/usr/include/x86_64-linux-gnu/sys/sysctl.h:21:2: error: #warning "The <sys/sysctl.h> header is deprecated and will be removed." [-Werror=cpp]
21 | #warning "The <sys/sysctl.h> header is deprecated and will be removed."
|  ^~~~~~~
cc1: all warnings being treated as errors

That particular line it mentions causing the error is because we have #include <sys/sysctl.h>, which is where the deprecation warning ultimately appears..

Doing some cursory Google research, I've found others with similar problems. They conditionally #include <sys/sysctl,h> only if HAVE_SYSCONF is NOT true,

The problem is, at least for Ubuntu, probably others in the very near future, the openocd project isn't including the necessary files that would export that HAVE_SYSCONF macro. And I am not familiar enough with the project to understand the requirements for using sys/sysctl.h, or what it would take to replace it.

In any case, the obvious workaround for now is to disable -Werror, and pray

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions