Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp662206ybl; Tue, 7 Jan 2020 12:49:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxJE5Ek8jeGhPKWo8xcMXUgVuzMoXRdfjemx1R99L0OsMm08gVs5lI50/v5LIsyHXu0DVVU X-Received: by 2002:a9d:7c90:: with SMTP id q16mr1605148otn.191.1578430177599; Tue, 07 Jan 2020 12:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578430177; cv=none; d=google.com; s=arc-20160816; b=OE8L25uvU2HgVtJMY2YcOOvv81xYU/t4E8gxHRGCjnZMjC/rkWqoZQT2t+5ilFgfRT 2EddpzAJTrremhel0N2XHFyGKap3rdPcPXjh+YhfPoSlhOFsfMFUrzIXxikcbiTEt9s1 MDhG0soM51Is4H9acA5ArMwwn6p+VXOFgb6QwYooHpMRDmbPepGhfhy7IMPr90NdM4gX Ouygc8RvE80Uob3Ip5G72Dr27ZpF/zXx4mi20ejLb/bfzyU8Hvuno3t9tz2FwwrNfjgN MdXq+EwdqfCHx7L0Cn6xUSxboQH1RpTgWgWqir0uQMmc7V295fUWJYAkqJd9YheS1Yx6 EFag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=zxlGMQojZYiNyHf+AM90FO6lD8TZsnX0sKF7G9TAuOg=; b=DMK2e2TNb6iBjt18PlqCnpNQltm1b57j4kq6KPBkl/Nh5ariX0ekmk4M0RPnDkfUWd So/m/uwx3xoyEA5GDfRcVJlD85HhKfP5wWEDvqTrIF2t9Ln997M1NFT2++/hMkv47oGO 6zsZcvYvSBbMM7DR/1lvWvpNqhIzHZmF62N3Eh735RZoukQdU0Rv4t9gkFVnhZ2y6Kb2 Xnad7D3X1opsEdyr1JBeQnQUjd18Nw9KtEn6xFCuBoesPhpI0336Y31Q+ysL75s9DUK6 by9c0UTltHWG4rjUYGDsNn05bKFAt9Z1JR53uKSlnmV9115fQXGh8l6ixVhfnks3I9qm JECg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si583052oij.133.2020.01.07.12.49.25; Tue, 07 Jan 2020 12:49:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbgAGUsK (ORCPT + 99 others); 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)