From patchwork Tue Dec 29 10:14:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Darbyshire-Bryant X-Patchwork-Id: 561519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9177D140C51 for ; Tue, 29 Dec 2015 21:15:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=DarbyshireBryant.onmicrosoft.com header.i=@DarbyshireBryant.onmicrosoft.com header.b=CsPAblxj; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 2794028BE5F; Tue, 29 Dec 2015 11:14:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 7E6F028B9A9 for ; Tue, 29 Dec 2015 11:14:41 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 HELO_IP_IN_CL_SUBNET=-1.2 (check from: .darbyshire-bryant. - helo: .emea01-am1-obe.outbound.protection.outlook. - helo-domain: .outlook.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7.7 Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1on0056.outbound.protection.outlook.com [157.56.112.56]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Tue, 29 Dec 2015 11:14:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=DarbyshireBryant.onmicrosoft.com; s=selector1-darbyshirebryant-me-uk02e; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Odu1CUdaA0v6tmqsRzVD9jGc+n+n/FUqXooeWwnYqDQ=; b=CsPAblxjW5bZujgAeHeqQByGQUhsDR4uoQdGncksgofBXVAvYFhbXXWKaZV7e7lcrw/DaV+OvIrVoU+f3r7wtOeFY4yndKfgHUgR0MBhfz3nB6PU5ncVH3bZRuf5D7f/pLzAdCW4t14CNdRKltk73Qp8jaIZD4tSOiWPJK+HEx8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kevin@darbyshire-bryant.me.uk; Received: from Animal.darbyshire-bryant.me.uk (188.221.218.142) by VI1PR07MB0943.eurprd07.prod.outlook.com (10.161.110.148) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 29 Dec 2015 10:15:01 +0000 From: Kevin Darbyshire-Bryant To: Date: Tue, 29 Dec 2015 10:14:44 +0000 Message-ID: <1451384084-5093-1-git-send-email-kevin@darbyshire-bryant.me.uk> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [188.221.218.142] X-ClientProxiedBy: AM3PR04CA0013.eurprd04.prod.outlook.com (10.242.16.13) To VI1PR07MB0943.eurprd07.prod.outlook.com (25.161.110.148) X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB0943; 2:bga2hbWfknU7r/9mVRWFVgwnjUJ99I8NWSdGIcM5Bsgrt/E1rZzcXLTMdCp5LriWzG49V8vFEXJ/ACCP3dNA5ncUEnzPgliyAdXL9eHVBbFqvHEZ8CoKjhSxbJiWveHr+A1kAVC7qpDMoHi8v6zLDg==; 3:vJ3BTXbT4k1GGodPvl8usaKZdIw6S+S688qVngzDxUeGT/hR24DDvl7rKWddba3cQ8Z38MaxHzuKZTFSOqzoKcmhO329yH4KXsBVgZiTEzGLneJo7rw1s9eu6u4Pa+Ir; 25:2zkOZN8ZmNfveSBZTKIvLhsKnwTMzqQPATcKP4jbm5Un7BZebVZ8UFtw4OrYgLuzRZT9b8n+V1b7+guP5z4pcsGj1YBqnqys0MD38RNdDaBfVJeqxDie70iaM6kXJCG0hYYP1iwRL2Q2joR0lj7CkAJBS7YIexJVftHbxPXuZKIsSlEvRV1XLCTqA6TPTPoi/yCtMpzRB4qiUcfDBrO9O16EGcjlivsLRq5JuEP5rBIttJVEUY+W7dvd1+fAqNLwjMlstd0fcS1NOk/dXwe8Yg==; 4:xObelYwih0bU5y/tFPKxkTf67QMr5Hsiy6dg9+tpVbhIKSdQCSykyrzB5+/UADOZ0tVXXGwutFDHTCzeIEizjZsuDm9EqGMhC2pJuZibZ229yXsxC9ajHKg8nMiGHJX7HewakbBLXnmJ9DOpM6EJ+FE/fDfrCpsYq9IO/FCktH5BKgIr7rjJGRMX4HMw47AmLQslSXAOfq5qQ8t13FiPI1uaqRa2Wl8lKMD1HNKInvD488OR8UivPN833x4idUje0MnGUrObusnrrTarzqXaGDvU21qFRKtPUM9CFHUE/kpLag5mh28wrQaLRYHnZR2WU2Sqqc6HTDrphldc+B13C9tG9hgKmAcAHInkwdWDusX9NnCiq5EIgVU0FgMgd0an X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR07MB0943; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046); SRVR:VI1PR07MB0943; BCL:0; PCL:0; RULEID:; SRVR:VI1PR07MB0943; X-Forefront-PRVS: 0805EC9467 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(1096002)(87976001)(74482002)(189998001)(16601075003)(69596002)(122386002)(40100003)(450100001)(106356001)(105586002)(81156007)(19580395003)(50226001)(586003)(4001430100002)(97736004)(19580405001)(5008740100001)(48376002)(5004730100002)(50466002)(53416004)(5003940100001)(229853001)(3846002)(101416001)(6116002)(66066001)(36756003)(50986999)(107886002)(5001960100002)(77096005)(86362001)(92566002)(110136002)(15975445007)(33646002)(575784001)(42186005)(2351001)(47776003)(41533002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR07MB0943; H:Animal.darbyshire-bryant.me.uk; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: darbyshire-bryant.me.uk does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR07MB0943; 23:jokVvpSNuez/7ds5bQ1QPzOLq9AcPEqWaQ2yM36np?= =?us-ascii?Q?+0Ux2Z6Jjdk3Eikj82UfIQlCa0eFfqMr6FsSDQ8BYvwhb6RNQHe8BwD3Pp/W?= =?us-ascii?Q?Kf7TX0q8b+NSFOfiE+nyuTKFlLNBciMzH5PaCAE8GGEIlmX6qr4ErUpzFWEL?= =?us-ascii?Q?AO0by3r8CTAtFfp6ZckBBvpiiyl5ayE+OTZ9Qpcw5Aoggkqa6tcOZv8H7/+h?= =?us-ascii?Q?dJaBRP5RVjnKN6ufrlWAJsHhsmXttq8Lqm3to1BYpYZoXIwrw1OeAlEYFHZn?= =?us-ascii?Q?i9LfpzIo7D3x6C13ntyfEujWQLuw1kHCtiwR3xoTVj/aNMJ27q9OA0erdVo5?= =?us-ascii?Q?8dTp/t8oFZulpfWsNJXphr3p49yheLkJaG80MOiEJAOHTy75tMo9pz3FuXY9?= =?us-ascii?Q?mGHdMamXW6MDQkqlGlvxuiFVsA/+bdzEof0cZJ3Q7of3OtIg3AijvxJKcg/g?= =?us-ascii?Q?TCvvsdxSgALpG2zMh3WYEwNDT6TaFL16yLtdEST3/aRIxLl3RtJ08CZuzX7Q?= =?us-ascii?Q?l+T0YC6gzanCE5E9elyYSEF9EeM0QDYDdXqs2ozPNCih1K7XFal+GlqtdZt7?= =?us-ascii?Q?VjPVLtV/glXf3ADcw0b/X3GkaPZTEHs6vILSnXHM2YHkXn6fIL2INnTe/RPq?= =?us-ascii?Q?LBuHz3JhAclDAFK2oJ84PwyVJgnop3MLpZ27eIz5Xw5XElHNkzW9Mh14pIy8?= =?us-ascii?Q?rPhVe4hJ06rothW+8DAgzXvM78EkbY7ZsdGCyYdEXPbS34I9ULAHbbKu0X7/?= =?us-ascii?Q?70QMyOHotJst6Abz4dIoec0fqGv8d/gKUhwKbsZ9ULpXAcqesavnO0o4WEBE?= =?us-ascii?Q?QXfBqvnIUF1qw0JG8HPUFBZxedFRPlmasnBd156vtX076zX0MUapsfM4Jjh8?= =?us-ascii?Q?xZ0JF1L49nPvhPQRRX4rfU4cKf13viSKZ3FVuWzkuWsLZUSVhyTMxUBZHEcQ?= =?us-ascii?Q?SoJiMWz6LcCjBEvKChJlgZK4oYtnl9fNba2jcswrlsxPJAds4WYsQmyLEzrw?= =?us-ascii?Q?Nx/Vw5GFktLHfHABns0a02y1BsprRO4iDDSXrVfyHE+RdalnnZ1OxZ2+HQv0?= =?us-ascii?Q?bRxroqk/3miD1u3nU82MZFLr1v7ZlA/cd3yAMmiKCRviygg88MPNH1z69A87?= =?us-ascii?Q?xGweiIuJZQnazlM6eZomRVGX4zJPQMulAogLTvto0Acav97KKCQd9Kp5RqEF?= =?us-ascii?Q?vEWydq9tQNZFO+lTAZmrlkzTEd1SU5fDfaY1SUqdwMOwl+HCPNVvS93yA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB0943; 5:IJjU9ivNr5pb0nuBbmbXnQJLBvLchzWs3PS2ImelGE+Zc3Js8ePzusNfXYayX4WVm9gl1PiRsFdAQ3nlqHjjJ9Ln9rkcmKKLx3kdA9hSTyOWjsUj9Iuq6z3+0fJ2d+ln1RhtQTFEBmPNHO2vZl1nUA==; 24:A1BFjrC8AIWQTKSJtxjhJFTaD78dGkg6zyb4cLYottpV9JBkIsIxtr8R6/GvqjRSToggE8q4jyh9UBKpAO6SI77L11vRsEsrRZDS1P47Z3Q= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: darbyshire-bryant.me.uk X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Dec 2015 10:15:01.8411 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB0943 Subject: [OpenWrt-Devel] [PATCH] kernel: generic 4.1 & 4.4 perf: musl compatibility X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Enable linux perf tools to compile under musl. Tested on MIPS Archer c7 v2 & ARM Linksys 1200ac. With thanks to Dave Taht who did the heavy lifting. Signed-off-by: Kevin Darbyshire-Bryant --- 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 for the heavy lifting. + +Signed-off-by: Kevin Darbyshire-Bryant + +--- + 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; ++} ++ + int main(int argc, const char **argv) + { + const char *cmd; +@@ -512,7 +527,7 @@ int main(int argc, const char **argv) + + /* The page_size is placed in util object. */ + page_size = sysconf(_SC_PAGE_SIZE); +- cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); ++ cacheline_size = cache_line_size(); + + cmd = perf_extract_argv0_path(argv[0]); + if (!cmd) +diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h +index fbcca21..9b23c4a 100644 +--- a/tools/perf/util/cache.h ++++ b/tools/perf/util/cache.h +@@ -72,7 +72,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2 + extern char *perf_pathdup(const char *fmt, ...) + __attribute__((format (printf, 1, 2))); + +-#ifndef __UCLIBC__ ++#if !defined(__UCLIBC__) && defined(__GLIBC__) + /* Matches the libc/libbsd function attribute so we declare this unconditionally: */ + extern size_t strlcpy(char *dest, const char *src, size_t size); + #endif +diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c +index 2babdda..85b5238 100644 +--- a/tools/perf/util/cloexec.c ++++ b/tools/perf/util/cloexec.c +@@ -7,15 +7,11 @@ + + static unsigned long flag = PERF_FLAG_FD_CLOEXEC; + +-#ifdef __GLIBC_PREREQ +-#if !__GLIBC_PREREQ(2, 6) + int __weak sched_getcpu(void) + { + errno = ENOSYS; + return -1; + } +-#endif +-#endif + + static int perf_flag_probe(void) + { +diff --git a/tools/perf/util/cloexec.h b/tools/perf/util/cloexec.h +index 68888c2..06904bc 100644 +--- a/tools/perf/util/cloexec.h ++++ b/tools/perf/util/cloexec.h +@@ -3,10 +3,6 @@ + + unsigned long perf_event_open_cloexec_flag(void); + +-#ifdef __GLIBC_PREREQ +-#if !__GLIBC_PREREQ(2, 6) + extern int sched_getcpu(void) __THROW; +-#endif +-#endif + + #endif /* __PERF_CLOEXEC_H */ +diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h +index 1ff23e0..a5f4770 100644 +--- a/tools/perf/util/util.h ++++ b/tools/perf/util/util.h +@@ -333,4 +333,8 @@ int gzip_decompress_to_file(const char *input, int output_fd); + int lzma_decompress_to_file(const char *input, int output_fd); + #endif + ++/* musl has a xpg compliant strerror_r by default */ ++#define strerror_r(err, buf, buflen) \ ++ (strerror_r(err, buf, buflen) ? NULL : buf) ++ + #endif /* GIT_COMPAT_UTIL_H */ +-- +1.9.1 + diff --git a/target/linux/generic/patches-4.4/280-perf-fixes-for-musl.patch b/target/linux/generic/patches-4.4/280-perf-fixes-for-musl.patch new file mode 100644 index 0000000..42d0d48 --- /dev/null +++ b/target/linux/generic/patches-4.4/280-perf-fixes-for-musl.patch @@ -0,0 +1,147 @@ +kernel: 4.4 perf: musl compatibility + +Allow linux perf tool to compile under musl. + +Thanks to Dave Taht for the +heavy lifting. + +Signed-off-by: Kevin Darbyshire-Bryant + +--- + tools/lib/api/fs/tracing_path.c | 3 +++ + 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, 28 insertions(+), 10 deletions(-) + +diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c +index a26bb5e..a04df38 100644 +--- a/tools/lib/api/fs/tracing_path.c ++++ b/tools/lib/api/fs/tracing_path.c +@@ -10,6 +10,9 @@ + #include "fs.h" + + #include "tracing_path.h" ++/* musl has a xpg compliant strerror_r by default */ ++#define strerror_r(err, buf, buflen) \ ++ (strerror_r(err, buf, buflen) ? NULL : buf) + + + char tracing_mnt[PATH_MAX] = "/sys/kernel/debug"; +diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c +index 2a912df..0644b42 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 3d4c7c0..91f57b0 100644 +--- a/tools/perf/perf.c ++++ b/tools/perf/perf.c +@@ -523,6 +523,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; ++} ++ + int main(int argc, const char **argv) + { + const char *cmd; +@@ -530,7 +545,7 @@ int main(int argc, const char **argv) + + /* The page_size is placed in util object. */ + page_size = sysconf(_SC_PAGE_SIZE); +- cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); ++ cacheline_size = cache_line_size(); + + cmd = perf_extract_argv0_path(argv[0]); + if (!cmd) +diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h +index c861373..599aa97 100644 +--- a/tools/perf/util/cache.h ++++ b/tools/perf/util/cache.h +@@ -71,7 +71,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2 + extern char *perf_pathdup(const char *fmt, ...) + __attribute__((format (printf, 1, 2))); + +-#ifndef __UCLIBC__ ++#if !defined(__UCLIBC__) && defined(__GLIBC__) + /* Matches the libc/libbsd function attribute so we declare this unconditionally: */ + extern size_t strlcpy(char *dest, const char *src, size_t size); + #endif +diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c +index 2babdda..85b5238 100644 +--- a/tools/perf/util/cloexec.c ++++ b/tools/perf/util/cloexec.c +@@ -7,15 +7,11 @@ + + static unsigned long flag = PERF_FLAG_FD_CLOEXEC; + +-#ifdef __GLIBC_PREREQ +-#if !__GLIBC_PREREQ(2, 6) + int __weak sched_getcpu(void) + { + errno = ENOSYS; + return -1; + } +-#endif +-#endif + + static int perf_flag_probe(void) + { +diff --git a/tools/perf/util/cloexec.h b/tools/perf/util/cloexec.h +index 3bee677..06904bc 100644 +--- a/tools/perf/util/cloexec.h ++++ b/tools/perf/util/cloexec.h +@@ -3,10 +3,6 @@ + + unsigned long perf_event_open_cloexec_flag(void); + +-#ifdef __GLIBC_PREREQ +-#if !__GLIBC_PREREQ(2, 6) && !defined(__UCLIBC__) + extern int sched_getcpu(void) __THROW; +-#endif +-#endif + + #endif /* __PERF_CLOEXEC_H */ +diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h +index dcc6590..16d398b 100644 +--- a/tools/perf/util/util.h ++++ b/tools/perf/util/util.h +@@ -358,4 +358,8 @@ int fetch_kernel_version(unsigned int *puint, + #define KVER_FMT "%d.%d.%d" + #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) + ++/* musl has a xpg compliant strerror_r by default */ ++#define strerror_r(err, buf, buflen) \ ++ (strerror_r(err, buf, buflen) ? NULL : buf) ++ + #endif /* GIT_COMPAT_UTIL_H */ +-- +2.5.0 +