2
votes

I run sparse on linux kernel.

But it throws the following error:

Run sparse on linux:
lovegcy@knltest-VirtualBox:~/git_root/linux$ make C=2
make[1]: Nothing to be done for `all'.
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
HOSTLD arch/x86/tools/relocs
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CC kernel/bounds.s
GEN include/generated/bounds.h
CC arch/x86/kernel/asm-offsets.s
GEN include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHECK scripts/mod/empty.c
/bin/sh: 1: sparse: not found
make[2]: * [scripts/mod/empty.o] Error 127
make[1]:
[scripts/mod] Error 2
make: ** [scripts] Error 2

Here is the sparse install log:

lovegcy@knltest-VirtualBox:~/git_root/sparse$ make install
/bin/sh: 1: llvm-config: not found
Makefile:79: Your system does not have llvm, disabling sparse-llvm
INSTALL ‘sparse’ -> ‘/home/lovegcy/bin/sparse’
INSTALL ‘cgcc’ -> ‘/home/lovegcy/bin/cgcc’
INSTALL ‘c2xml’ -> ‘/home/lovegcy/bin/c2xml’
INSTALL ‘test-inspect’ -> ‘/home/lovegcy/bin/test-inspect’
INSTALL ‘sparse.1’ -> ‘/home/lovegcy/share/man/man1/sparse.1’
INSTALL ‘cgcc.1’ -> ‘/home/lovegcy/share/man/man1/cgcc.1’
INSTALL ‘libsparse.a’ -> ‘/home/lovegcy/lib/libsparse.a’
INSTALL ‘token.h’ -> ‘/home/lovegcy/include/sparse/token.h’
INSTALL ‘parse.h’ -> ‘/home/lovegcy/include/sparse/parse.h’
INSTALL ‘lib.h’ -> ‘/home/lovegcy/include/sparse/lib.h’
INSTALL ‘symbol.h’ -> ‘/home/lovegcy/include/sparse/symbol.h’
INSTALL ‘scope.h’ -> ‘/home/lovegcy/include/sparse/scope.h’
INSTALL ‘expression.h’ -> ‘/home/lovegcy/include/sparse/expression.h’
INSTALL ‘target.h’ -> ‘/home/lovegcy/include/sparse/target.h’
INSTALL ‘linearize.h’ -> ‘/home/lovegcy/include/sparse/linearize.h’
INSTALL ‘bitmap.h’ -> ‘/home/lovegcy/include/sparse/bitmap.h’
INSTALL ‘ident-list.h’ -> ‘/home/lovegcy/include/sparse/ident-list.h’
INSTALL ‘compat.h’ -> ‘/home/lovegcy/include/sparse/compat.h’
INSTALL ‘flow.h’ -> ‘/home/lovegcy/include/sparse/flow.h’
INSTALL ‘allocate.h’ -> ‘/home/lovegcy/include/sparse/allocate.h’
INSTALL ‘storage.h’ -> ‘/home/lovegcy/include/sparse/storage.h’
INSTALL ‘ptrlist.h’ -> ‘/home/lovegcy/include/sparse/ptrlist.h’
INSTALL ‘dissect.h’ -> ‘/home/lovegcy/include/sparse/dissect.h’
INSTALL ‘sparse.pc’ -> ‘/home/lovegcy/lib/pkgconfig/sparse.pc’

More: The kernel is already compiled.

Could anyone give some clue?

Thank you very much!

1

1 Answers

5
votes

Easier method :

First, download and Install sparse on your host-PC from the official channel.

For example, on Ubuntu run,
$ sudo apt-get install sparse


Building from source:

Alternately if you are attempting to build sparse from its sources, then we need to ensure that after running the make install command the sparse binary is present at /usr/bin/sparse.

This can be confirmed by opening a new terminal and running the which sparse command in it. It should output similar to the following :

$ which sparse
/usr/bin/sparse

In the same terminal, navigate to the Linux kernel source directory and attempt make C=2 to run sparse on the Linux kernel source.

Note : From your logs it appears that sparse is being installed into /home/lovegcy/bin/. Ensure that you have added the path /home/lovegcy/bin/ your $PATH environment variable. Otherwise the system will NOT be able to find the sparse binary.

On Ubuntu (running the bash shell), this can be automated for each new terminal by adding the following line in the .bashrc file as follows :

$ echo "export PATH=\$PATH:/home/lovegcy/bin/" >> ~/.bashrc