From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCFA0C3F68F for ; Tue, 7 Jan 2020 20:48:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAEB52077B for ; Tue, 7 Jan 2020 20:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbgAGUsK (ORCPT ); Tue, 7 Jan 2020 15:48:10 -0500 Received: from vmicros1.altlinux.org ([194.107.17.57]:59202 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbgAGUsJ (ORCPT ); Tue, 7 Jan 2020 15:48:09 -0500 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id 99C1E72CCE9; Tue, 7 Jan 2020 23:48:04 +0300 (MSK) Received: from altlinux.org (sole.flsd.net [185.75.180.6]) by imap.altlinux.org (Postfix) with ESMTPSA id 69EC64A4AE7; Tue, 7 Jan 2020 23:48:04 +0300 (MSK) Date: Tue, 7 Jan 2020 23:48:04 +0300 From: Vitaly Chikunov To: David Laight Cc: 'Arnaldo Carvalho de Melo' , Ingo Molnar , Thomas Gleixner , Jiri Olsa , Namhyung Kim , Clark Williams , "linux-kernel@vger.kernel.org" , "linux-perf-users@vger.kernel.org" , Dmitry Levin , Josh Poimboeuf , kbuild test robot , Peter Zijlstra , "stable@vger.kernel.org" , Vineet Gupta , Arnaldo Carvalho de Melo Subject: Re: [PATCH 20/20] tools lib: Fix builds when glibc contains strlcpy() Message-ID: <20200107204803.yuunleopt7pnq5dw@altlinux.org> Mail-Followup-To: David Laight , 'Arnaldo Carvalho de Melo' , Ingo Molnar , Thomas Gleixner , Jiri Olsa , Namhyung Kim , Clark Williams , "linux-kernel@vger.kernel.org" , "linux-perf-users@vger.kernel.org" , Dmitry Levin , Josh Poimboeuf , kbuild test robot , Peter Zijlstra , "stable@vger.kernel.org" , Vineet Gupta , Arnaldo Carvalho de Melo References: <20200106160705.10899-1-acme@kernel.org> <20200106160705.10899-21-acme@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20171215-106-ac61c7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org David, On Mon, Jan 06, 2020 at 05:03:26PM +0000, David Laight wrote: > From: Arnaldo Carvalho de Melo > > Sent: 06 January 2020 16:07 > > > > From: Vitaly Chikunov > > > > Disable a couple of compilation warnings (which are treated as errors) > > on strlcpy() definition and declaration, allowing users to compile perf > > and kernel (objtool) when: > > > > 1. glibc have strlcpy() (such as in ALT Linux since 2004) objtool and > > perf build fails with this (in gcc): > > > > In file included from exec-cmd.c:3: > > tools/include/linux/string.h:20:15: error: redundant redeclaration of ‘strlcpy’ [-Werror=redundant-decls] > > 20 | extern size_t strlcpy(char *dest, const char *src, size_t size); > > > > 2. clang ignores `-Wredundant-decls', but produces another warning when > > building perf: > > > > CC util/string.o > > ../lib/string.c:99:8: error: attribute declaration must precede definition [-Werror,-Wignored-attributes] > > size_t __weak strlcpy(char *dest, const char *src, size_t size) > > ../../tools/include/linux/compiler.h:66:34: note: expanded from macro '__weak' > > # define __weak __attribute__((weak)) > > /usr/include/bits/string_fortified.h:151:8: note: previous definition is here > > __NTH (strlcpy (char *__restrict __dest, const char *__restrict __src, > > Why not just always use the local version by renaming it? I believe that was the initial approach, which is changed some time ago to using weak linking. Also, Dmitry Levin (as one of glibc maintainers) claims that glibc implementation of strlcpy() is more correct and thus better. Thanks, > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)