Skip to contentSkip to conversation

What CONFIG_ option enables compilation of *.o file?

DISCUSSION Denis Efremov 3 participants 3 messages Jan 9, 2021 – Jan 14, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi,

Is there a general way to get information about what CONFIG_ options enable compilation of *.o (*.[ch]) file? Maybe with kconfig command or from some generated files?

I mean, to get information that, for example:
1) driver/block/floppy.o depends on CONFIG_BLK_DEV_FD

From driver/block/Makefile:

	obj-$(CONFIG_BLK_DEV_FD)        += floppy.o

2) kernel/trace/trace_selftest_dynamic.o depends on CONFIG_FTRACE_SELFTEST

From kernel/trace/Makefile:

	ifdef CONFIG_FTRACE_SELFTEST
	obj-y += trace_selftest_dynamic.o
	endif

3) kernel/trace/trace_irqsoff.o depends on either CONFIG_IRQSOFF_TRACER or CONFIG_PREEMPT_TRACER

From kernel/trace/Makefile:

	obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o
	obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o

4) drivers/dax/bus.o depends on CONFIG_DAX

From drivers/dax/Makefile:

	obj-$(CONFIG_DAX) += dax.o 
	dax-y += bus.o

5) drivers/soc/bcm/brcmstb/common.o depends on CONFIG_SOC_BRCMSTB

From drivers/Makefile:

	obj-y                           += soc/ 
From drivers/soc/Makefile:
	obj-y                           += bcm/
From drivers/soc/bcm/Makefile:
	obj-$(CONFIG_SOC_BRCMSTB)       += brcmstb/
From drivers/soc/bcm/brcmstb/Makefile
	obj-y += common.o 

Thanks,
Denis

#1 lore raw
Quoted 6 lines · Denis Efremov

Hi,

Is there a general way to get information about what CONFIG_ options enable compilation of *.o (*.[ch]) file? Maybe with kconfig command or from some generated files?

As far as I know, there is no tool or kconfig command to know what CONFIG option enables which object.

I also check Makefiles as you did below.

This is my workflow.

I have my own utility functions in ~/.bashrc

kgrep - grep only Kconfig files
mgrep - grep only Makefiles

function kgrep()

{
        find . -name .repo -prune -o -name .git -prune -o -type f \
        \( -name 'Kconfig*' -o -name 'Config.in' \) \
        -print0 | xargs -0 grep --color -n "$@"
}

function mgrep()

{
        find . -name .repo -prune -o -name .git -prune -o -type f \
        \( -name 'Makefile*' -o -name 'Kbuild*' -o -name "*.mk" \) \
        -print0 | xargs -0 grep --color -n "$@"
}

Then, I get this:

masahiro@grover:~/ref/linux-next$ mgrep floppy.o
./drivers/block/Makefile:14:obj-$(CONFIG_BLK_DEV_FD) += floppy.o
./drivers/ide/Makefile:92: ide-gd_mod-y += ide-floppy.o ide-floppy_ioctl.o

Maybe, there is a better way...

Quoted 40 lines

I mean, to get information that, for example:
1) driver/block/floppy.o depends on CONFIG_BLK_DEV_FD

From driver/block/Makefile:

        obj-$(CONFIG_BLK_DEV_FD)        += floppy.o

2) kernel/trace/trace_selftest_dynamic.o depends on CONFIG_FTRACE_SELFTEST

From kernel/trace/Makefile:

        ifdef CONFIG_FTRACE_SELFTEST
        obj-y += trace_selftest_dynamic.o
        endif

3) kernel/trace/trace_irqsoff.o depends on either CONFIG_IRQSOFF_TRACER or CONFIG_PREEMPT_TRACER

From kernel/trace/Makefile:

        obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o
        obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o

4) drivers/dax/bus.o depends on CONFIG_DAX

From drivers/dax/Makefile:

        obj-$(CONFIG_DAX) += dax.o
        dax-y += bus.o

5) drivers/soc/bcm/brcmstb/common.o depends on CONFIG_SOC_BRCMSTB

From drivers/Makefile:

        obj-y                           += soc/
From drivers/soc/Makefile:
        obj-y                           += bcm/
From drivers/soc/bcm/Makefile:
        obj-$(CONFIG_SOC_BRCMSTB)       += brcmstb/
From drivers/soc/bcm/brcmstb/Makefile
        obj-y += common.o

Thanks,
Denis

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 41 lines · Masahiro Yamada
Quoted 6 lines · Denis Efremov

Hi,

Is there a general way to get information about what CONFIG_ options enable compilation of *.o (*.[ch]) file? Maybe with kconfig command or from some generated files?

As far as I know, there is no tool or kconfig command to know what CONFIG option enables which object.

I also check Makefiles as you did below.

This is my workflow.

I have my own utility functions in ~/.bashrc

kgrep - grep only Kconfig files
mgrep - grep only Makefiles

function kgrep()

{
        find . -name .repo -prune -o -name .git -prune -o -type f \
        \( -name 'Kconfig*' -o -name 'Config.in' \) \
        -print0 | xargs -0 grep --color -n "$@"
}

function mgrep()

{
        find . -name .repo -prune -o -name .git -prune -o -type f \
        \( -name 'Makefile*' -o -name 'Kbuild*' -o -name "*.mk" \) \
        -print0 | xargs -0 grep --color -n "$@"
}

Then, I get this:

Quoted 8 lines
masahiro@grover:~/ref/linux-next$ mgrep floppy.o
./drivers/block/Makefile:14:obj-$(CONFIG_BLK_DEV_FD) += floppy.o
./drivers/ide/Makefile:92: ide-gd_mod-y += ide-floppy.o ide-floppy_ioctl.o

Maybe, there is a better way...

I don't know of anything better. I have scripts (instead of functions) findconfig and findmakefile, but they are not as nice as your functions.

Signature · 3 lines
~Randy
You can't do anything without having to do something else first.
-- Belefant's Law