* [PATCH] linux-yocto: build out-of-tree drivers with SDK
@ 2025-05-13 3:32 Vincent Davis Jr
2025-05-13 3:36 ` Vincent Davis Jr
0 siblings, 1 reply; 3+ messages in thread
From: Vincent Davis Jr @ 2025-05-13 3:32 UTC (permalink / raw)
To: openembedded-core; +Cc: Vincent Davis Jr
Attached patches enables the compilation
of out-of-tree drivers whilst utilizing
the Yocto built SDK.
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
---
...-add-KCFLAGS-to-build-with-Yocto-SDK.patch | 63 +++++++++++++++++++
meta/recipes-kernel/linux/linux-yocto.inc | 4 ++
2 files changed, 67 insertions(+)
create mode 100644 meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch
diff --git a/meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch b/meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch
new file mode 100644
index 0000000000..b556f25daf
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch
@@ -0,0 +1,63 @@
+From e48021f480428b5e34d299261029bfafdf0e3a2f Mon Sep 17 00:00:00 2001
+From: Vincent Davis Jr <vince@underview.tech>
+Date: Sun, 11 May 2025 19:57:46 -0400
+Subject: [PATCH] Makefile: add KCFLAGS to build with Yocto SDK
+
+When running
+
+make -C \
+"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \
+modules_prepare
+
+Issues that are encountered include
+
+make -f ./Makefile syncconfig
+make -f ./scripts/Makefile.build obj=scripts/basic
+ 92 | #include <sys/types.h>
+ | ^~~~~~~~~~~~~
+compilation terminated.
+
+ld: cannot find Scrt1.o: No such file or directory
+ld: cannot find crti.o: No such file or directory
+ld: cannot find crtbeginS.o: No such file or directory
+ld: cannot find -lgcc: No such file or directory
+ld: cannot find -lgcc_s: No such file or directory
+ld: cannot find -lc: No such file or directory
+ld: cannot find -lgcc: No such file or directory
+ld: cannot find -lgcc_s: No such file or directory
+ld: cannot find crtendS.o: No such file or directory
+ld: cannot find crtn.o: No such file or directory
+
+Solved by setting KCFLAGS as the yocto project SDK
+KCFLAGS is set to --sysroot="${SDKTARGETSYSROOT}".
+
+Signed-off-by: Vincent Davis Jr <vince@underview.tech>
+---
+ Makefile | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 64c514f4bc19..bbe7b0503841 100644
+--- a/Makefile
++++ b/Makefile
+@@ -459,7 +459,7 @@ HOSTRUSTC = rustc
+ HOSTPKG_CONFIG = pkg-config
+
+ KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
+- -O2 -fomit-frame-pointer -std=gnu11
++ -O2 -fomit-frame-pointer -std=gnu11 $(KCFLAGS)
+ KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
+ KBUILD_USERLDFLAGS := $(USERLDFLAGS)
+
+@@ -491,7 +491,7 @@ KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \
+ -I $(srctree)/scripts/include
+ KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
+ -Zallow-features= $(HOSTRUSTFLAGS)
+-KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
++KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) $(KCFLAGS)
+ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
+ KBUILD_PROCMACROLDFLAGS := $(or $(PROCMACROLDFLAGS),$(KBUILD_HOSTLDFLAGS))
+
+--
+2.43.0
+
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 389329030d..5f45ab2bc4 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -37,6 +37,10 @@ KERNEL_FEATURES:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'efi', 'cfg/
KERNEL_FEATURES:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'numa', 'features/numa/numa.scc', '', d)}"
KERNEL_FEATURES:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'vfat', 'cfg/fs/vfat.scc', '', d)}"
+# Appears to be the only way to build out-of-tree
+# kernel drivers with the yocto project SDK.
+SRC_URI += "file://0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch"
+
# A KMACHINE is the mapping of a yocto $MACHINE to what is built
# by the kernel. This is typically the branch that should be built,
# and it can be specific to the machine or shared
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-yocto: build out-of-tree drivers with SDK
2025-05-13 3:32 [PATCH] linux-yocto: build out-of-tree drivers with SDK Vincent Davis Jr
@ 2025-05-13 3:36 ` Vincent Davis Jr
2025-05-13 3:40 ` Vincent Davis Jr
0 siblings, 1 reply; 3+ messages in thread
From: Vincent Davis Jr @ 2025-05-13 3:36 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 292 bytes --]
Hello,
Wanted to propose fixing SDK out-of-tree kernel driver compilation problems.
Know a patch here may not be the best route as there's zero patches for a reason.
Wanted to know how we want to solve issue described in patch 0001-Makefile-add-KCFLAGS-to-build-with-Yocto-SDK.patch.
[-- Attachment #2: Type: text/html, Size: 370 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-yocto: build out-of-tree drivers with SDK
2025-05-13 3:36 ` Vincent Davis Jr
@ 2025-05-13 3:40 ` Vincent Davis Jr
0 siblings, 0 replies; 3+ messages in thread
From: Vincent Davis Jr @ 2025-05-13 3:40 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 105 bytes --]
Or do we want to just document it somewhere for future people?
Attempting to get above patch merged.
[-- Attachment #2: Type: text/html, Size: 144 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-13 3:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13 3:32 [PATCH] linux-yocto: build out-of-tree drivers with SDK Vincent Davis Jr
2025-05-13 3:36 ` Vincent Davis Jr
2025-05-13 3:40 ` Vincent Davis Jr
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.