Build a single object file with make drivers/foo/bar.o
Compile a single kernel source file to its object with make drivers/foo/bar.o on Linux 6.12, to catch errors in seconds instead of minutes.
When you are fixing a compile error, the fastest loop is to build the one object file that fails. Give make the path of the object you want and Kbuild compiles just that translation unit, with the exact flags the full build would use. It needs a configured tree where make prepare has already run.
make drivers/net/dummy.o CC [M] drivers/net/dummy.oThe [M] marks a file that belongs to a module (CONFIG_DUMMY=m). A built-in file prints plain CC. The rule is the generic %.o: %.c pattern in scripts/Makefile.build, so it works for any .c file whose directory Makefile mentions it, as explained in the Kbuild makefile document.
This builds the object only. It does not link a module, run modpost or check symbol versions, so a missing export will pass here and fail later at MODPOST. If the file is not enabled in .config, the Makefile never lists it and make will say it has no rule for the target.