Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5676776yba; Tue, 30 Apr 2019 20:13:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6Cz957PDc3TLBGFs8LL5AxLa9BO4Fho5zLd9AJ8KHQD7IjRMwZDmCy7BdhQUDdg/SwZo6 X-Received: by 2002:a62:4558:: with SMTP id s85mr77538737pfa.171.1556680436495; Tue, 30 Apr 2019 20:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556680436; cv=none; d=google.com; s=arc-20160816; b=ie3UTiPKd/hKSfyQwaV4evaA6CizAMNKlFZyMa4OtIFyM+/ppnP7kdFuAvqX87eE6d BXCyx3fqi2vUDcoC2Lnj3HSzA7Sgw+z8J0nYh1rFf24xy2vOLnaR1SjiVWC80/r/OxCb KvgF1ldcsFUVJ9AYN/ySCRfqjpIhhQRDKyaSy6cVA87AcWJCLPKiNnWN32KDmtmrJcHr CN2uoh9YC66TIeTHat4AsiSGxlZJU852/qIke4mOpBVB+/C9uz+xRSUfK78ouv6pDtqX /ZQv2di/Pd0RSqiJE8QWUywluYa4t0045Xo7gBZ9Ufuw8TkG2opbzW07IEVR8k6r6le7 P7cw== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Tm4b1uVmeBx1/EQnypYrWCOPgRTyLXL2jBR/XDjyrwU=; b=ycn+NgYKIs5/u83Hgmb60ggf/yH+jSA7YjdhpwNDkNw+rL0hTF+XaaJDX3GLjV4Dsn 1G+6Fnan2uW/aO0ZGq3gkNwzoSt6l3GG3AB8aHLRxkHmdjhnqGdgsacQ9FAsOVq7yC1g 1EKTXN5CfLUaqUtfNqEQvuir3nS3uiyJnBMAuHtMzNCwePuo6Nq8SY/FcI7EKVVcqan4 kxCF3wqS5XYifZQ3GkQDGA+bpJghQg0U4UAm9TzLjrRWSD4zw15yIanTl/sW/+P7r7ce TB0BOLDHOmOi5gILfWvaX7Y1Es71rwHmKcqkFxTv+pUVJMhYGjbUunG9q2lWpeZ3AB1/ hjJg== 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 184si6259655pfg.32.2019.04.30.20.13.41; Tue, 30 Apr 2019 20:13:56 -0700 (PDT) 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 S1726101AbfEADMW (ORCPT + 99 others); Tue, 30 Apr 2019 23:12:22 -0400 Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:32874 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726004AbfEADMV (ORCPT ); Tue, 30 Apr 2019 23:12:21 -0400 Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1hLffL-0002EU-00; Wed, 01 May 2019 03:12:15 +0000 Date: Tue, 30 Apr 2019 23:12:15 -0400 From: Rich Felker To: Vineet Gupta Cc: Arnaldo Carvalho de Melo , "devel@uclibc-ng.org" , "linux-perf-users@vger.kernel.org" , Arnaldo Carvalho de Melo , lkml , arcml , Arnd Bergmann , Jiri Olsa , Namhyung Kim Subject: Re: Detecting libc in perf (was Re: perf tools build broken after v5.1-rc1) Message-ID: <20190501031215.GZ23599@brightrain.aerifal.cx> References: <20190422152027.GB11750@kernel.org> <20190425214800.GC21829@kernel.org> <20190430011818.GE7857@kernel.org> <20190430170404.GX23599@brightrain.aerifal.cx> <17a86bc7-c1f9-8c3c-8f1d-711e95dac49d@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17a86bc7-c1f9-8c3c-8f1d-711e95dac49d@synopsys.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 30, 2019 at 10:13:40AM -0700, Vineet Gupta wrote: > On 4/30/19 10:04 AM, Rich Felker wrote: > > On Tue, Apr 30, 2019 at 03:53:18PM +0000, Vineet Gupta wrote: > >> On 4/29/19 6:18 PM, Arnaldo Carvalho de Melo wrote: > >>>>> Auto-detecting system features: > >>>>> ... dwarf: [ OFF ] > >>>>> ... dwarf_getlocations: [ OFF ] > >>>>> ... glibc: [ on ] > >>>> Not related to current issue, this run uses a uClibc toolchain and yet it is > >>>> detecting glibc - doesn't seem right to me. > >>> Ok, I'll improve that, I think it just tries to detect a libc, yeah, > >>> see: > >>> > >>> [acme@quaco linux]$ cat tools/build/feature/test-glibc.c > >>> // SPDX-License-Identifier: GPL-2.0 > >>> #include > >>> > >>> #if !defined(__UCLIBC__) > >>> #include > >>> #else > >>> #define XSTR(s) STR(s) > >>> #define STR(s) #s > >>> #endif > >>> > >>> int main(void) > >>> { > >>> #if !defined(__UCLIBC__) > >>> const char *version = gnu_get_libc_version(); > >>> #else > >>> const char *version = XSTR(__GLIBC__) "." XSTR(__GLIBC_MINOR__); > >>> #endif > >>> > >>> return (long)version; > >>> } > >>> [acme@quaco linux]$ > >>> > >>> [perfbuilder@59ca4b424ded /]$ grep __GLIBC__ /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/*.h > >>> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/features.h: The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are > >>> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/features.h:#define __GLIBC__ 2 > >>> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/features.h: ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) > >>> [perfbuilder@59ca4b424ded /]$ > >>> > >>> Isn't that part of uClibc? > >> > >> Right you are. Per the big fat comment right above that code, this gross hack in > >> uclibc is unavoidable as applications tend to rely on that define. > >> So a better fix would be to check for various !GLIBC libs explicitly. > >> > >> #ifdef __UCLIBC__ > >> > >> #elseif defined __MUSL__ > >> > >> .... > >> > >> Not pretty from app usage pov, but that seems to be the only sane way of doing it. > > > > What are you trying to achieve? I was just CC'd and I'm missing the > > context. > > Sorry I added you as a subject matter expert but didn't provide enough context. > > The original issue [1] was perf failing to build on ARC due to perf tools needing > a copy of unistd.h but this thread [2] was a small side issue of auto-detecting > libc variaint in perf tools where despite uClibc tools, glibc is declared to be > detected, due to uClibc's historical hack of defining __GLIBC__. So __GLIBC__ is > not sufficient (and probably not the right interface to begin wtih) to ensure glibc. > > [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-April/005676.html > [2] http://lists.infradead.org/pipermail/linux-snps-arc/2019-April/005684.html I think you misunderstood -- I'm asking what you're trying to achieve by detecting whether the libc is glibc, rather than whether it has some particular interface you want to conditionally use. This is a major smell and is usually something wrong that shouldn't be done. Rich