diff mbox series

ltp: fix builds when host ld doesn't know about target ELF formats

Message ID 20220712143734.204094-1-ross.burton@arm.com
State Accepted, archived
Commit 4065c5b69830ea81fbde23263ece55f6f12e5d71
Headers show
Series ltp: fix builds when host ld doesn't know about target ELF formats | expand

Commit Message

Ross Burton July 12, 2022, 2:37 p.m. UTC
The kvm tests use the host ld, which doesn't necessarily know about the
target ELF format.  It should be using the cross ld we built, so call
$(LD) instead.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 ...-kvm-use-LD-instead-of-hardcoding-ld.patch | 37 +++++++++++++++++++
 meta/recipes-extended/ltp/ltp_20220527.bb     |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch

Comments

Khem Raj July 12, 2022, 3:28 p.m. UTC | #1
the ltp patch is upstream worthy. Have you thought about sending it to
the ltp community ?

On Tue, Jul 12, 2022 at 3:37 PM Ross Burton <ross.burton@arm.com> wrote:
>
> The kvm tests use the host ld, which doesn't necessarily know about the
> target ELF format.  It should be using the cross ld we built, so call
> $(LD) instead.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  ...-kvm-use-LD-instead-of-hardcoding-ld.patch | 37 +++++++++++++++++++
>  meta/recipes-extended/ltp/ltp_20220527.bb     |  1 +
>  2 files changed, 38 insertions(+)
>  create mode 100644 meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
>
> diff --git a/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch b/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
> new file mode 100644
> index 00000000000..23634d0c860
> --- /dev/null
> +++ b/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
> @@ -0,0 +1,37 @@
> +Upstream-Status: Submitted [https://github.com/linux-test-project/ltp/pull/948]
> +Signed-off-by: Ross Burton <ross.burton@arm.com>
> +
> +From 7670233e43df2aed6d44b96c51b034f8e2d28a19 Mon Sep 17 00:00:00 2001
> +From: Ross Burton <ross.burton@arm.com>
> +Date: Tue, 12 Jul 2022 15:03:54 +0100
> +Subject: [PATCH] kvm: use $(LD) instead of hardcoding ld
> +
> +In cross-compiled builds the host ld may not know the required ELF format,
> +so ensure we use $(LD) which will be the cross-capable ld binary.
> +
> +Signed-off-by: Ross Burton <ross.burton@arm.com>
> +---
> + testcases/kernel/kvm/Makefile | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
> +index 69a9946fe..4ddef9f95 100644
> +--- a/testcases/kernel/kvm/Makefile
> ++++ b/testcases/kernel/kvm/Makefile
> +@@ -50,11 +50,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk
> + ifdef VERBOSE
> +       $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS)
> +       objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin
> +-      ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
> ++      $(LD) -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
> + else
> +       @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS)
> +       @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin
> +-      @ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
> ++      @$(LD) -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
> +       @echo KVM_CC $(target_rel_dir)$@
> + endif
> +       @rm $*-payload.elf $*-payload.bin
> +--
> +2.34.1
> +
> diff --git a/meta/recipes-extended/ltp/ltp_20220527.bb b/meta/recipes-extended/ltp/ltp_20220527.bb
> index 56fa83f5a03..094251ec811 100644
> --- a/meta/recipes-extended/ltp/ltp_20220527.bb
> +++ b/meta/recipes-extended/ltp/ltp_20220527.bb
> @@ -28,6 +28,7 @@ SRCREV = "6f88e0f6f1d6eb12c48c902f50f47ecbd3b0f18a"
>  SRC_URI = "git://github.com/linux-test-project/ltp.git;branch=master;protocol=https \
>             file://0001-Remove-OOM-tests-from-runtest-mm.patch \
>             file://disable_hanging_tests.patch \
> +           file://0001-kvm-use-LD-instead-of-hardcoding-ld.patch \
>             "
>
>  S = "${WORKDIR}/git"
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#167929): https://lists.openembedded.org/g/openembedded-core/message/167929
> Mute This Topic: https://lists.openembedded.org/mt/92334178/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Martin Jansa July 18, 2022, 7:42 a.m. UTC | #2
FYI: This might be causing build issues with ld-is-gold:

| i686-webos-linux-ld: error: kvm_pagefault01-payload.bin:1:1: invalid
character
| ltp/20220527-r0/git/testcases/kernel/kvm/Makefile:55: recipe for target
'kvm_pagefault01-payload.o' failed
| make[3]: *** [kvm_pagefault01-payload.o] Error 1

The previous patch to use bfd:
https://git.openembedded.org/openembedded-core/commit/?id=674fd0c423f3a8911d73b4319ab23bd9b3f1bbac
was doing it only through -fuse-ld=bfd in LDFLAGS which doesn't seem to be
used here.

Will check if it was really caused by this change after my builder gets
online again (now in memtest86 with sad results).

Cheers,

On Tue, Jul 12, 2022 at 4:37 PM Ross Burton <ross.burton@arm.com> wrote:

