Fixed
Created: Aug 19, 2024
Updated: Sep 22, 2024
Resolved Date: Aug 21, 2024
Found In Version: 10.23.30.11
Fix Version: 10.23.30.13
Severity: Standard
Applicable for: Wind River Linux LTS 23
Component/s: Userspace
Why SDK uses the different gcc options for building kernel module?
eg, SDK's gcc option:
-march=core2...-mno-sse -mno-mmx -mno-sse2
eg, linux kernel gcc option:
-mfpmath=sse -msse4.2 ...
*Makefile and Kernel Module:*
Building a Kernel Module with the SDK
[https://docs.windriver.com/r/bundle/Wind_River_Linux_Tutorial_Building_a_Kernel_Module_with_the_SDK_LTS_23/page/nxy1501520379278.html]
*I have confimed linux kernel gcc option in run.do_configure.*
<prj>/build/tmp-glibc/work/intel_x86_64-wrs-linux/linux-yocto-rt/6.1.92+gitAUTOINC+eb4b213a80_b97611901c-r0/temp/run.do_configure
export CC="x86_64-wrs-linux-gcc -m64 -march=nehalem -mtune=generic -mfpmath=sse -msse4.2 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/04/wrlinux/lts/23/rcpl-11/intel-x86-64.all/build/tmp-glibc/work/intel_x86_64-wrs-linux/linux-yocto-rt/6.1.92+gitAUTOINC+eb4b213a80_b97611901c-r0/recipe-sysroot"
...
$ cd <WRL-LTS23-SDK-install>
$ . ./environment-setup-corei7-64-wrs-linux
$ cat Makefile
obj-m += hello.o
all:
make -C ${SDKTARGETSYSROOT}/usr/src/kernel M=$(PWD) modules
clean:
make -C ${SDKTARGETSYSROOT}/usr/src/kernel M=$(PWD) clean
$ cat hello.c
#include <linux/module.h> // included for all kernel modules
#include <linux/kernel.h> // included for KERN_INFO
#include <linux/init.h> // included for __init and __exit macros
MODULE_LICENSE("GPL");
MODULE_AUTHOR("my_name");
MODULE_DESCRIPTION("A Simple Hello World module");
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world!\n");
return 0; // Non-zero return means that the module couldn't be loaded.
}
static void __exit hello_cleanup(void)
{
printk(KERN_INFO "Cleaning up module.\n");
}
module_init(hello_init);
module_exit(hello_cleanup);
$ make V=1
x86_64-wrs-linux-gcc -Wp,-MMD,/04/wrlinux/lts/23/rcpl-11/intel-x86-64.all/build/sdk/hello-mod/.hello.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu11 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=core2 -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -g --sysroot=/04/wrlinux/lts/23/rcpl-11/intel-x86-64.all/build/sdk/sysroots/corei7-64-wrs-linux -DMODULE -DKBUILD_BASENAME='"hello"' -DKBUILD_MODNAME='"hello"' -D__KBUILD_MODNAME=kmod_hello -c -o /04/wrlinux/lts/23/rcpl-11/intel-x86-64.all/build/sdk/hello-mod/hello.o /04/wrlinux/lts/23/rcpl-11/intel-x86-64.all/build/sdk/hello-mod/hello.c ; ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --retpoline --rethunk --static-call --uaccess --module /04/wrlinux/lts/23/rcpl-11/intel-x86-64.all/build/sdk/hello-mod/hello.o