All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS
@ 2021-12-02 13:43 Uwe Kleine-König
  2021-12-02 15:23 ` Uwe Kleine-König
  2021-12-02 15:36 ` James Clark
  0 siblings, 2 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2021-12-02 13:43 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, Diederik de Haas, Uwe Kleine-König

From: Uwe Kleine-König <uwe@kleine-koenig.org>

When cross compiling on amd64 for arm64 the build failed on my machine with:

	Makefile.config:493: *** Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1.  Stop.

even though libopencsd was installed (for both amd64 and arm64). After
some digging around I found the relevant error message in
tools/perf/feature/test-libopencsd.make.output:

	/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lstdc++

Instead of fixing the error message to also include a request to install
libstdc++, just drop -lstdc++. With this change the build completed.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
Hello,

not sure this is a pure cross compilation problem. I think in general
it's a bad idea to link against libstdc++ explicitly. Still more if
there is no C++ involved.

Best regards
Uwe

 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index afd144725a0b..dc946b7a802e 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -143,7 +143,7 @@ FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
 ifdef CSINCLUDES
   LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
 endif
-OPENCSDLIBS := -lopencsd_c_api -lopencsd -lstdc++
+OPENCSDLIBS := -lopencsd_c_api -lopencsd
 ifdef CSLIBS
   LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
 endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS
  2021-12-02 13:43 [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS Uwe Kleine-König
@ 2021-12-02 15:23 ` Uwe Kleine-König
  2021-12-02 15:36 ` James Clark
  1 sibling, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2021-12-02 15:23 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, Diederik de Haas, Tamas Zsoldos,
	Arnaldo Carvalho de Melo, Adrian Bunk


[-- Attachment #1.1: Type: text/plain, Size: 1605 bytes --]

Hello,

I picked the wrong script so the sender address was wrong. I assume I'll 
have to fix that. Will pay more attention for v2.

On 12/2/21 14:43, Uwe Kleine-König wrote:
> From: Uwe Kleine-König <uwe@kleine-koenig.org>
> 
> When cross compiling on amd64 for arm64 the build failed on my machine with:
> 
> 	Makefile.config:493: *** Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1.  Stop.
> 
> even though libopencsd was installed (for both amd64 and arm64). After
> some digging around I found the relevant error message in
> tools/perf/feature/test-libopencsd.make.output:
> 
> 	/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lstdc++
> 
> Instead of fixing the error message to also include a request to install
> libstdc++, just drop -lstdc++. With this change the build completed.
> 
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
> ---
> Hello,
> 
> not sure this is a pure cross compilation problem. I think in general
> it's a bad idea to link against libstdc++ explicitly. Still more if
> there is no C++ involved.

In the meantime I was pointed to 573cf5c9a152 ("perf build: Add missing 
-lstdc++ when linking with libopencsd"), and I wonder what I'm missing. 
Maybe my patch breaks the build if libopencsd is only available as .a?

I added the people involved in that commit to Cc: and look forward to 
details. The motivation to add -lstdc++ seems to be "It does not hurt" 
which is a bit weak.

Best regards
Uwe

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS
  2021-12-02 13:43 [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS Uwe Kleine-König
  2021-12-02 15:23 ` Uwe Kleine-König
@ 2021-12-02 15:36 ` James Clark
  2021-12-02 16:00   ` Branislav Rankov
  2021-12-02 16:03   ` Uwe Kleine-König
  1 sibling, 2 replies; 7+ messages in thread
From: James Clark @ 2021-12-02 15:36 UTC (permalink / raw)
  To: Uwe Kleine-König, Branislav Rankov
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, Diederik de Haas, Uwe Kleine-König,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo



On 02/12/2021 13:43, Uwe Kleine-König wrote:
> From: Uwe Kleine-König <uwe@kleine-koenig.org>
> 
> When cross compiling on amd64 for arm64 the build failed on my machine with:
> 
> 	Makefile.config:493: *** Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1.  Stop.
> 
> even though libopencsd was installed (for both amd64 and arm64). After
> some digging around I found the relevant error message in
> tools/perf/feature/test-libopencsd.make.output:
> 
> 	/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lstdc++

Do you have this library installed for arm64? I know you said you had OpenCSD installed, but
maybe the arm64 stdc++ lib is missing?

> 
> Instead of fixing the error message to also include a request to install
> libstdc++, just drop -lstdc++. With this change the build completed.
> 
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
> ---
> Hello,
> 
> not sure this is a pure cross compilation problem. I think in general
> it's a bad idea to link against libstdc++ explicitly. Still more if
> there is no C++ involved.

This -lstdc++ was only just added a few months ago by Branislav so I'm
not sure if it should be removed. OpenCSD does use C++ so it is involved,
although I would have thought that stdc++ was a dependency of opencsd so
it would automatically get pulled in.

@Branislav, what was the build error that you were fixing with the recent
change? I checked the commit message but it's not listed.

James

> 
> Best regards
> Uwe
> 
>  tools/perf/Makefile.config | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index afd144725a0b..dc946b7a802e 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -143,7 +143,7 @@ FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
>  ifdef CSINCLUDES
>    LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
>  endif
> -OPENCSDLIBS := -lopencsd_c_api -lopencsd -lstdc++
> +OPENCSDLIBS := -lopencsd_c_api -lopencsd
>  ifdef CSLIBS
>    LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
>  endif
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS
  2021-12-02 15:36 ` James Clark
@ 2021-12-02 16:00   ` Branislav Rankov
  2021-12-02 16:07     ` Uwe Kleine-König
  2021-12-02 16:03   ` Uwe Kleine-König
  1 sibling, 1 reply; 7+ messages in thread
From: Branislav Rankov @ 2021-12-02 16:00 UTC (permalink / raw)
  To: James Clark, Uwe Kleine-König
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, Diederik de Haas, Uwe Kleine-König,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo



On 12/2/21 15:36, James Clark wrote:
>
>
> On 02/12/2021 13:43, Uwe Kleine-König wrote:
>> From: Uwe Kleine-König <uwe@kleine-koenig.org>
>>
>> When cross compiling on amd64 for arm64 the build failed on my machine with:
>>
>>      Makefile.config:493: *** Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1.  Stop.
>>
>> even though libopencsd was installed (for both amd64 and arm64). After
>> some digging around I found the relevant error message in
>> tools/perf/feature/test-libopencsd.make.output:
>>
>>      /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lstdc++
>
> Do you have this library installed for arm64? I know you said you had OpenCSD installed, but
> maybe the arm64 stdc++ lib is missing?
>
>>
>> Instead of fixing the error message to also include a request to install
>> libstdc++, just drop -lstdc++. With this change the build completed.
>>
>> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
>> ---
>> Hello,
>>
>> not sure this is a pure cross compilation problem. I think in general
>> it's a bad idea to link against libstdc++ explicitly. Still more if
>> there is no C++ involved.
>
> This -lstdc++ was only just added a few months ago by Branislav so I'm
> not sure if it should be removed. OpenCSD does use C++ so it is involved,
> although I would have thought that stdc++ was a dependency of opencsd so
> it would automatically get pulled in.
>
> @Branislav, what was the build error that you were fixing with the recent
> change? I checked the commit message but it's not listed.

Hi. I was fixing the static build with this. When doing the static build you need
to list all the dependencies. I thought it would not be a problem to also list it
in the dynamic case.

I did not have problems when trying crosscompile in both dynamic and static case.
But maybe you have a case where this is a problem. I would like to understand what
your case is.
Does your libOpenCSD.so have a dependency on libstdc++.so?
If so, where is the libstdc++.so?

If this is a genuine problem, we could add -lstdc++ conditionally only for the
static build.

>
> James
>
>>
>> Best regards
>> Uwe
>>
>>  tools/perf/Makefile.config | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>> index afd144725a0b..dc946b7a802e 100644
>> --- a/tools/perf/Makefile.config
>> +++ b/tools/perf/Makefile.config
>> @@ -143,7 +143,7 @@ FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
>>  ifdef CSINCLUDES
>>    LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
>>  endif
>> -OPENCSDLIBS := -lopencsd_c_api -lopencsd -lstdc++
>> +OPENCSDLIBS := -lopencsd_c_api -lopencsd
>>  ifdef CSLIBS
>>    LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
>>  endif
>>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS
  2021-12-02 15:36 ` James Clark
  2021-12-02 16:00   ` Branislav Rankov
@ 2021-12-02 16:03   ` Uwe Kleine-König
  1 sibling, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2021-12-02 16:03 UTC (permalink / raw)
  To: James Clark, Uwe Kleine-König, Branislav Rankov
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, Diederik de Haas, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Branislav Rankov, Tamas Zsoldos


[-- Attachment #1.1: Type: text/plain, Size: 1935 bytes --]

Hello,

On 12/2/21 16:36, James Clark wrote:
> On 02/12/2021 13:43, Uwe Kleine-König wrote:
>> From: Uwe Kleine-König <uwe@kleine-koenig.org>
>>
>> When cross compiling on amd64 for arm64 the build failed on my machine with:
>>
>> 	Makefile.config:493: *** Error: No libopencsd library found or the version is not up-to-date. Please install recent libopencsd to build with CORESIGHT=1.  Stop.
>>
>> even though libopencsd was installed (for both amd64 and arm64). After
>> some digging around I found the relevant error message in
>> tools/perf/feature/test-libopencsd.make.output:
>>
>> 	/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lstdc++
> 
> Do you have this library installed for arm64? I know you said you had OpenCSD installed, but
> maybe the arm64 stdc++ lib is missing?

Yes, I have libstdc++ installed, but only the libstdc++.so.6.0.29, not 
the plain .so. The former is enough to run c++ binaries, the latter is 
only needed for linking. As none of the symbols in libstdc++ is needed 
for the kernel tools, not having the .so works fine.

>> Instead of fixing the error message to also include a request to install
>> libstdc++, just drop -lstdc++. With this change the build completed.
>>
>> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
>> ---
>> Hello,
>>
>> not sure this is a pure cross compilation problem. I think in general
>> it's a bad idea to link against libstdc++ explicitly. Still more if
>> there is no C++ involved.
> 
> This -lstdc++ was only just added a few months ago by Branislav so I'm
> not sure if it should be removed.

This is a poor reasoning in my eyes. Overstating: We didn't suffer long 
enough from this problem, let's keep it around for a while.

I would hope that given the change isn't that old we have a good chance 
to find out enough details to find a good fix.

Best regards
Uwe

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS
  2021-12-02 16:00   ` Branislav Rankov
@ 2021-12-02 16:07     ` Uwe Kleine-König
  2021-12-03  9:22       ` James Clark
  0 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2021-12-02 16:07 UTC (permalink / raw)
  To: Branislav Rankov, James Clark, Uwe Kleine-König
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, Diederik de Haas, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo


[-- Attachment #1.1: Type: text/plain, Size: 685 bytes --]

On 12/2/21 17:00, Branislav Rankov wrote:
> I did not have problems when trying crosscompile in both dynamic and static case.
> But maybe you have a case where this is a problem. I would like to understand what
> your case is.
> Does your libOpenCSD.so have a dependency on libstdc++.so?
> If so, where is the libstdc++.so?

As noted in an other thread branch: I have libstdc++.so.6.0.29 but not 
libstdc++.so. For linking this is enough as the binary that is linked 
doesn't need any symbols from libstdc++.so.

> If this is a genuine problem, we could add -lstdc++ conditionally only for the
> static build.

That seems to be the path to go then.

Best regards
Uwe

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS
  2021-12-02 16:07     ` Uwe Kleine-König
@ 2021-12-03  9:22       ` James Clark
  0 siblings, 0 replies; 7+ messages in thread
From: James Clark @ 2021-12-03  9:22 UTC (permalink / raw)
  To: Uwe Kleine-König, Branislav Rankov, Uwe Kleine-König
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, Diederik de Haas, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo



On 02/12/2021 16:07, Uwe Kleine-König wrote:
> On 12/2/21 17:00, Branislav Rankov wrote:
>> I did not have problems when trying crosscompile in both dynamic and static case.
>> But maybe you have a case where this is a problem. I would like to understand what
>> your case is.
>> Does your libOpenCSD.so have a dependency on libstdc++.so?
>> If so, where is the libstdc++.so?
> 
> As noted in an other thread branch: I have libstdc++.so.6.0.29 but not libstdc++.so. For linking this is enough as the binary that is linked doesn't need any symbols from libstdc++.so.
> 
>> If this is a genuine problem, we could add -lstdc++ conditionally only for the
>> static build.
> 
> That seems to be the path to go then.

Hi Uwe,

Yes I think so. There are also quite a few similar cases in the makefiles like:

  ifeq ($(findstring -static,${LDFLAGS}),-static)
    DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
  endif

With the conditional added to this patch:

Reviewed-by: James Clark <james.clark@arm.com>


Thanks
James

> 
> Best regards
> Uwe

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-03  9:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 13:43 [PATCH] perf: Drop -lstdc++ from OPENCSDLIBS Uwe Kleine-König
2021-12-02 15:23 ` Uwe Kleine-König
2021-12-02 15:36 ` James Clark
2021-12-02 16:00   ` Branislav Rankov
2021-12-02 16:07     ` Uwe Kleine-König
2021-12-03  9:22       ` James Clark
2021-12-02 16:03   ` Uwe Kleine-König

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.