All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ltp: fix build with ld-is-gold in DISTRO_FEATURES
@ 2022-07-28 11:40 Martin Jansa
  2022-07-28 11:40 ` [RFC][PATCH] bitbake.conf: introduce LINKER/BUILD_LINKER variables Martin Jansa
  2022-07-28 11:40 ` [RFC][PATCH] bitbake.conf: change TOOLCHAIN_OPTIONS not to start with space Martin Jansa
  0 siblings, 2 replies; 4+ messages in thread
From: Martin Jansa @ 2022-07-28 11:40 UTC (permalink / raw)
  To: openembedded-core; +Cc: petr.vorel, Martin Jansa

* backport one more commit for LD call which conflicts with the
  0001-kvm-use-LD-instead-of-hardcoding-ld.patch we already had
  and replace this 2nd patch with the rebased version which is
  now merged upstream

* then backport additional patch which introduces KVM_LD variable
  which we can set to use .bfd suffix in LD when ld-is-gold is
  in DISTRO_FEATURES to work around gold incompatibility reported:
  https://github.com/linux-test-project/ltp/pull/948#issuecomment-1193138866
  https://lists.openembedded.org/g/openembedded-core/message/168193

  http://errors.yoctoproject.org/Errors/Details/663094/

  x86_64-oe-linux-ld --sysroot=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/ltp/20220527-r0/recipe-sysroot   -z noexecstack -r -T /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/ltp/20220527-r0/git/testcases/kernel/kvm/linker/payload.lds --oformat=elf64-x86-64 -o kvm_pagefault01-payload.o kvm_pagefault01-payload.bin
  x86_64-oe-linux-ld: error: kvm_pagefault01-payload.bin:1:1: invalid character
  make: *** [Makefile:53: kvm_pagefault01-payload.o] Error 1

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 depends on "ltp: Add post release runtime fixes" change currently in master-next:
 https://git.openembedded.org/openembedded-core/commit/?h=master-next&id=024ce059a64eb2f96dce2880e5708afd25dd45f2

 ...-access-mode-in-KVM-test-ELF-headers.patch | 40 ++++++++++++
 ...kvm-use-LD-instead-of-hardcoding-ld.patch} | 26 ++++----
 ...ile-variable-for-building-KVM-payloa.patch | 63 +++++++++++++++++++
 meta/recipes-extended/ltp/ltp_20220527.bb     | 13 +++-
 4 files changed, 128 insertions(+), 14 deletions(-)
 create mode 100644 meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch
 rename meta/recipes-extended/ltp/ltp/{0001-kvm-use-LD-instead-of-hardcoding-ld.patch => 0002-kvm-use-LD-instead-of-hardcoding-ld.patch} (60%)
 create mode 100644 meta/recipes-extended/ltp/ltp/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch

diff --git a/meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch b/meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch
new file mode 100644
index 0000000000..764e9c0d9f
--- /dev/null
+++ b/meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch
@@ -0,0 +1,40 @@
+From 608fc7bcda43e60536ae1f19842f7affba8f0aea Mon Sep 17 00:00:00 2001
+From: Martin Doucha <mdoucha@suse.cz>
+Date: Wed, 1 Jun 2022 16:16:34 +0200
+Subject: [PATCH] kvm: Fix stack access mode in KVM test ELF headers
+
+When the linker converts guest payload binary into a linkable resource
+object file, it somehow defaults to requesting executable stack section
+for the final test binary. This trips some build-time security checks
+on newer systems. Add explicit linker option to make the stack
+non-executable.
+
+Suggested-by: Fabian Vogt <fvogt@suse.com>
+Signed-off-by: Martin Doucha <mdoucha@suse.cz>
+Reviewed-by: Petr Vorel <pvorel@suse.cz>
+Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/f9715d7c2e78713e26533c6e0846aaabf5c4095b]
+---
+ 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..adab56952 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 -z noexecstack -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 -z noexecstack -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
diff --git a/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch b/meta/recipes-extended/ltp/ltp/0002-kvm-use-LD-instead-of-hardcoding-ld.patch
similarity index 60%
rename from meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
rename to meta/recipes-extended/ltp/ltp/0002-kvm-use-LD-instead-of-hardcoding-ld.patch
index 23634d0c86..060ba05835 100644
--- a/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch
+++ b/meta/recipes-extended/ltp/ltp/0002-kvm-use-LD-instead-of-hardcoding-ld.patch
@@ -1,7 +1,4 @@
-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 1cea308a647c2a2f9790b0bac7c523de7aa83270 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
@@ -9,29 +6,34 @@ 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.
 
