Bug 223180 - Bug in kmod.mk when SRCS is empty/not defined
Summary: Bug in kmod.mk when SRCS is empty/not defined
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-23 07:58 UTC by Johannes Lundberg
Modified: 2018-01-31 15:42 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Lundberg 2017-10-23 07:58:39 UTC
I discovered a bug/flaw in kmod.mk when building a kernel module where I do not have any c source files. Objects files are built using Rust and specified in OBJS variable.

If SRCS is empty/not defined these lines

# Conditionally include SRCS based on kernel config options.
.for _o in ${KERN_OPTS}
SRCS+=${SRCS.${_o}}
.endfor

generate an entry in SRCS with one space: SRCS=" "

Causing this line to add a " .o" to OBJS. 

OBJS+=	${SRCS:N*.h:R:S/$/.o/g}

Which of course cause the make command to fail since there is no ".o" file.

By replacing it with these lines I could temporary fix the problem.

.for _o in ${SRCS}
OBJS+=${_o:R:S/$/.o/g}
.endfor
Comment 1 Johannes Lundberg 2018-01-31 15:42:12 UTC
It should of course be

.for _o in ${SRCS:N*.h}
OBJS+=${_o:R:S/$/.o/g}
.endfor


The previous suggestion breaks buildkernel (and maybe even buildworld).