On 29 December 2015 at 12:14, Kevin Darbyshire-Bryant <[email protected]> wrote: > Enable linux perf tools to compile under musl. > > Tested on MIPS Archer c7 v2 & ARM Linksys 1200ac. > > With thanks to Dave Taht <[email protected]> who > did the heavy lifting. > > Signed-off-by: Kevin Darbyshire-Bryant <[email protected]> > --- > package/devel/perf/Makefile | 2 +- > .../patches-4.1/280-perf-fixes-for-musl.patch | 148 > +++++++++++++++++++++ > .../patches-4.4/280-perf-fixes-for-musl.patch | 147 ++++++++++++++++++++ > 3 files changed, 296 insertions(+), 1 deletion(-) > create mode 100644 > target/linux/generic/patches-4.1/280-perf-fixes-for-musl.patch > create mode 100644 > target/linux/generic/patches-4.4/280-perf-fixes-for-musl.patch > > diff --git a/package/devel/perf/Makefile b/package/devel/perf/Makefile > index 5e3d63f..46ddb92 100644 > --- a/package/devel/perf/Makefile > +++ b/package/devel/perf/Makefile > @@ -19,7 +19,7 @@ include $(INCLUDE_DIR)/package.mk > define Package/perf > SECTION:=devel > CATEGORY:=Development > - DEPENDS:= @USE_GLIBC +libelf1 +libdw +libpthread +librt +binutils > + DEPENDS:= @USE_MUSL +libelf1 +libdw +libpthread +librt +binutils > TITLE:=Linux performance monitoring tool > VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE) > URL:=http://www.kernel.org > diff --git a/target/linux/generic/patches-4.1/280-perf-fixes-for-musl.patch > b/target/linux/generic/patches-4.1/280-perf-fixes-for-musl.patch > new file mode 100644 > index 0000000..0e8b6d8 > --- /dev/null > +++ b/target/linux/generic/patches-4.1/280-perf-fixes-for-musl.patch > @@ -0,0 +1,148 @@ > +kernel: 4.1 perf: musl compatibility > + > +Allow linux perf tool to compile under musl. > + > +Backport to 4.1 by Kevin D-B with thanks to Dave > +Taht <[email protected]> for the heavy lifting. > + > +Signed-off-by: Kevin Darbyshire-Bryant <[email protected]> > + > +--- > + tools/lib/api/fs/debugfs.c | 4 ++++ > + tools/lib/traceevent/event-parse.c | 4 ++++ > + tools/perf/perf.c | 17 ++++++++++++++++- > + tools/perf/util/cache.h | 2 +- > + tools/perf/util/cloexec.c | 4 ---- > + tools/perf/util/cloexec.h | 4 ---- > + tools/perf/util/util.h | 4 ++++ > + 7 files changed, 29 insertions(+), 10 deletions(-) > + > +diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c > +index 8305b3e..5d1745c 100644 > +--- a/tools/lib/api/fs/debugfs.c > ++++ b/tools/lib/api/fs/debugfs.c > +@@ -17,6 +17,10 @@ > + #define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug" > + #endif > + > ++/* musl has a xpg compliant strerror_r by default */ > ++#define strerror_r(err, buf, buflen) \ > ++ (strerror_r(err, buf, buflen) ? NULL : buf) > ++ > + char debugfs_mountpoint[PATH_MAX + 1] = DEBUGFS_DEFAULT_PATH; > + > + static const char * const debugfs_known_mountpoints[] = { > +diff --git a/tools/lib/traceevent/event-parse.c > b/tools/lib/traceevent/event-parse.c > +index ed5461f..f151369 100644 > +--- a/tools/lib/traceevent/event-parse.c > ++++ b/tools/lib/traceevent/event-parse.c > +@@ -36,6 +36,10 @@ > + #include "event-parse.h" > + #include "event-utils.h" > + > ++/* musl has a xpg compliant strerror_r by default */ > ++#define strerror_r(err, buf, buflen) \ > ++ (strerror_r(err, buf, buflen) ? NULL : buf) > ++ > + static const char *input_buf; > + static unsigned long long input_buf_ptr; > + static unsigned long long input_buf_siz; > +diff --git a/tools/perf/perf.c b/tools/perf/perf.c > +index b857fcb..3e67fa2 100644 > +--- a/tools/perf/perf.c > ++++ b/tools/perf/perf.c > +@@ -505,6 +505,21 @@ void pthread__unblock_sigwinch(void) > + pthread_sigmask(SIG_UNBLOCK, &set, NULL); > + } > + > ++unsigned cache_line_size(void); > ++ > ++unsigned cache_line_size(void) { > ++ FILE * p = 0; > ++ unsigned int i = 0; > ++ p = > fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r"); > ++ if (p) { > ++ if(fscanf(p, "%d", &i) != 1) { > ++ perror("cannot determine cache line size"); > ++ } > ++ fclose(p); > ++ } > ++ return i; > ++} > ++
Kevin, are you sure this works? I don't have /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size on my Archer C7 I did a little bit more simple way adding a header from eglibc. If anybody interested I can submit the patch for RFC. Regards, Roman _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