+Closes: https://github.com/linux-test-project/ltp/pull/948
+
+Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/f94e0ef3b7280f886384703ef9019aaf2f2dfebb]
 Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+Reviewed-by: Petr Vorel <pvorel@suse.cz>
+Reviewed-by: Martin Doucha <mdoucha@suse.cz>
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.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
+index adab56952..d67230735 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
+-	ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
++	$(LD) -z noexecstack -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
+-	@ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
++	@$(LD) -z noexecstack -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/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch b/meta/recipes-extended/ltp/ltp/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch
new file mode 100644
index 0000000000..974ca5eebe
--- /dev/null
+++ b/meta/recipes-extended/ltp/ltp/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch
@@ -0,0 +1,63 @@
+From a8d41b7937a34904611011ca357f8db880d42270 Mon Sep 17 00:00:00 2001
+From: Martin Doucha <mdoucha@suse.cz>
+Date: Mon, 25 Jul 2022 17:37:27 +0200
+Subject: [PATCH] Add KVM_LD Makefile variable for building KVM payload
+ binaries
+
+KVM linker needs to be configurable for cross-compiling but some
+linkers don't support the linker script for wrapping arbitrary files
+into linkable resource files. Allow KVM linker to be changed
+independently of $LD via $KVM_LD.
+
+Signed-off-by: Martin Doucha <mdoucha@suse.cz>
+Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
+
+Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/5ef0b7892a17b64040e55e9ad62d36ebb75d33fd]
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+---
+ doc/build-system-guide.txt    | 5 +++++
+ testcases/kernel/kvm/Makefile | 5 +++--
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/doc/build-system-guide.txt b/doc/build-system-guide.txt
+index 166f7fb92..b8d267b4b 100644
+--- a/doc/build-system-guide.txt
++++ b/doc/build-system-guide.txt
+@@ -145,6 +145,11 @@ $(CPPFLAGS)		: Preprocessor flags, e.g. -I arguments.
+ 
+ $(DEBUG_CFLAGS)		: Debug flags to pass to $(CC), -g, etc.
+ 
++$(KVM_LD)		: Special linker for wrapping KVM payload binaries
++			  into linkable object files. Defaults to $(LD).
++			  Change this variable if the KVM Makefile fails
++			  to build files named *-payload.o.
++
+ $(LD)			: The system linker (typically $(CC), but not
+ 			  necessarily).
+ 
+diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
+index d67230735..31f144c26 100644
+--- a/testcases/kernel/kvm/Makefile
++++ b/testcases/kernel/kvm/Makefile
+@@ -11,6 +11,7 @@ GUEST_CPPFLAGS = $(CPPFLAGS) -DCOMPILE_PAYLOAD
+ GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse
+ GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none
+ GUEST_LDLIBS =
++KVM_LD ?= $(LD)
+ 
+ FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86
+ 
+@@ -50,11 +51,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) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
++	$(KVM_LD) -z noexecstack -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) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
++	@$(KVM_LD) -z noexecstack -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
diff --git a/meta/recipes-extended/ltp/ltp_20220527.bb b/meta/recipes-extended/ltp/ltp_20220527.bb
index d07563c4e1..b0f4ea6021 100644
--- a/meta/recipes-extended/ltp/ltp_20220527.bb
+++ b/meta/recipes-extended/ltp/ltp_20220527.bb
@@ -28,7 +28,9 @@ 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 \
+           file://0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch \
+           file://0002-kvm-use-LD-instead-of-hardcoding-ld.patch \
+           file://0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch \
            file://0001-nfs05_make_tree-Restore-5-min-timeout.patch \
            file://0001-syscalls-migrate_pages03-restore-runtime-to-5m.patch \
            file://0001-mountns0-1-3-wait-for-umount-completed-in-thread_b.patch \
