Skip to content

./bench/nanobench.h:2492:25: error: ‘PERF_EVENT_IOC_ID’ was not declared in this scope #21549

Closed
@luke-jr

Description

@luke-jr

Expected behavior

Either configure to disable bench-bitcoin, or the build to succeed.

Actual behavior

Build fails with:

In file included from bench/nanobench.cpp:6:
./bench/nanobench.h: In member function ‘bool ankerl::nanobench::detail::LinuxPerformanceCounters::monitor(uint32_t, uint64_t, ankerl::nanobench::detail::LinuxPerformanceCounters::Target)’:
./bench/nanobench.h:2492:25: error: ‘PERF_EVENT_IOC_ID’ was not declared in this scope; did you mean ‘PERF_EVENT_IOC_PERIOD’?
 2492 |     if (-1 == ioctl(fd, PERF_EVENT_IOC_ID, &id)) {
      |                         ^~~~~~~~~~~~~~~~~
      |                         PERF_EVENT_IOC_PERIOD
./bench/nanobench.h: In constructor ‘ankerl::nanobench::detail::PerformanceCounters::PerformanceCounters()’:
./bench/nanobench.h:2515:35: error: ‘PERF_COUNT_HW_REF_CPU_CYCLES’ was not declared in this scope; did you mean ‘PERF_COUNT_HW_CPU_CYCLES’?
 2515 |     mHas.cpuCycles = mPc->monitor(PERF_COUNT_HW_REF_CPU_CYCLES, LinuxPerformanceCounters::Target(&mVal.cpuCycles, true, false));
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                   PERF_COUNT_HW_CPU_CYCLES

To reproduce

Install old linux-headers without PERF_EVENT_IOC_ID

System information

This error discovered building on an otherwise-up-to-date system with linux-headers 2.6.32.

Activity

fanquake

fanquake commented on Mar 30, 2021

@fanquake
Member

@martinus do you have any input here? Is supporting older Linux headers something you'd even want to, or can do in https://github.com/martinus/nanobench?

martinus

martinus commented on Mar 30, 2021

@martinus
Contributor

Hi, I can fix this in the next nanobench release, I'll add a check for the required events, and if they are not there I'll disable the feature.

Currently I have a define ANKERL_NANOBENCH_DISABLE_PERF_COUNTERS, and if it is true the whole perf counter stuff is disabled. So if this is somehow defined for the build it should already compile.

martinus

martinus commented on Sep 21, 2021

@martinus
Contributor

I think that bug had been fixed in #22082 and can be closed.

locked and limited conversation to collaborators on Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      ./bench/nanobench.h:2492:25: error: ‘PERF_EVENT_IOC_ID’ was not declared in this scope · Issue #21549 · bitcoin/bitcoin