pmc/display.cc gets std:sort via header pollution; it could use an include of <algorithm>; pmc/view.hh:198:2: error: unknown type name 'cpuset_t'; . . . (less obvious but headers again) . . .

Mark Millard <[email protected]> Fri, 31 Jul 2026 18:04:11 -0700
Newsgroups gmane.os.freebsd.current
Message-ID <[email protected]>
Note: /usr/main-src is a worktree for main's src. It is as of:

# ~/fbsd-based-on-what-commit.sh -C /usr/main-src/
21bc31ce2e4a (HEAD -> main, freebsd/main, freebsd/HEAD) acpi: parse
resources of not-present devices that are kept enabled
Author:     Abdelkader Boudih <[email protected]>
Commit:     Adrian Chadd <[email protected]>
CommitDate: 2026-07-31 21:26:08 +0000
branch: main
merge-base: 21bc31ce2e4a7106ec352c9e30fc6d948b881653
merge-base: CommitDate: 2026-07-31 21:26:08 +0000
n287870 (--first-parent --count for merge-base)


With -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES in use . . .


usr.sbin/pmc/display.cc :

/usr/main-src/usr.sbin/pmc/display.cc:505:3: error: no member named
'sort' in namespace 'std'; did you mean simply 'sort'?
  505 |                 std::sort(rows.begin(), rows.end(), [col](auto
&a, auto &b)
      |                 ^~~~~~~~~
      |                 sort
/usr/main-src/usr.sbin/pmc/display.cc:500:8: note: 'sort' declared here
  500 | table::sort(int col, bool descending)
      |        ^
/usr/main-src/usr.sbin/pmc/display.cc:505:39: error: too many arguments
to function call, expected at most 2, have 3
  505 |                 std::sort(rows.begin(), rows.end(), [col](auto
&a, auto &b)
      |                 ~~~~~~~~~
^~~~~~~~~~~~~~~~~~~~~~~
  506 |                     { return (a[col] > b[col]); });
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/main-src/usr.sbin/pmc/display.cc:500:8: note: 'sort' declared here
  500 | table::sort(int col, bool descending)
      |        ^    ~~~~~~~~~~~~~~~~~~~~~~~~
. . .
/usr/main-src/usr.sbin/pmc/display.cc:508:3: error: no member named
'sort' in namespace 'std'; did you mean simply 'sort'?
  508 |                 std::sort(rows.begin(), rows.end(), [col](auto
&a, auto &b)
      |                 ^~~~~~~~~
      |                 sort
/usr/main-src/usr.sbin/pmc/display.cc:500:8: note: 'sort' declared here
  500 | table::sort(int col, bool descending)
      |        ^
. . .
  508 |                 std::sort(rows.begin(), rows.end(), [col](auto
&a, auto &b)
      |                 ~~~~~~~~~
^~~~~~~~~~~~~~~~~~~~~~~
  509 |                     { return (a[col] < b[col]); });
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/main-src/usr.sbin/pmc/display.cc:500:8: note: 'sort' declared here
  500 | table::sort(int col, bool descending)
      |        ^    ~~~~~~~~~~~~~~~~~~~~~~~~


usr.sbin/pmc/view.hh :

In file included from /usr/main-src/usr.sbin/pmc/view.cc:56:
/usr/main-src/usr.sbin/pmc/view.hh:198:2: error: unknown type name
'cpuset_t'
  198 |         cpuset_t                        cpus;
      |         ^

In file included from /usr/main-src/usr.sbin/pmc/view.cc:56:
/usr/main-src/usr.sbin/pmc/view.hh:185:35: error: use of undeclared
identifier 'CPU_ZERO'
  185 |             ibs_ldlat(0), ibs_oplat(0) { CPU_ZERO(&cpus); }
      |                                          ^~~~~~~~
/usr/main-src/usr.sbin/pmc/view.hh:229:7: error: use of undeclared
identifier 'cpuset_parselist'


/usr/main-src/usr.sbin/pmc/view.hh:405:7: error: no template named
'vector' in namespace 'std'
Building
/usr/obj/BUILDs/main-ZNV4-nodbg-clang/usr/main-src/amd64.amd64/libexec/rtld-elf32/ld-elf32.so.1
  405 |         std::vector<pmcinfox>                   extpmcinfo;
      |         ~~~~~^


In file included from /usr/main-src/usr.sbin/pmc/view.cc:56:
/usr/main-src/usr.sbin/pmc/view.hh:232:7: error: use of undeclared
identifier 'cpuset_parselist'
  232 |                 if (cpuset_parselist(ids, &cpus) == CPUSET_PARSE_OK)
      |                     ^~~~~~~~~~~~~~~~

/usr/main-src/usr.sbin/pmc/view.hh:232:39: error: use of undeclared
identifier 'CPUSET_PARSE_OK'
  232 |                 if (cpuset_parselist(ids, &cpus) == CPUSET_PARSE_OK)
      |                                                     ^~~~~~~~~~~~~~~


For reference, quick hacks to avoid such:

diff --git a/usr.sbin/pmc/display.cc b/usr.sbin/pmc/display.cc
index 454cb74e29bd..55579acd4717 100644
--- a/usr.sbin/pmc/display.cc
+++ b/usr.sbin/pmc/display.cc
@@ -42,6 +42,7 @@
 #include <unistd.h>

 #include <cxxabi.h>
+#include <algorithm>
 #include <iomanip>
 #include <ios>
 #include <iostream>
diff --git a/usr.sbin/pmc/view.hh b/usr.sbin/pmc/view.hh
index 062325b096dc..540ed8157de1 100644
--- a/usr.sbin/pmc/view.hh
+++ b/usr.sbin/pmc/view.hh
@@ -31,6 +31,9 @@
 #ifndef __VIEW_HH__
 #define __VIEW_HH__

+#include <sys/_cpuset.h>
+#include <sys/cpuset.h>
+
 #include <libdwarf.h>
 #include <libelf.h>
 #include <libutil.h>
@@ -39,6 +42,8 @@
 #include "headers.hh"
 #include "util.hh"

+#include <vector>
+
 /*
  * PMC counter state.
  */


-- 
===
Mark Millard
marklmi at yahoo.com