Makefile: add KCFLAGS to build with Yocto SDK
PATCH 1/1 Makefile: add KCFLAGS to build with Yocto SDK
When running
make -C \
"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \modules_prepare
Issue 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}".
--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -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))
Signature · 1 line
2.43.0
Quoted 6 lines · Vincent Davis Jr
When running
make -C \
"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \modules_prepare
This is not the correct way to build an external module. Do not run modules_prepare.
Quoted 32 lines
Issue that are encountered include
make -f ./Makefile syncconfig
make -f./scripts/Makefile.buildobj=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 directorySolved by setting KCFLAGS as the yocto project SDK KCFLAGS is set to --sysroot="${SDKTARGETSYSROOT}".
Signed-off-by Vincent Davis Jr <[email protected]>--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +0
-0
Makefile HOSTRUSTC = rustc · line 462
Quoted 5 lines
Makefile +1
-1@@ -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)
Sorry, I do not understand what you are trying to achieve.
KCFLAGS is meant to specify compiler flags for the kernel-space, not userspace host programs.
Quoted 15 lines
Makefile +1
-2KBUILD_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
Signature · 2 lines
Best Regards Masahiro Yamada
Hello,
Sorry I should have given a better description. First kernel patch.
There appears to be a userspace program called fixdep.c. That won't compile when you utilize the yocto project SDK cross compilers. Problems are described in the original patch.
We have to run make modules_prepare as there's limits with the Yocto project kernel-devsrc package that gets included in the SDK.
After SDK extraction, developers have to first prepare the SDK's kernel source tree to be able to build any out of tree drivers with the SDK's cross-compilers. This wasn't achievable without the submitted patch.
Sorry for poor timing. I am going on vacation and can't respond due to emails needing to be in plain text. Please don't ignore future patches.
For instance if I run bellow commands
$ ./x86_64-0.1.0-underview.sh Underview SDK installer version 0.1.0 ===================================== Enter target directory for SDK (default: .): extract-sdk You are about to install the SDK to "/home/vince/extract-sdk". Proceed [Y/n]? Y Extracting SDK.............................................................................................................................................................................................................................................................................................................................................done Setting it up...done SDK has been successfully set up and is ready to be used. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /home/vince/extract-sdk/environment-setup-zen1-underview-linux
$ source /home/vince/extract-sdk/environment-setup-zen1-underview-linux
$ cd /home/vince/extract-sdk
$ ls sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build/
arch certs Documentation fs init ipc Kconfig lib
mm net samples security
System.map-6.6.9-amd-standard usr
block crypto drivers include io_uring Kbuild kernel
Makefile Module.symvers rust scripts sound tools
virt $ make -C sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build
modules_prepare
make: Entering directory
'/home/vince/extract-sdk/sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build'
SYNC include/config/auto.conf
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:92:10: fatal error: sys/types.h: No such file
or directory
92 | #include <sys/types.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[3]: *** [scripts/Makefile.host:114: scripts/basic/fixdep] Error 1
make[2]: *** [Makefile:633: scripts_basic] Error 2
make[1]: *** [/home/vince/extract-sdk/sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build/Makefile:798:
include/config/auto.conf] Error 2
make[1]: *** [include/config/auto.conf] Deleting file
'include/generated/rustc_cfg'
make[1]: *** [include/config/auto.conf] Deleting file
'include/generated/autoconf.h'
make: *** [Makefile:234: __sub-make] Error 2
make: Leaving directory
'/home/vince/extract-sdk/sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build'Hopefully makes sense
Quoted 82 lines · Masahiro Yamada
Quoted 6 lines · Vincent Davis Jr
When running
make -C \
"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \modules_prepareThis is not the correct way to build an external module. Do not run
modules_prepare.Quoted 32 lines
Issue that are encountered include
make -f ./Makefile syncconfig
make -f./scripts/Makefile.buildobj=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 directorySolved by setting KCFLAGS as the yocto project SDK KCFLAGS is set to --sysroot="${SDKTARGETSYSROOT}".
Signed-off-by Vincent Davis Jr <[email protected]>--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +0
-0Makefile HOSTRUSTC = rustc · line 462
Quoted 5 lines
Makefile +1
-1@@ -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)Sorry, I do not understand what you are trying to achieve.
KCFLAGS is meant to specify compiler flags for the kernel-space, not userspace host programs.
Quoted 13 lines
Makefile +1
-2KBUILD_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)) --Quoted 2 lines
2.43.0
--
Best Regards
Masahiro Yamada
Hello correction in previous comment.
After SDK extraction, developers have to first prepare the SDK's kernel source tree to be able to build any out of tree drivers with the SDK's cross-compilers and kernel source tree.
Thanks,
Vincent
Quoted 155 lines · Vincent Davis
Hello,
Sorry I should have given a better description. First kernel patch.
There appears to be a userspace program called
fixdep.c. That won't compile when you utilize the yocto project SDK cross compilers. Problems are described in the original patch.We have to run make
modules_prepareas there's limits with the Yocto project kernel-devsrc package that gets included in the SDK.After SDK extraction, developers have to first prepare the SDK's kernel source tree to be able to build any out of tree drivers with the SDK's cross-compilers. This wasn't achievable without the submitted patch.
Sorry for poor timing. I am going on vacation and can't respond due to emails needing to be in plain text. Please don't ignore future patches.
For instance if I run bellow commands
$ ./x86_64-0.1.0-underview.sh Underview SDK installer version 0.1.0 ===================================== Enter target directory for SDK (default: .): extract-sdk You are about to install the SDK to "/home/vince/extract-sdk". Proceed [Y/n]? Y Extracting SDK.............................................................................................................................................................................................................................................................................................................................................done Setting it up...done SDK has been successfully set up and is ready to be used. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /home/vince/extract-sdk/environment-setup-zen1-underview-linux$ source /home/vince/extract-sdk/environment-setup-zen1-underview-linux$ cd /home/vince/extract-sdk $ ls sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build/ arch certs Documentation fs init ipc Kconfig lib mm net samples security System.map-6.6.9-amd-standard usr block crypto drivers include io_uring Kbuild kernel Makefile Module.symvers rust scripts sound tools virt$ make -C sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build modules_prepare make: Entering directory '/home/vince/extract-sdk/sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build' SYNC include/config/auto.conf HOSTCC scripts/basic/fixdep scripts/basic/fixdep.c:92:10: fatal error: sys/types.h: No such file or directory 92 | #include <sys/types.h> | ^~~~~~~~~~~~~ compilation terminated. make[3]: *** [scripts/Makefile.host:114: scripts/basic/fixdep] Error 1 make[2]: *** [Makefile:633: scripts_basic] Error 2 make[1]: *** [/home/vince/extract-sdk/sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build/Makefile:798: include/config/auto.conf] Error 2 make[1]: *** [include/config/auto.conf] Deleting file 'include/generated/rustc_cfg' make[1]: *** [include/config/auto.conf] Deleting file 'include/generated/autoconf.h' make: *** [Makefile:234: __sub-make] Error 2 make: Leaving directory '/home/vince/extract-sdk/sysroots/zen1-underview-linux/usr/lib/modules/6.6.9-amd-standard/build'Hopefully makes sense
Quoted 82 lines · Masahiro Yamada
Quoted 6 lines · Vincent Davis Jr
When running
make -C \
"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \modules_prepareThis is not the correct way to build an external module. Do not run
modules_prepare.Quoted 32 lines
Issue that are encountered include
make -f ./Makefile syncconfig
make -f./scripts/Makefile.buildobj=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 directorySolved by setting KCFLAGS as the yocto project SDK KCFLAGS is set to --sysroot="${SDKTARGETSYSROOT}".
Signed-off-by Vincent Davis Jr <[email protected]>--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +0
-0Makefile HOSTRUSTC = rustc · line 462
Quoted 5 lines
Makefile +1
-1@@ -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)Sorry, I do not understand what you are trying to achieve.
KCFLAGS is meant to specify compiler flags for the kernel-space, not userspace host programs.
Quoted 13 lines
Makefile +1
-2KBUILD_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)) --Quoted 2 lines
2.43.0
--
Best Regards
Masahiro Yamada
Hello,
Patch can be ignored and dropped.
Believe the original issue has to do with the way I built the SDK.
Thanks,
Vincent
Quoted 82 lines · Masahiro Yamada
Quoted 6 lines · Vincent Davis Jr
When running
make -C \
"${SDKTARGETSYSROOT}/lib/modules/<kernel version>/build" \modules_prepareThis is not the correct way to build an external module. Do not run
modules_prepare.Quoted 32 lines
Issue that are encountered include
make -f ./Makefile syncconfig
make -f./scripts/Makefile.buildobj=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 directorySolved by setting KCFLAGS as the yocto project SDK KCFLAGS is set to --sysroot="${SDKTARGETSYSROOT}".
Signed-off-by Vincent Davis Jr <[email protected]>--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +0
-0Makefile HOSTRUSTC = rustc · line 462
Quoted 5 lines
Makefile +1
-1@@ -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)Sorry, I do not understand what you are trying to achieve.
KCFLAGS is meant to specify compiler flags for the kernel-space, not userspace host programs.
Quoted 13 lines
Makefile +1
-2KBUILD_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)) --Quoted 2 lines
2.43.0
--
Best Regards
Masahiro Yamada