dev-util/oprofile: fix build on clang & libcxx

Closes: https://bugs.gentoo.org/983194
Closes: https://bugs.gentoo.org/953413
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
Part-of: https://codeberg.org/gentoo/gentoo/pulls/2418
Merges: https://codeberg.org/gentoo/gentoo/pulls/2418
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Z. Liu
2026-11-15 05:57:18 +00:00
committed by Sam James
parent 2c4ae84a9b
commit c2a08af028
3 changed files with 294 additions and 0 deletions
@@ -0,0 +1,95 @@
From fd491083573cf8384f83950041825ebc3f34d719 Mon Sep 17 00:00:00 2001
From: "Z. Liu" <zhixu.liu@gmail.com>
Date: Sat, 14 Nov 2026 17:04:19 +0800
Subject: [PATCH] bfd_boolean is removed since binutils 2.47
> opagent.c:81:2: error: use of undeclared identifier 'bfd_boolean'
> 81 | bfd_boolean r;
> | ^~~~~~~~~~~
> opagent.c:106:2: error: use of undeclared identifier 'r'
> 106 | r = bfd_check_format(bfd, bfd_object);
> | ^
> opagent.c:107:7: error: use of undeclared identifier 'r'
> 107 | if (!r) {
> | ^
> opagent.c:111:19: warning: assigning to 'char *' from 'const char *const' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
> 111 | _bfd_target_name = bfd->xvec->name;
> | ^ ~~~~~~~~~~~~~~~
Define a bfd_boolean fallback so older binutils keep working, make
_bfd_target_name const, and use false from stdbool.h.
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
diff --git a/libopagent/opagent.c b/libopagent/opagent.c
index f280880c..146d2e05 100644
--- a/libopagent/opagent.c
+++ b/libopagent/opagent.c
@@ -69,8 +69,13 @@
#include "op_config.h"
#include "jitdump.h"
+// bfd_boolean and the TRUE/FALSE macros were removed from bfd.h
+#ifndef bfd_boolean
+typedef bool bfd_boolean;
+#endif
+
// Declare BFD-related global variables.
-static char * _bfd_target_name;
+static const char * _bfd_target_name;
static int _bfd_arch;
static unsigned int _bfd_mach;
diff --git a/opjitconv/create_bfd.c b/opjitconv/create_bfd.c
index da1e6d29..18b7d3d9 100644
--- a/opjitconv/create_bfd.c
+++ b/opjitconv/create_bfd.c
@@ -65,7 +65,7 @@ static int fill_symtab(void)
syms[i] = s;
}
r = bfd_set_symtab(cur_bfd, syms, entry_count);
- if (r == FALSE) {
+ if (r == false) {
bfd_perror("bfd_set_symtab");
rc = OP_JIT_CONV_FAIL;
}
@@ -88,11 +88,11 @@ asection * create_section(bfd * abfd, char const * section_name,
goto error;
}
op_bfd_set_section_vma(abfd, section, vma);
- if (op_bfd_set_section_size(abfd, section, size) == FALSE) {
+ if (op_bfd_set_section_size(abfd, section, size) == false) {
bfd_perror("bfd_set_section_size");
goto error;
}
- if (op_bfd_set_section_flags(abfd, section, flags) == FALSE) {
+ if (op_bfd_set_section_flags(abfd, section, flags) == false) {
bfd_perror("bfd_set_section_flags");
goto error;
}
@@ -134,7 +134,7 @@ static int create_text_section(int start_idx, int end_idx)
int fill_section_content(bfd * abfd, asection * section,
void const * b, file_ptr offset, size_t sz)
{
- if (bfd_set_section_contents(abfd, section, b, offset, sz) == FALSE) {
+ if (bfd_set_section_contents(abfd, section, b, offset, sz) == false) {
bfd_perror("bfd_set_section_contents");
return OP_JIT_CONV_FAIL;
}
@@ -257,11 +257,11 @@ bfd * open_elf(char const * filename)
bfd_perror("bfd_openw");
goto error1;
}
- if (bfd_set_format(abfd, bfd_object) == FALSE) {
+ if (bfd_set_format(abfd, bfd_object) == false) {
bfd_perror("bfd_set_format");
goto error;
}
- if (bfd_set_arch_mach(abfd, dump_bfd_arch, dump_bfd_mach) == FALSE) {
+ if (bfd_set_arch_mach(abfd, dump_bfd_arch, dump_bfd_mach) == false) {
bfd_perror("bfd_set_arch_mach");
goto error;
}
--
2.49.1
+101
View File
@@ -0,0 +1,101 @@
From 465dbb2fa4927d3249fdf7a9b577e782881a09d4 Mon Sep 17 00:00:00 2001
From: "Z. Liu" <zhixu.liu@gmail.com>
Date: Sat, 14 Nov 2026 21:34:17 +0800
Subject: [PATCH] remove unavailable feature in C++ 17+
* replace std::bind2nd with lambda
* std::vector::const_iterator cannot be constructed from
a null pointer. Use a default-constructed iterator instead.
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
diff --git a/libpp/xml_utils.cpp b/libpp/xml_utils.cpp
index 3de41e58..ba05daea 100644
--- a/libpp/xml_utils.cpp
+++ b/libpp/xml_utils.cpp
@@ -73,7 +73,7 @@ void dump_symbol(string const & prefix, sym_iterator it, bool want_nl = true)
void dump_symbols(string const & prefix, sym_iterator b, sym_iterator e)
{
- if (b == (sym_iterator)0)
+ if (b == sym_iterator())
return;
for (sym_iterator it = b; it != e; ++it)
@@ -406,7 +406,7 @@ xml_utils::output_summary_data(ostream & out, count_array_t const & summary, siz
class module_info {
public:
module_info()
- { lo = hi = 0; name = ""; begin = end = (sym_iterator)0;}
+ { lo = hi = 0; name = ""; begin = end = sym_iterator();}
void dump();
void build_module(string const & n, sym_iterator it,
size_t l, size_t h);
@@ -540,21 +540,21 @@ void module_info::add_to_summary(count_array_t const & counts)
void module_info::set_begin(sym_iterator b)
{
- if (begin == (sym_iterator)0)
+ if (begin == sym_iterator())
begin = b;
}
void module_info::set_end(sym_iterator e)
{
- if (end == (sym_iterator)0)
+ if (end == sym_iterator())
end = e;
}
bool module_info::is_closed(string const & n)
{
- return (name == n) && end != (sym_iterator)0;
+ return (name == n) && end != sym_iterator();
}
@@ -585,7 +585,7 @@ void module_info::output_summary(ostream & out)
void module_info::output_symbols(ostream & out, bool is_module)
{
- if (begin == (sym_iterator)0)
+ if (begin == sym_iterator())
return;
for (sym_iterator it = begin; it != end; ++it)
@@ -606,7 +606,7 @@ void binary_info::close_binary(sym_iterator it)
void binary_info::dump()
{
cverb << vxml << "app_name=" << name << endl;
- if (begin != (sym_iterator)0)
+ if (begin != sym_iterator())
dump_symbols(" ", begin, end);
for (size_t i = 0; i < nr_modules; ++i)
@@ -648,7 +648,7 @@ add_module_symbol(string const & module, string const & app,
// mark end of enclosing binary symbols if there have been any
// NOTE: it is possible for the binary's symbols to follow its
// module symbols
- if (begin != (sym_iterator)0 && end == (sym_iterator)0)
+ if (begin != sym_iterator() && end == sym_iterator())
set_end(it);
// build the new module
diff --git a/libutil++/growable_vector.h b/libutil++/growable_vector.h
index 350246a9..877d7e3d 100644
--- a/libutil++/growable_vector.h
+++ b/libutil++/growable_vector.h
@@ -94,7 +94,7 @@ public:
/// return true if all elements have the default constructed value
bool zero() const {
return std::find_if(container.begin(), container.end(),
- std::bind2nd(std::not_equal_to<T>(), T()))
+ [](T const & v) { return v != T(); })
== container.end();
}
--
2.49.1
@@ -0,0 +1,98 @@
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit autotools java-pkg-opt-2 linux-info
DESCRIPTION="A transparent low-overhead system-wide profiler"
HOMEPAGE="https://oprofile.sourceforge.io/news/"
SRC_URI="https://downloads.sourceforge.net/project/oprofile/oprofile/${P}/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~sparc ~x86"
IUSE="apidoc java pch static-libs"
BDEPEND="
apidoc? ( app-text/doxygen[dot] )
"
CDEPEND="
>=dev-libs/popt-1.7-r1
sys-libs/binutils-libs:=
elibc_glibc? ( >=sys-libs/glibc-2.3.2-r1 )
ppc64? ( dev-libs/libpfm )
"
DEPEND="${CDEPEND}
>=sys-kernel/linux-headers-2.6.31
java? ( >=virtual/jdk-1.8:* )
"
RDEPEND="${CDEPEND}
acct-user/oprofile
acct-group/oprofile
java? ( >=virtual/jre-1.8:* )
"
CONFIG_CHECK="~PERF_EVENTS"
ERROR_PERF_EVENTS="CONFIG_PERF_EVENTS is mandatory for ${PN} to work."
PATCHES=(
"${FILESDIR}/musl.patch"
"${FILESDIR}/gcc12.patch"
"${FILESDIR}/config-implicit.patch"
"${FILESDIR}/binutils-2.47.patch"
"${FILESDIR}/libcxx.patch"
)
pkg_setup() {
linux-info_pkg_setup
if ! kernel_is -ge 2 6 31; then
echo
ewarn "Support for kernels before 2.6.31 has been dropped in ${PN}-1.0.0."
echo
fi
use java && java-pkg-opt-2_pkg_setup
}
src_prepare() {
default
# bug 723092
sed -i 's/==/=/g' configure.ac || die
java-pkg-opt-2_src_prepare
eautoreconf
}
src_configure() {
local jh=""
use java && jh="$(java-config -O)"
econf \
--disable-werror \
$(use_enable pch) \
$(use_with java java "${jh}")
}
src_compile() {
default
use apidoc && emake -C doc/srcdoc
}
src_install() {
emake DESTDIR="${D}" htmldir="/usr/share/doc/${PF}" install
use static-libs || rm "${ED}"/usr/$(get_libdir)/${PN}/*.{a,la}
use apidoc && dodoc -r doc/srcdoc/html
dodoc ChangeLog* README TODO
echo "LDPATH=${PREFIX}/usr/$(get_libdir)/${PN}" > "${T}/10${PN}" || die
doenvd "${T}/10${PN}"
}
pkg_postinst() {
echo
elog "Starting from ${PN}-1.0.0 opcontrol was removed, use operf instead."
elog "CONFIG_OPROFILE is no longer used, you may remove it from your kernels."
elog "Please read manpages and this html doc:"
elog " /usr/share/doc/${PF}/${PN}.html"
echo
}