* [PATCH v2] selftest/powerpc/benchmark: remove requirement libc-dev
@ 2024-08-12 9:41 Madhavan Srinivasan
2024-08-13 7:41 ` Michael Ellerman
2024-09-12 12:00 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Madhavan Srinivasan @ 2024-08-12 9:41 UTC (permalink / raw)
To: mpe, npiggin, christophe.leroy, shuah
Cc: linuxppc-dev, linux-kselftest, Madhavan Srinivasan
Currently exec-target.c file is linked as static and this
post a requirement to install libc dev package to build.
Without it, build-break when compiling selftest/powerpc/benchmark.
CC exec_target
/usr/bin/ld: cannot find -lc: No such file or directory
collect2: error: ld returned 1 exit status
exec_target.c is using "syscall" library function which
could be replaced with a inline assembly and the same is
proposed as a fix here.
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
---
Chnagelog v1:
- Add comment for clobber register and proper list of
clobber registers as suggested by Michael Ellerman and
Christophe Leroy
.../selftests/powerpc/benchmarks/Makefile | 2 +-
.../selftests/powerpc/benchmarks/exec_target.c | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 1321922038d0..ca4483c238b9 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -18,4 +18,4 @@ $(OUTPUT)/context_switch: LDLIBS += -lpthread
$(OUTPUT)/fork: LDLIBS += -lpthread
-$(OUTPUT)/exec_target: CFLAGS += -static -nostartfiles
+$(OUTPUT)/exec_target: CFLAGS += -nostartfiles
diff --git a/tools/testing/selftests/powerpc/benchmarks/exec_target.c b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
index c14b0fc1edde..a6408d3f26cd 100644
--- a/tools/testing/selftests/powerpc/benchmarks/exec_target.c
+++ b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
@@ -7,10 +7,22 @@
*/
#define _GNU_SOURCE
-#include <unistd.h>
#include <sys/syscall.h>
void _start(void)
{
- syscall(SYS_exit, 0);
+ asm volatile (
+ "li %%r0, %[sys_exit];"
+ "li %%r3, 0;"
+ "sc;"
+ :
+ : [sys_exit] "i" (SYS_exit)
+ /*
+ * "sc" will clobber r0, r3-r13, cr0, ctr, xer and memory.
+ * Even though sys_exit never returns, handle clobber
+ * registers.
+ */
+ : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
+ "r11", "r12", "r13", "cr0", "ctr", "xer", "memory"
+ );
}
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftest/powerpc/benchmark: remove requirement libc-dev
2024-08-12 9:41 [PATCH v2] selftest/powerpc/benchmark: remove requirement libc-dev Madhavan Srinivasan
@ 2024-08-13 7:41 ` Michael Ellerman
2024-08-16 3:31 ` Madhavan Srinivasan
2024-09-12 12:00 ` Michael Ellerman
1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2024-08-13 7:41 UTC (permalink / raw)
To: Madhavan Srinivasan, npiggin, christophe.leroy, shuah
Cc: linuxppc-dev, linux-kselftest, Madhavan Srinivasan
Madhavan Srinivasan <maddy@linux.ibm.com> writes:
> Currently exec-target.c file is linked as static and this
> post a requirement to install libc dev package to build.
I think specifically the problem is that the test requires a static
libc, which is packaged separately in some distros from the regular libc
headers, am I right?
On Fedora the package is glibc-static, as opposed to glibc-devel, which
the tests still require.
So this patch removes the requirement to have glibc-static installed.
Any idea what the package is called on Debian/Ubuntu?
cheers
> Without it, build-break when compiling selftest/powerpc/benchmark.
>
> CC exec_target
> /usr/bin/ld: cannot find -lc: No such file or directory
> collect2: error: ld returned 1 exit status
>
> exec_target.c is using "syscall" library function which
> could be replaced with a inline assembly and the same is
> proposed as a fix here.
>
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> ---
> Chnagelog v1:
> - Add comment for clobber register and proper list of
> clobber registers as suggested by Michael Ellerman and
> Christophe Leroy
>
> .../selftests/powerpc/benchmarks/Makefile | 2 +-
> .../selftests/powerpc/benchmarks/exec_target.c | 16 ++++++++++++++--
> 2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
> index 1321922038d0..ca4483c238b9 100644
> --- a/tools/testing/selftests/powerpc/benchmarks/Makefile
> +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
> @@ -18,4 +18,4 @@ $(OUTPUT)/context_switch: LDLIBS += -lpthread
>
> $(OUTPUT)/fork: LDLIBS += -lpthread
>
> -$(OUTPUT)/exec_target: CFLAGS += -static -nostartfiles
> +$(OUTPUT)/exec_target: CFLAGS += -nostartfiles
> diff --git a/tools/testing/selftests/powerpc/benchmarks/exec_target.c b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
> index c14b0fc1edde..a6408d3f26cd 100644
> --- a/tools/testing/selftests/powerpc/benchmarks/exec_target.c
> +++ b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
> @@ -7,10 +7,22 @@
> */
>
> #define _GNU_SOURCE
> -#include <unistd.h>
> #include <sys/syscall.h>
>
> void _start(void)
> {
> - syscall(SYS_exit, 0);
> + asm volatile (
> + "li %%r0, %[sys_exit];"
> + "li %%r3, 0;"
> + "sc;"
> + :
> + : [sys_exit] "i" (SYS_exit)
> + /*
> + * "sc" will clobber r0, r3-r13, cr0, ctr, xer and memory.
> + * Even though sys_exit never returns, handle clobber
> + * registers.
> + */
> + : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
> + "r11", "r12", "r13", "cr0", "ctr", "xer", "memory"
> + );
> }
> --
> 2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftest/powerpc/benchmark: remove requirement libc-dev
2024-08-13 7:41 ` Michael Ellerman
@ 2024-08-16 3:31 ` Madhavan Srinivasan
0 siblings, 0 replies; 4+ messages in thread
From: Madhavan Srinivasan @ 2024-08-16 3:31 UTC (permalink / raw)
To: Michael Ellerman, npiggin, christophe.leroy, shuah
Cc: linuxppc-dev, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 3294 bytes --]
On 8/13/24 1:11 PM, Michael Ellerman wrote:
> Madhavan Srinivasan<maddy@linux.ibm.com> writes:
>> Currently exec-target.c file is linked as static and this
>> post a requirement to install libc dev package to build.
> I think specifically the problem is that the test requires a static
> libc, which is packaged separately in some distros from the regular libc
> headers, am I right?
Thats right
> On Fedora the package is glibc-static, as opposed to glibc-devel, which
> the tests still require.
>
> So this patch removes the requirement to have glibc-static installed.
> Any idea what the package is called on Debian/Ubuntu?
This is what i could find in ubuntu VM, package is "libgcc-13-dev"
Description about this package
Binary package "libgcc-13-dev" in ubuntu noble Noble (24.04)
libgcc-13-dev GCC support library (development files) This package
contains the headers and static library files necessary for building C
programs which use libgcc, libgomp, libquadmath, libssp or libitm.
Maddy
>
> cheers
>
>> Without it, build-break when compiling selftest/powerpc/benchmark.
>>
>> CC exec_target
>> /usr/bin/ld: cannot find -lc: No such file or directory
>> collect2: error: ld returned 1 exit status
>>
>> exec_target.c is using "syscall" library function which
>> could be replaced with a inline assembly and the same is
>> proposed as a fix here.
>>
>> Suggested-by: Michael Ellerman<mpe@ellerman.id.au>
>> Signed-off-by: Madhavan Srinivasan<maddy@linux.ibm.com>
>> ---
>> Chnagelog v1:
>> - Add comment for clobber register and proper list of
>> clobber registers as suggested by Michael Ellerman and
>> Christophe Leroy
>>
>> .../selftests/powerpc/benchmarks/Makefile | 2 +-
>> .../selftests/powerpc/benchmarks/exec_target.c | 16 ++++++++++++++--
>> 2 files changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
>> index 1321922038d0..ca4483c238b9 100644
>> --- a/tools/testing/selftests/powerpc/benchmarks/Makefile
>> +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
>> @@ -18,4 +18,4 @@ $(OUTPUT)/context_switch: LDLIBS += -lpthread
>>
>> $(OUTPUT)/fork: LDLIBS += -lpthread
>>
>> -$(OUTPUT)/exec_target: CFLAGS += -static -nostartfiles
>> +$(OUTPUT)/exec_target: CFLAGS += -nostartfiles
>> diff --git a/tools/testing/selftests/powerpc/benchmarks/exec_target.c b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
>> index c14b0fc1edde..a6408d3f26cd 100644
>> --- a/tools/testing/selftests/powerpc/benchmarks/exec_target.c
>> +++ b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
>> @@ -7,10 +7,22 @@
>> */
>>
>> #define _GNU_SOURCE
>> -#include <unistd.h>
>> #include <sys/syscall.h>
>>
>> void _start(void)
>> {
>> - syscall(SYS_exit, 0);
>> + asm volatile (
>> + "li %%r0, %[sys_exit];"
>> + "li %%r3, 0;"
>> + "sc;"
>> + :
>> + : [sys_exit] "i" (SYS_exit)
>> + /*
>> + * "sc" will clobber r0, r3-r13, cr0, ctr, xer and memory.
>> + * Even though sys_exit never returns, handle clobber
>> + * registers.
>> + */
>> + : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
>> + "r11", "r12", "r13", "cr0", "ctr", "xer", "memory"
>> + );
>> }
>> --
>> 2.45.2
[-- Attachment #2: Type: text/html, Size: 4981 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftest/powerpc/benchmark: remove requirement libc-dev
2024-08-12 9:41 [PATCH v2] selftest/powerpc/benchmark: remove requirement libc-dev Madhavan Srinivasan
2024-08-13 7:41 ` Michael Ellerman
@ 2024-09-12 12:00 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2024-09-12 12:00 UTC (permalink / raw)
To: mpe, npiggin, christophe.leroy, shuah, Madhavan Srinivasan
Cc: linuxppc-dev, linux-kselftest
On Mon, 12 Aug 2024 15:11:52 +0530, Madhavan Srinivasan wrote:
> Currently exec-target.c file is linked as static and this
> post a requirement to install libc dev package to build.
> Without it, build-break when compiling selftest/powerpc/benchmark.
>
> CC exec_target
> /usr/bin/ld: cannot find -lc: No such file or directory
> collect2: error: ld returned 1 exit status
>
> [...]
Applied to powerpc/next.
[1/1] selftest/powerpc/benchmark: remove requirement libc-dev
https://git.kernel.org/powerpc/c/8c9c01ce695eea84d19482e7429e3d54ceb7585c
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-12 12:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 9:41 [PATCH v2] selftest/powerpc/benchmark: remove requirement libc-dev Madhavan Srinivasan
2024-08-13 7:41 ` Michael Ellerman
2024-08-16 3:31 ` Madhavan Srinivasan
2024-09-12 12:00 ` Michael Ellerman
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).