linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Clark <james.clark@arm.com>
To: Ian Rogers <irogers@google.com>
Cc: "Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Stephane Eranian" <eranian@google.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Tom Rix" <trix@redhat.com>,
	"Roberto Sassu" <roberto.sassu@huawei.com>,
	"Quentin Monnet" <quentin@isovalent.com>,
	"Andres Freund" <andres@anarazel.de>,
	"Tiezhu Yang" <yangtiezhu@loongson.cn>,
	"Pavithra Gurushankar" <gpavithrasha@gmail.com>,
	"Yang Jihong" <yangjihong1@huawei.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Leo Yan" <leo.yan@linaro.org>, "Martin Liška" <mliska@suse.cz>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	llvm@lists.linux.dev, "Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>
Subject: Re: [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support
Date: Fri, 31 Mar 2023 10:27:12 +0100	[thread overview]
Message-ID: <8daa6988-a0ec-bd92-5a7b-0dca39fbc3b0@arm.com> (raw)
In-Reply-To: <CAP-5=fWYHyJbZicrsj6UnOBVTFX8NheL+GPGQbC8NMQv2G1WcA@mail.gmail.com>



On 30/03/2023 20:03, Ian Rogers wrote:
> On Thu, Mar 30, 2023 at 9:50 AM Ian Rogers <irogers@google.com> wrote:
>>
>> On Thu, Mar 30, 2023 at 7:08 AM James Clark <james.clark@arm.com> wrote:
>>>
>>>
>>>
>>> On 11/03/2023 06:57, Ian Rogers wrote:
>>>> Refactor C++ demangling out of symbol-elf into its own files similar
>>>> to other languages. Add abi::__cxa_demangle support. As the other
>>>> demanglers are not shippable with distributions, this brings back C++
>>>> demangling in a common case. It isn't perfect as the support for
>>>> optionally demangling arguments and modifiers isn't present.
>>>>
>>>> Signed-off-by: Ian Rogers <irogers@google.com>
>>>> ---
>>>>  tools/perf/Makefile.config       | 29 +++++++++---------
>>>>  tools/perf/util/Build            |  1 +
>>>>  tools/perf/util/demangle-cxx.cpp | 50 ++++++++++++++++++++++++++++++++
>>>>  tools/perf/util/demangle-cxx.h   | 16 ++++++++++
>>>>  tools/perf/util/symbol-elf.c     | 37 +++++------------------
>>>>  5 files changed, 88 insertions(+), 45 deletions(-)
>>>>  create mode 100644 tools/perf/util/demangle-cxx.cpp
>>>>  create mode 100644 tools/perf/util/demangle-cxx.h
>>>>
>>>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>>>> index 5756498248e0..fdeca45cf15f 100644
>>>> --- a/tools/perf/Makefile.config
>>>> +++ b/tools/perf/Makefile.config
>>>> @@ -906,6 +906,7 @@ ifdef BUILD_NONDISTRO
>>>>    endif
>>>>
>>>>    CFLAGS += -DHAVE_LIBBFD_SUPPORT
>>>> +  CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
>>>>    ifeq ($(feature-libbfd-buildid), 1)
>>>>      CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
>>>>    else
>>>> @@ -913,26 +914,24 @@ ifdef BUILD_NONDISTRO
>>>>    endif
>>>>  endif
>>>>
>>>> -ifdef NO_DEMANGLE
>>>> -  CFLAGS += -DNO_DEMANGLE
>>>> -else
>>>> +ifndef NO_DEMANGLE
>>>> +  $(call feature_check,cxa-demangle)
>>>> +  ifeq ($(feature-cxa-demangle), 1)
>>>> +    EXTLIBS += -lstdc++
>>>
>>> Hi Ian,
>>>
>>> I think cross compilation for arm on x86 isn't working after this change
>>> (at least on Ubuntu).
>>>
>>> Even with all of the arm64 libstdc++ stuff installed, you can only link
>>> to it using g++, but the perf build tries to link to it using gcc. Not
>>> sure it's some quirk with the search paths on Ubuntu or something else:
>>>
>>>   $ aarch64-linux-gnu-gcc -lstdc++
>>>
>>>    /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-
>>> gnu/bin/ld: cannot find -lstdc++: No such file or directory
>>>   collect2: error: ld returned 1 exit status
>>>
>>> g++ gets further:
>>>
>>>   $ aarch64-linux-gnu-g++ -lstdc++
>>>
>>>   ...
>>>   (.text+0x20): undefined reference to `main'
>>> collect2: error: ld returned 1 exit status
>>>
>>> At the end of the perf build it looks like something similar is
>>> happening (with all the non interesting bits deleted):
>>>
>>>    $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
>>> NO_BPF_SKEL=1 V=1
>>>
>>>   aarch64-linux-gnu-gcc ... -o perf
>>>
>>> /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld:
>>> cannot find -lstdc++: No such file or directory
>>>
>>> If I build with NO_DEMANGLE=1 then the build works, but I think it would
>>> at be best to autodetect rather than have to do this. Or maybe even link
>>> at the end with g++ if we're going to use libstdc++?
>>
>> Hi James,
>>
>> sorry for the problems you are having, I'll see if I can get a repo. I
>> did add a feature test with this change in the same set:
>> https://lore.kernel.org/lkml/20230311065753.3012826-9-irogers@google.com/
>> So it should be feature testing and only enabling when
>> HAVE_CXA_DEMANGLE_SUPPORT is present. Obviously something is up, so
>> I'll have a think about it.
>>
>> Thanks,
>> Ian
> 
> Sorry to say I couldn't repro on Debian:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
> NO_LIBELF=1 NO_LIBTRACEEVENT=1

If you have NO_LIBELF=1 it sets NO_DEMANGLE=1 automatically so it skips
the c++ linking step. If you run with V=1 you can see that it doesn't
have -lstdc++ on the last link line.

But, having said that, I went to make a full reproducer in docker but it
actually worked. Turns out that the issue was on my end. I'd used
update-alternatives for a different compiler version and looks like I
had half of one gcc and half of another g++. Completely my fault, sorry
for the noise!

James

  reply	other threads:[~2023-03-31  9:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
2023-03-11  6:57 ` [PATCH v1 01/13] perf build: Support python/perf.so testing Ian Rogers
2023-03-11  6:57 ` [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL Ian Rogers
2023-03-13 20:19   ` Arnaldo Carvalho de Melo
2023-03-13 20:27     ` Ian Rogers
2023-03-13 20:34       ` Arnaldo Carvalho de Melo
2023-03-13 20:59         ` Arnaldo Carvalho de Melo
2023-03-13 21:05           ` Arnaldo Carvalho de Melo
2023-03-11  6:57 ` [PATCH v1 03/13] perf build: Remove unused HAVE_GLIBC_SUPPORT Ian Rogers
2023-03-11  6:57 ` [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set Ian Rogers
2023-03-13 19:45   ` Arnaldo Carvalho de Melo
2023-03-13 20:18     ` Ian Rogers
2023-03-11  6:57 ` [PATCH v1 05/13] perf util: Remove weak sched_getcpu Ian Rogers
2023-03-11  6:57 ` [PATCH v1 06/13] perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set Ian Rogers
2023-03-11  6:57 ` [PATCH v1 07/13] perf build: Make binutil libraries opt in Ian Rogers
2023-03-13 19:37   ` Arnaldo Carvalho de Melo
2023-03-11  6:57 ` [PATCH v1 08/13] tools build: Add feature test for abi::__cxa_demangle Ian Rogers
2023-03-11  6:57 ` [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support Ian Rogers
2023-03-30 14:08   ` James Clark
2023-03-30 16:50     ` Ian Rogers
2023-03-30 19:03       ` Ian Rogers
2023-03-31  9:27         ` James Clark [this message]
2023-03-11  6:57 ` [PATCH v1 10/13] perf build: Switch libpfm4 to opt-out rather than opt-in Ian Rogers
2023-03-11  6:57 ` [PATCH v1 11/13] perf build: If libtraceevent isn't present error the build Ian Rogers
2023-03-11  6:57 ` [PATCH v1 12/13] tools headers: Make the difference output easier to read Ian Rogers
2023-03-13 19:35   ` Arnaldo Carvalho de Melo
2023-03-13 20:14     ` Ian Rogers
2023-03-11  6:57 ` [PATCH v1 13/13] perf build: Remove redundant NO_NEWT build option Ian Rogers
2023-03-14 12:11 ` [PATCH v1 00/13] Perf tool build improvements Arnaldo Carvalho de Melo
2023-03-14 12:12   ` Arnaldo Carvalho de Melo
2023-03-14 12:27     ` Arnaldo Carvalho de Melo
2023-03-14 12:29       ` Arnaldo Carvalho de Melo
2023-03-14 12:21   ` Adrian Hunter
2023-03-14 12:28     ` Arnaldo Carvalho de Melo

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=8daa6988-a0ec-bd92-5a7b-0dca39fbc3b0@arm.com \
    --to=james.clark@arm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andres@anarazel.de \
    --cc=eranian@google.com \
    --cc=gpavithrasha@gmail.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=mliska@suse.cz \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=quentin@isovalent.com \
    --cc=roberto.sassu@huawei.com \
    --cc=trix@redhat.com \
    --cc=yangjihong1@huawei.com \
    --cc=yangtiezhu@loongson.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).