When doing an out-of-tree build against a kernel with CONFIG_CTF=n (such as
debug kernels), linking fails because the list of object files in the
command-line given to the linker is empty.
The object files are substituted by this line in Makefile.modpost:
$(patsubst $(ctf-dir)/%,,$(filter-out FORCE,$^))
which takes the list of prerequisites for the module (which includes all its CTF
type information as well as its object files and a FORCE dummy target) and
filters out the FORCE target and all the CTF prerequisites (they are not linked
at this stage, but objcopied in immediately afterward). This works because all
the CTF files are generated under the $(ctf-dir) directory, and nothing else is
kept under there.
Unfortunately $(ctf-dir) is left empty if CONFIG_CTF=n. This is unproblematic
in normal kernel builds because all paths are relative, but if an out-of-tree
module build is being performed this strips everything out of the link line,
since out-of-tree builds usually specify all object files using absolute
pathnames, which naturally begin with a slash, and when $(ctf-dir) is empty so
does the patsubst pattern.
The solution is to provide a non-empty expansion of ctf-dir when CONFIG_CTF=n:
any value that can't appear at the start of object file names will do.
Orabug:
19078361
Reported-by: Knut Omang <knut.omang@oracle.com>
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Jamie Iles <jamie.iles@oracle.com>
Signed-off-by: Guangyu Sun <guangyu.sun@oracle.com>