@@ -47,6 +49,13 @@ inherit autotools-brokensep pkgconfig
 # https://github.com/linux-test-project/ltp/commit/3fce2064b54843218d085aae326c8f7ecf3a8c41#diff-39268f0855c634ca48c8993fcd2c95b12a65b79e8d9fa5ccd6b0f5a8785c0dd6R36
 LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}"
 
+# After 0002-kvm-use-LD-instead-of-hardcoding-ld.patch
+# https://github.com/linux-test-project/ltp/commit/f94e0ef3b7280f886384703ef9019aaf2f2dfebb
+# it fails with gold also a bit later when trying to use *-payload.bin
+# http://errors.yoctoproject.org/Errors/Details/663094/
+# work around this by forcing .bfd linked in LD when ld-is-gold is in DISTRO_FEATURES
+KVM_LD = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '${HOST_PREFIX}ld.bfd${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}', '${LD}', d)}"
+
 TARGET_CC_ARCH += "${LDFLAGS}"
 
 export prefix = "/opt/${PN}"
@@ -59,7 +68,7 @@ EXTRA_OECONF = " --with-realtime-testsuite --with-open-posix-testsuite "
 EXTRA_OECONF += " --without-tirpc "
 
 do_compile() {
-    oe_runmake HOSTCC="${CC_FOR_BUILD}" HOST_CFLAGS="${CFLAGS_FOR_BUILD}" HOST_LDFLAGS="${LDFLAGS_FOR_BUILD}"
+    oe_runmake HOSTCC="${CC_FOR_BUILD}" HOST_CFLAGS="${CFLAGS_FOR_BUILD}" HOST_LDFLAGS="${LDFLAGS_FOR_BUILD}" KVM_LD="${KVM_LD}"
 }
 
 do_install(){


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

* [RFC][PATCH] bitbake.conf: introduce LINKER/BUILD_LINKER variables
  2022-07-28 11:40 [PATCH] ltp: fix build with ld-is-gold in DISTRO_FEATURES Martin Jansa
@ 2022-07-28 11:40 ` Martin Jansa
  2022-07-28 21:43   ` [OE-core] " Khem Raj
  2022-07-28 11:40 ` [RFC][PATCH] bitbake.conf: change TOOLCHAIN_OPTIONS not to start with space Martin Jansa
  1 sibling, 1 reply; 4+ messages in thread
From: Martin Jansa @ 2022-07-28 11:40 UTC (permalink / raw)
  To: openembedded-core; +Cc: petr.vorel, Martin Jansa

* makes it a bit easier to replace ld with ld.bfd or some other implementation
  in LD/BUILD_LD variables without changing this whole variable and without
  depending on ld-is-gold to set ld symlink to preferred implementation (or
  when we want to force different one for specific recipe, e.g. forcing bfd
  where gold fails, like in ltp)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/conf/bitbake.conf | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 1d36aae8b3..1c2ebf333e 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -553,7 +553,8 @@ export CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
 export CXX = "${CCACHE}${HOST_PREFIX}g++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
 export FC = "${CCACHE}${HOST_PREFIX}gfortran ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
 export CPP = "${HOST_PREFIX}gcc -E${TOOLCHAIN_OPTIONS} ${HOST_CC_ARCH}"
-export LD = "${HOST_PREFIX}ld${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
+LINKER = "ld"
+export LD = "${HOST_PREFIX}${LINKER}${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
 export CCLD = "${CC}"
 export AR = "${HOST_PREFIX}gcc-ar"
 export AS = "${HOST_PREFIX}as ${HOST_AS_ARCH}"
@@ -570,7 +571,8 @@ export BUILD_CC = "${CCACHE}${BUILD_PREFIX}gcc ${BUILD_CC_ARCH}"
 export BUILD_CXX = "${CCACHE}${BUILD_PREFIX}g++ ${BUILD_CC_ARCH}"
 export BUILD_FC = "${CCACHE}${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH}"
 export BUILD_CPP = "${BUILD_PREFIX}gcc ${BUILD_CC_ARCH} -E"
-export BUILD_LD = "${BUILD_PREFIX}ld ${BUILD_LD_ARCH}"
+BUILD_LINKER = "ld"
+export BUILD_LD = "${BUILD_PREFIX}${BUILD_LINKER} ${BUILD_LD_ARCH}"
 export BUILD_CCLD = "${BUILD_PREFIX}gcc ${BUILD_CC_ARCH}"
 export BUILD_AR = "${BUILD_PREFIX}ar"
 export BUILD_AS = "${BUILD_PREFIX}as ${BUILD_AS_ARCH}"


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

* [RFC][PATCH] bitbake.conf: change TOOLCHAIN_OPTIONS not to start with space
  2022-07-28 11:40 [PATCH] ltp: fix build with ld-is-gold in DISTRO_FEATURES Martin Jansa
  2022-07-28 11:40 ` [RFC][PATCH] bitbake.conf: introduce LINKER/BUILD_LINKER variables Martin Jansa
@ 2022-07-28 11:40 ` Martin Jansa
  1 sibling, 0 replies; 4+ messages in thread
From: Martin Jansa @ 2022-07-28 11:40 UTC (permalink / raw)
  To: openembedded-core; +Cc: petr.vorel, Martin Jansa

* it was introduced this way in 2007:
  https://git.openembedded.org/openembedded-core/commit/?id=0138501213f140198abdead3ffa6b3ba80462c98
  but now there are quite a few places which use it after a space (which doesn't hurt):
  meta/classes/cmake.bbclass:OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}"
  meta/classes/cmake.bbclass:OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}"
  meta/classes/cmake.bbclass:OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}"
  meta/classes/cmake.bbclass:OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}"
  meta/classes/kernel-yocto.bbclass:  CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" LD="${KERNEL_LD}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1
  meta/recipes-bsp/u-boot/u-boot.inc:EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1'
  meta/recipes-devtools/diffstat/diffstat_1.64.bb:LDFLAGS += "${TOOLCHAIN_OPTIONS}"
  meta/recipes-devtools/go/go-runtime.inc:GO_EXTLDFLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
  meta/recipes-extended/wget/wget.inc:EXTRA_OEMAKE += 'TOOLCHAIN_OPTIONS="${TOOLCHAIN_OPTIONS}" \
  meta/recipes-kernel/linux/linux-yocto.inc:KERNEL_CC:append:aarch64 = " ${TOOLCHAIN_OPTIONS}"
  meta/recipes-kernel/linux/linux-yocto.inc:KERNEL_LD:append:aarch64 = " ${TOOLCHAIN_OPTIONS}"
  meta/recipes-kernel/linux/linux-yocto.inc:KERNEL_CC:append:nios2 = " ${TOOLCHAIN_OPTIONS}"
  meta/recipes-kernel/linux/linux-yocto.inc:KERNEL_LD:append:nios2 = " ${TOOLCHAIN_OPTIONS}"
  meta/recipes-kernel/linux/linux-yocto.inc:KERNEL_CC:append:arc = " ${TOOLCHAIN_OPTIONS}"
  meta/recipes-kernel/linux/linux-yocto.inc:KERNEL_LD:append:arc = " ${TOOLCHAIN_OPTIONS}"

  not using space now seems a bit strange to me (noticed when trying to prepend
  something to TOOLCHAIN_OPTIONS)

* it made more sense when default TOOLCHAIN_OPTIONS were empty, but
  since 2010 it's almost always used to set --sysroot:
  https://git.openembedded.org/openembedded-core/commit/?id=6124cccddfc202124fa76bb677ad3e06f0fefc70

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/classes/cross-canadian.bbclass            |  2 +-
 meta/classes/go.bbclass                        |  2 +-
 meta/conf/bitbake.conf                         | 12 ++++++------
 meta/recipes-devtools/go/go-runtime.inc        |  2 +-
 meta/recipes-extended/ltp/ltp_20220527.bb      |  2 +-
 meta/recipes-multimedia/ffmpeg/ffmpeg_5.0.1.bb |  2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/meta/classes/cross-canadian.bbclass b/meta/classes/cross-canadian.bbclass
index a0e9d23836..686646357c 100644
--- a/meta/classes/cross-canadian.bbclass
+++ b/meta/classes/cross-canadian.bbclass
@@ -104,7 +104,7 @@ INHIBIT_DEFAULT_DEPS = "1"
 
 STAGING_DIR_HOST = "${RECIPE_SYSROOT}"
 
-TOOLCHAIN_OPTIONS = " --sysroot=${RECIPE_SYSROOT}"
+TOOLCHAIN_OPTIONS = "--sysroot=${RECIPE_SYSROOT}"
 
 PATH:append = ":${TMPDIR}/sysroots/${HOST_ARCH}/${bindir_cross}"
 PKGHIST_DIR = "${TMPDIR}/pkghistory/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}/"
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index cd2daed70b..c6b38bd294 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -40,7 +40,7 @@ GO_RPATH_LINK = "${@'-Wl,-rpath-link=${STAGING_DIR_TARGET}${libdir}/go/pkg/${TAR
 GO_RPATH = "${@'-r ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}"
 GO_RPATH:class-native = "${@'-r ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}"
 GO_RPATH_LINK:class-native = "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}"
-GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}"
+GO_EXTLDFLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}"
 GO_LINKMODE ?= ""
 GO_LINKMODE:class-nativesdk = "--linkmode=external"
 GO_LINKMODE:class-native = "--linkmode=external"
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 1c2ebf333e..27478b1107 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -547,14 +547,14 @@ HOSTTOOLS_NONFATAL += "git-lfs"
 
 CCACHE ??= ""
 
-TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TARGET}"
+TOOLCHAIN_OPTIONS = "--sysroot=${STAGING_DIR_TARGET}"
 
-export CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
-export CXX = "${CCACHE}${HOST_PREFIX}g++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
-export FC = "${CCACHE}${HOST_PREFIX}gfortran ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
-export CPP = "${HOST_PREFIX}gcc -E${TOOLCHAIN_OPTIONS} ${HOST_CC_ARCH}"
+export CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
+export CXX = "${CCACHE}${HOST_PREFIX}g++ ${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
+export FC = "${CCACHE}${HOST_PREFIX}gfortran ${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
+export CPP = "${HOST_PREFIX}gcc -E ${TOOLCHAIN_OPTIONS} ${HOST_CC_ARCH}"
 LINKER = "ld"
-export LD = "${HOST_PREFIX}${LINKER}${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
+export LD = "${HOST_PREFIX}${LINKER} ${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
 export CCLD = "${CC}"
 export AR = "${HOST_PREFIX}gcc-ar"
 export AS = "${HOST_PREFIX}as ${HOST_AS_ARCH}"
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index e18339cddb..d1846707cc 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -14,7 +14,7 @@ export CGO_CXXFLAGS = "${CXXFLAGS}"
 export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }"
 export GOCACHE = "${B}/.cache"
 
-GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
+GO_EXTLDFLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
 GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"'
 
 do_configure() {
diff --git a/meta/recipes-extended/ltp/ltp_20220527.bb b/meta/recipes-extended/ltp/ltp_20220527.bb
index b0f4ea6021..aa64385846 100644
--- a/meta/recipes-extended/ltp/ltp_20220527.bb
+++ b/meta/recipes-extended/ltp/ltp_20220527.bb
@@ -54,7 +54,7 @@ LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-
 # it fails with gold also a bit later when trying to use *-payload.bin
 # http://errors.yoctoproject.org/Errors/Details/663094/
 # work around this by forcing .bfd linked in LD when ld-is-gold is in DISTRO_FEATURES
-KVM_LD = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '${HOST_PREFIX}ld.bfd${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}', '${LD}', d)}"
+KVM_LD = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '${HOST_PREFIX}ld.bfd ${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}', '${LD}', d)}"
 
 TARGET_CC_ARCH += "${LDFLAGS}"
 
diff --git a/meta/recipes-multimedia/ffmpeg/ffmpeg_5.0.1.bb b/meta/recipes-multimedia/ffmpeg/ffmpeg_5.0.1.bb
index dd14f8df6f..a2f85b1fe9 100644
--- a/meta/recipes-multimedia/ffmpeg/ffmpeg_5.0.1.bb
+++ b/meta/recipes-multimedia/ffmpeg/ffmpeg_5.0.1.bb
@@ -108,7 +108,7 @@ EXTRA_OECONF = " \
     --arch=${TARGET_ARCH} \
     --target-os='linux' \
     --enable-cross-compile \
-    --extra-cflags='${CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}' \
+    --extra-cflags='${CFLAGS} ${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}' \
     --extra-ldflags='${LDFLAGS}' \
     --sysroot='${STAGING_DIR_TARGET}' \
     ${EXTRA_FFCONF} \


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

* Re: [OE-core] [RFC][PATCH] bitbake.conf: introduce LINKER/BUILD_LINKER variables
  2022-07-28 11:40 ` [RFC][PATCH] bitbake.conf: introduce LINKER/BUILD_LINKER variables Martin Jansa
@ 2022-07-28 21:43   ` Khem Raj
  0 siblings, 0 replies; 4+ messages in thread
From: Khem Raj @ 2022-07-28 21:43 UTC (permalink / raw)
  To: Martin Jansa; +Cc: openembedded-core, petr.vorel

[-- Attachment #1: Type: text/plain, Size: 2609 bytes --]

On Thu, Jul 28, 2022 at 7:41 AM Martin Jansa <Martin.Jansa@gmail.com> wrote:

> * makes it a bit easier to replace ld with ld.bfd or some other
> implementation
>   in LD/BUILD_LD variables without changing this whole variable and without
>   depending on ld-is-gold to set ld symlink to preferred implementation (or
>   when we want to force different one for specific recipe, e.g. forcing bfd
>   where gold fails, like in ltp)


This is fixing bare ld calls but there are perhaps handful of recipes where
bare ld is used in most of the cases we rely on compiler driver to do the
linking and this confuses that use case.


>
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  meta/conf/bitbake.conf | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 1d36aae8b3..1c2ebf333e 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -553,7 +553,8 @@ export CC = "${CCACHE}${HOST_PREFIX}gcc
> ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
>  export CXX = "${CCACHE}${HOST_PREFIX}g++
> ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
>  export FC = "${CCACHE}${HOST_PREFIX}gfortran
> ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
>  export CPP = "${HOST_PREFIX}gcc -E${TOOLCHAIN_OPTIONS} ${HOST_CC_ARCH}"
> -export LD = "${HOST_PREFIX}ld${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
> +LINKER = "ld"
> +export LD = "${HOST_PREFIX}${LINKER}${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
>  export CCLD = "${CC}"
>  export AR = "${HOST_PREFIX}gcc-ar"
>  export AS = "${HOST_PREFIX}as ${HOST_AS_ARCH}"
> @@ -570,7 +571,8 @@ export BUILD_CC = "${CCACHE}${BUILD_PREFIX}gcc
> ${BUILD_CC_ARCH}"
>  export BUILD_CXX = "${CCACHE}${BUILD_PREFIX}g++ ${BUILD_CC_ARCH}"
>  export BUILD_FC = "${CCACHE}${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH}"
>  export BUILD_CPP = "${BUILD_PREFIX}gcc ${BUILD_CC_ARCH} -E"
> -export BUILD_LD = "${BUILD_PREFIX}ld ${BUILD_LD_ARCH}"
> +BUILD_LINKER = "ld"
> +export BUILD_LD = "${BUILD_PREFIX}${BUILD_LINKER} ${BUILD_LD_ARCH}"
>  export BUILD_CCLD = "${BUILD_PREFIX}gcc ${BUILD_CC_ARCH}"
>  export BUILD_AR = "${BUILD_PREFIX}ar"
>  export BUILD_AS = "${BUILD_PREFIX}as ${BUILD_AS_ARCH}"
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#168601):
> https://lists.openembedded.org/g/openembedded-core/message/168601
> Mute This Topic: https://lists.openembedded.org/mt/92668261/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

[-- Attachment #2: Type: text/html, Size: 3936 bytes --]

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

end of thread, other threads:[~2022-07-28 21:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 11:40 [PATCH] ltp: fix build with ld-is-gold in DISTRO_FEATURES Martin Jansa
2022-07-28 11:40 ` [RFC][PATCH] bitbake.conf: introduce LINKER/BUILD_LINKER variables Martin Jansa
2022-07-28 21:43   ` [OE-core] " Khem Raj
2022-07-28 11:40 ` [RFC][PATCH] bitbake.conf: change TOOLCHAIN_OPTIONS not to start with space Martin Jansa

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.