> The kvm tests use the host ld, which doesn't necessarily know about the
> target ELF format.  It should be using the cross ld we built, so call
> $(LD) instead.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  ...-kvm-use-LD-instead-of-hardcoding-ld.patch | 37 +++++++++++++++++++
>  meta/recipes-extended/ltp/ltp_20220527.bb     |  1 +
>  2 files changed, 38 insertions(+)
>  create mode 100644
> meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
>
> diff --git
> a/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
> b/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
> new file mode 100644
> index 00000000000..23634d0c860
> --- /dev/null
> +++
> b/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
> @@ -0,0 +1,37 @@
> +Upstream-Status: Submitted [
> https://github.com/linux-test-project/ltp/pull/948]
> +Signed-off-by: Ross Burton <ross.burton@arm.com>
> +
> +From 7670233e43df2aed6d44b96c51b034f8e2d28a19 Mon Sep 17 00:00:00 2001
> +From: Ross Burton <ross.burton@arm.com>
> +Date: Tue, 12 Jul 2022 15:03:54 +0100
> +Subject: [PATCH] kvm: use $(LD) instead of hardcoding ld
> +
> +In cross-compiled builds the host ld may not know the required ELF format,
> +so ensure we use $(LD) which will be the cross-capable ld binary.
> +
> +Signed-off-by: Ross Burton <ross.burton@arm.com>
> +---
> + testcases/kernel/kvm/Makefile | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
> +index 69a9946fe..4ddef9f95 100644
> +--- a/testcases/kernel/kvm/Makefile
> ++++ b/testcases/kernel/kvm/Makefile
> +@@ -50,11 +50,11 @@ include $(top_srcdir)/include/mk/
> generic_leaf_target.mk
> + ifdef VERBOSE
> +       $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o
> $*-payload.elf $^ $(GUEST_LDLIBS)
> +       objcopy -O binary -j .init.boot -j .text -j .data -j .init -j
> .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin
> +-      ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT)
> -o $@ $*-payload.bin
> ++      $(LD) -r -T $(abs_srcdir)/linker/payload.lds
> --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
> + else
> +       @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o
> $*-payload.elf $^ $(GUEST_LDLIBS)
> +       @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j
> .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin
> +-      @ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT)
> -o $@ $*-payload.bin
> ++      @$(LD) -r -T $(abs_srcdir)/linker/payload.lds
> --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
> +       @echo KVM_CC $(target_rel_dir)$@
> + endif
> +       @rm $*-payload.elf $*-payload.bin
> +--
> +2.34.1
> +
> diff --git a/meta/recipes-extended/ltp/ltp_20220527.bb
> b/meta/recipes-extended/ltp/ltp_20220527.bb
> index 56fa83f5a03..094251ec811 100644
> --- a/meta/recipes-extended/ltp/ltp_20220527.bb
> +++ b/meta/recipes-extended/ltp/ltp_20220527.bb
> @@ -28,6 +28,7 @@ SRCREV = "6f88e0f6f1d6eb12c48c902f50f47ecbd3b0f18a"
>  SRC_URI = "git://
> github.com/linux-test-project/ltp.git;branch=master;protocol=https \
>             file://0001-Remove-OOM-tests-from-runtest-mm.patch \
>             file://disable_hanging_tests.patch \
> +           file://0001-kvm-use-LD-instead-of-hardcoding-ld.patch \
>             "
>
>  S = "${WORKDIR}/git"
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#167929):
> https://lists.openembedded.org/g/openembedded-core/message/167929
> Mute This Topic: https://lists.openembedded.org/mt/92334178/3617156
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> Martin.Jansa@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Ross Burton July 18, 2022, 9:35 a.m. UTC | #3
On 12 Jul 2022, at 16:28, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
> 
> the ltp patch is upstream worthy. Have you thought about sending it to
> the ltp community ?

See the patch header:

>> +Upstream-Status: Submitted [https://github.com/linux-test-project/ltp/pull/948]


That should now be Backport, as it’s been merged.

Ross
diff mbox series

Patch

diff --git a/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch b/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
new file mode 100644
index 00000000000..23634d0c860
--- /dev/null
+++ b/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
@@ -0,0 +1,37 @@ 
+Upstream-Status: Submitted [https://github.com/linux-test-project/ltp/pull/948]
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+From 7670233e43df2aed6d44b96c51b034f8e2d28a19 Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton@arm.com>
+Date: Tue, 12 Jul 2022 15:03:54 +0100
+Subject: [PATCH] kvm: use $(LD) instead of hardcoding ld
+
+In cross-compiled builds the host ld may not know the required ELF format,
+so ensure we use $(LD) which will be the cross-capable ld binary.
+
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ testcases/kernel/kvm/Makefile | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
+index 69a9946fe..4ddef9f95 100644
+--- a/testcases/kernel/kvm/Makefile
++++ b/testcases/kernel/kvm/Makefile
+@@ -50,11 +50,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk
+ ifdef VERBOSE
+ 	$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS)
+ 	objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin
+-	ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
++	$(LD) -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
+ else
+ 	@$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS)
+ 	@objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin
+-	@ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
++	@$(LD) -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
+ 	@echo KVM_CC $(target_rel_dir)$@
+ endif
+ 	@rm $*-payload.elf $*-payload.bin
+-- 
+2.34.1
+
diff --git a/meta/recipes-extended/ltp/ltp_20220527.bb b/meta/recipes-extended/ltp/ltp_20220527.bb
index 56fa83f5a03..094251ec811 100644
--- a/meta/recipes-extended/ltp/ltp_20220527.bb
+++ b/meta/recipes-extended/ltp/ltp_20220527.bb
@@ -28,6 +28,7 @@  SRCREV = "6f88e0f6f1d6eb12c48c902f50f47ecbd3b0f18a"
 SRC_URI = "git://github.com/linux-test-project/ltp.git;branch=master;protocol=https \
            file://0001-Remove-OOM-tests-from-runtest-mm.patch \
            file://disable_hanging_tests.patch \
+           file://0001-kvm-use-LD-instead-of-hardcoding-ld.patch \
            "
 
 S = "${WORKDIR}/git"