0

I have this makefile. when running make commmand I get this error

make -C /lib/modules/5.13.0-21-generic/build M=/home/fawad/Desktop/ext2/linux-5.14.21/fs/ext2 modules
make[1]: Entering directory '/usr/src/linux-headers-5.13.0-21-generic'
  LD [M]  /home/fawad/Desktop/ext2/linux-5.14.21/fs/ext2/hijj.o
ld: no input files
make[2]: *** [scripts/Makefile.build:458: /home/fawad/Desktop/ext2/linux-5.14.21/fs/ext2/hijj.o] Error 1
make[1]: *** [Makefile:1874: /home/fawad/Desktop/ext2/linux-5.14.21/fs/ext2] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.13.0-21-generic'
make: *** [Makefile:33: all] Error 2

I like to know why I am getting error that ld: no input files since I have provided input files as super.c acl.c balloc.c dir.c file.c ialloc.c inode.c ioctl.c namei.c symlink.c xattr.c xattr_security.c xattr_trusted.c xattr_user.c

this is my makefile

#Comment/uncomment the following line to disable/enable debugging
#DEBUG = y
CFLAGS_hijj.ko := -DDEBUG

# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
    DEBFLAGS = -O -g -DSHORT_DEBUG # "-O" is needed to expand inlines
else
    DEBFLAGS = -O2
endif

CFLAGS += $(DEBFLAGS)
CFLAGS += -I..

ifneq ($(KERNELRELEASE),)
# call from kernel build system

obj-m   += hijj.o
hijj-y := super.c acl.c balloc.c dir.c file.c ialloc.c inode.c ioctl.c namei.c symlink.c xattr.c xattr_security.c xattr_trusted.c xattr_user.c

clean   :
    rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions    
    

    

else

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

endif



depend .depend dep:
    $(CC) $(CFLAGS) -M *.c > .depend


ifeq (.depend,$(wildcard .depend))
include .depend
endif

The above makefile Is I made for ext2 file system then need to install with insmod as out of tree as kernel module

Update

I think the error is in this line of /lib/modules/5.13.0-21-generic/build directory makefile. This is error make[1]: *** [Makefile:1874: /home/fawad/Desktop/ext2/linux-5.14.21/fs/ext2] Error 2 in the my output of make command

$(build-dirs): prepare
    $(Q)$(MAKE) $(build)=$@ \
    single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
    need-builtin=1 need-modorder=1

Update 2

My make stops at this. result from make --print-data-base -p

#  recipe to execute (from 'Makefile', line 32):
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

# Not a target:
.w.tex:
#  Builtin rule
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.
#  recipe to execute (built-in):
    $(CWEAVE) $< - $@
user786
  • 3,902
  • 4
  • 40
  • 72
  • 1
    Please try to pare this down to a [mre] – tripleee Nov 30 '21 at 07:45
  • @tripleee I am rather asking what this error means. For example, Is my makefile rule missing any source file for the kernel module. So undefined function error I.e. is translated by this error. What this error means? Is there any other causes to this error. The source of kernel module is from Linux source in /fs/ext2/ directory – user786 Nov 30 '21 at 09:49
  • 1
    What tripleee is saying here is basic debugging 101. Please follow that link and read that page. – DevSolar Nov 30 '21 at 10:32
  • @tripleee please see the update in my question with the line in my system Makefile – user786 Nov 30 '21 at 10:32
  • @DevSolar please see the update in my question – user786 Nov 30 '21 at 10:33
  • To reproduce the error just extract source files from linux kernel 5.14 fs/ext2 directory and use my make file plus I have kernel 5.13.0-21 plus headers same version – user786 Nov 30 '21 at 11:07
  • I would troubleshoot the error from the submake first: "`make[2]: *** [scripts/Makefile.build:458: /home/fawad/Desktop/ext2/linux-5.14.21/fs/ext2/hijj.o] Error 1`". It is likely that this is the source of the error in the top-level `make`, even though this message appears after the first error message in `make`'s output. – John Bollinger Nov 30 '21 at 13:12
  • 1
    These messages `make: *** ... Error 1` simply mean that make invoked a command (the one at that line number) and the command exited with a non-0 error code (in this case, exit code 1). That tells make that whatever command it invoked, failed. This problem has nothing to do with make per se, it's that your command failed. You have to figure out why that is. The error message here is `ld: no input files`. Why is that? I don't know. Your makefile has hidden the actual command that was invoked. Probably there's some kind of "verbose" mode to have it printed instead, that might help. – MadScientist Nov 30 '21 at 14:07
  • @MadScientist please see the update 2 of my question – user786 Nov 30 '21 at 14:34
  • @JohnBollinger please see my last comment – user786 Nov 30 '21 at 14:34
  • You don't need `make -p`: the filename/linenumber is printed by make: `Makefile:33`. But this isn't interesting as I said above. The error you're looking at is just make telling you that the command it invoked, the sub-make, exited with an error. You have to look at why the **sub-make** failed and fix that. It failed because of an `ld` error, and the makefile/linenumber that invokes that is shown by that error: `scripts/Makefile.build:458` (in directory `/usr/src/linux-headers-5.13.0-21-generic`) – MadScientist Nov 30 '21 at 14:49
  • @MadScientist `The error you're looking at is just make telling you that the command it invoked, the sub-make, exited with an error. You have to look at why the sub-make failed and fix that.` what that means and please do tell what is `sub-make`? – user786 Nov 30 '21 at 15:42
  • @MadScientist `The error message here is ld: no input files. Why is that? I don't know. Your makefile has hidden the actual command that was invoked. Probably there's some kind of "verbose" mode to have it printed instead, that might help` do u know any make command flag that prints verbose mode output? – user786 Nov 30 '21 at 16:01
  • It's not make that's hiding this output. It's the makefile itself. So the way to "un-hide" it is specific to that makefile or set of makefiles. You'll have to check docs for this. Searching for "linux kernel make verbose" I found this: https://stackoverflow.com/questions/5820303/how-do-i-force-make-gcc-to-show-me-the-commands as well as the Linux kernel build docs: https://www.kernel.org/doc/makehelp.txt (look at the bottom for options) – MadScientist Nov 30 '21 at 16:58
  • In pseudo-code `if (!something) print "error"` produces an error message if `something` is not true, but the error message is uninteresting; the interesting part is figuring out why `something` was not true. – tripleee Dec 01 '21 at 11:44
  • @tripleee can u tell two things as example what should I be looking at. Just a guess – user786 Dec 01 '21 at 11:57
  • 1
    Like @MadScientist already told you _twice_ you need to find the line which runs `ld` and figure out why it's not receiving any arguments. – tripleee Dec 01 '21 at 11:58
  • @triiplee which make file is it this makefile scripts/Makefile.build see my error in question this makefile file is printed in error output of make command. Please confirm – user786 Dec 01 '21 at 12:10

0 Answers0