likewhatevs wrote:
> Is what the kernel does in any way different from what build systems like
> cmake do for unity builds?
I don't think so but let me get an example to make sure I'm not missing
anything subtle.
This is what `compile_commands.json` looks like for one of the unity build
files:
```
{
"command": "gcc-14 -Wp,-MMD,kernel/sched/.build_policy.o.d -nostdinc
-I./arch/x86/include -I./arch/x86/include/generated -I./include -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__ -Werror -std=gnu11 -fshort-wchar -funsigned-char -fno-common
-fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
-mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1
-falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3
-mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel
-mstack-protector-guard-reg=gs
-mstack-protector-guard-symbol=__ref_stack_chk_guard -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
-fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2
-fno-allow-store-data-races -fstack-protector-strong
-ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mrecord-mcount
-mfentry -DCC_USING_FENTRY -fmin-function-alignment=16 -fstrict-flex-arrays=3
-fms-extensions -fno-strict-overflow -fno-stack-check -fconserve-stack
-fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration
-Werror=implicit-int -Werror=return-type -Werror=strict-prototypes
-Wno-format-security -Wno-trigraphs -Wno-frame-address
-Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes
-Wframe-larger-than=2048 -Wno-main -Wno-dangling-pointer -Wvla-larger-than=1
-Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-stringop-overflow
-Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time
-Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion
-Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable
-Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation
-Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers
-Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized
-Wno-sign-compare -Wno-unused-parameter -g -Wno-unused-but-set-variable
-DKBUILD_MODFILE='\"kernel/sched/build_policy\"'
-DKBUILD_BASENAME='\"build_policy\"' -DKBUILD_MODNAME='\"build_policy\"'
-D__KBUILD_MODNAME=build_policy -c -o kernel/sched/build_policy.o
kernel/sched/build_policy.c",
"directory": "~/linux",
"file": "~/linux/kernel/sched/build_policy.c"
},
```
This is that file:
https://elixir.bootlin.com/linux/v6.18/source/kernel/sched/build_policy.c#L50-L66
, the c files it includes (like `ext.c`) don't have their own entries in
`compile_commands.json`.
> If so, then I believe the scope this affects is way larger as unity builds
> are available in multiple build systems. iiuc what this does is propagate the
> includes and defines from source1 etc. into the following files?
Yes
https://github.com/llvm/llvm-project/pull/180402
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits