All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rich Felker <dalias@libc.org>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	"devel@uclibc-ng.org" <devel@uclibc-ng.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	lkml <linux-kernel@vger.kernel.org>,
	arcml <linux-snps-arc@lists.infradead.org>,
	Arnd Bergmann <arnd@arndb.de>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: Detecting libc in perf (was Re: perf tools build broken after v5.1-rc1)
Date: Tue, 30 Apr 2019 23:12:15 -0400	[thread overview]
Message-ID: <20190501031215.GZ23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <17a86bc7-c1f9-8c3c-8f1d-711e95dac49d@synopsys.com>

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 <stdlib.h>
> >>>
> >>> #if !defined(__UCLIBC__)
> >>> #include <gnu/libc-version.h>
> >>> #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

WARNING: multiple messages have this Message-ID (diff)
From: dalias@libc.org (Rich Felker)
To: linux-snps-arc@lists.infradead.org
Subject: Detecting libc in perf (was Re: perf tools build broken after v5.1-rc1)
Date: Tue, 30 Apr 2019 23:12:15 -0400	[thread overview]
Message-ID: <20190501031215.GZ23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <17a86bc7-c1f9-8c3c-8f1d-711e95dac49d@synopsys.com>

On Tue, Apr 30, 2019@10:13:40AM -0700, Vineet Gupta wrote:
> On 4/30/19 10:04 AM, Rich Felker wrote:
> > On Tue, Apr 30, 2019@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 at quaco linux]$ cat tools/build/feature/test-glibc.c
> >>> // SPDX-License-Identifier: GPL-2.0
> >>> #include <stdlib.h>
> >>>
> >>> #if !defined(__UCLIBC__)
> >>> #include <gnu/libc-version.h>
> >>> #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 at quaco linux]$
> >>>
> >>> [perfbuilder at 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 at 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

  reply	other threads:[~2019-05-01  3:12 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-19 23:32 perf tools build broken after v5.1-rc1 Vineet Gupta
2019-04-19 23:32 ` Vineet Gupta
2019-04-22 15:20 ` Arnaldo Carvalho de Melo
2019-04-22 15:20   ` Arnaldo Carvalho de Melo
2019-04-25 21:48   ` Arnaldo Carvalho de Melo
2019-04-25 21:48     ` Arnaldo Carvalho de Melo
2019-04-26 19:28     ` Arnaldo Carvalho de Melo
2019-04-26 19:28       ` Arnaldo Carvalho de Melo
2019-04-26 19:35       ` Arnaldo Carvalho de Melo
2019-04-26 19:35         ` Arnaldo Carvalho de Melo
2019-04-26 19:35         ` Arnaldo Carvalho de Melo
2019-04-29 17:23         ` Vineet Gupta
2019-04-29 17:23           ` Vineet Gupta
2019-05-03  5:58         ` [tip:perf/urgent] tools arch uapi: Copy missing unistd.h headers for arc, hexagon and riscv tip-bot for Arnaldo Carvalho de Melo
2019-04-29 17:14     ` perf tools build broken after v5.1-rc1 Vineet Gupta
2019-04-29 17:14       ` Vineet Gupta
2019-04-30  1:18       ` Arnaldo Carvalho de Melo
2019-04-30  1:18         ` Arnaldo Carvalho de Melo
2019-04-30  1:18         ` Arnaldo Carvalho de Melo
2019-04-30 15:53         ` Detecting libc in perf (was Re: perf tools build broken after v5.1-rc1) Vineet Gupta
2019-04-30 15:53           ` Vineet Gupta
2019-04-30 17:04           ` Rich Felker
2019-04-30 17:04             ` Rich Felker
2019-04-30 17:13             ` Vineet Gupta
2019-04-30 17:13               ` Vineet Gupta
2019-05-01  3:12               ` Rich Felker [this message]
2019-05-01  3:12                 ` Rich Felker
2019-05-02 16:55                 ` Vineet Gupta
2019-05-02 16:55                   ` Vineet Gupta
2019-05-02 16:55                   ` Vineet Gupta
2019-05-02 20:09                   ` Arnaldo Carvalho de Melo
2019-05-02 20:09                     ` Arnaldo Carvalho de Melo
2019-05-02 20:09                     ` Arnaldo Carvalho de Melo
2019-05-02 16:53         ` perf tools build broken after v5.1-rc1 Vineet Gupta
2019-05-02 16:53           ` Vineet Gupta
2019-04-29 17:17   ` Vineet Gupta
2019-04-29 17:17     ` Vineet Gupta
2019-04-30 16:12     ` Arnd Bergmann
2019-04-30 16:12       ` Arnd Bergmann
2019-05-01 20:41       ` Arnaldo Carvalho de Melo
2019-05-01 20:41         ` Arnaldo Carvalho de Melo
2019-05-01 21:17         ` Vineet Gupta
2019-05-01 21:17           ` Vineet Gupta
2019-05-02 14:36           ` Arnaldo Carvalho de Melo
2019-05-02 14:36             ` Arnaldo Carvalho de Melo
2019-05-02 14:36             ` Arnaldo Carvalho de Melo
2019-05-02 15:41             ` Arnaldo Carvalho de Melo
2019-05-02 15:41               ` Arnaldo Carvalho de Melo
2019-05-02 16:09             ` Vineet Gupta
2019-05-02 16:09               ` Vineet Gupta
2019-05-02 16:09               ` Vineet Gupta
2019-05-02 16:41               ` Arnaldo Carvalho de Melo
2019-05-02 16:41                 ` Arnaldo Carvalho de Melo
2019-05-02 17:10                 ` Vineet Gupta
2019-05-02 17:10                   ` Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190501031215.GZ23599@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=acme@redhat.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=arnd@arndb.de \
    --cc=devel@uclibc-ng.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.