Skip to content

company-clang doesn't work with kernel 5.3.6 #60

@choyoungcin

Description

@choyoungcin

Hi tuhdo,
I follow your blog and want to build an ide environment for kernel code reading.
When I try complete-mode with clang, something seems go wrong.
For example, when i type in

struct devi

then type command M-x company-complete, I wish struct device be auto-completed or a completion menu popped up, but i get the hint No completion found in the echo erea.

I got the following errors from clang-error buffer:

clang failed with error 1:
/usr/bin/clang -fsyntax-only -Xclang -code-completion-macros -x c -I/home/gnu/linux-5.3.6/include/ -I/home/gnu/linux-5.3.6/arch/arm/include/ -Xclang -code-completion-at=-:95:26 -

In file included from :7:
In file included from /home/gnu/linux-5.3.6/include/linux/kernel.h:13:
/home/gnu/linux-5.3.6/include/linux/log2.h:197:15: error: unknown type name 'attribute_const'
static inline attribute_const
^
/home/gnu/linux-5.3.6/include/linux/log2.h:198:1: error: expected identifier or '('
int __order_base_2(unsigned long n)
^
In file included from :7:
In file included from /home/gnu/linux-5.3.6/include/linux/kernel.h:15:
In file included from /home/gnu/linux-5.3.6/include/linux/printk.h:6:
/home/gnu/linux-5.3.6/include/linux/init.h:144:13: error: expected parameter declarator
extern char __initdata boot_command_line[];
^
/home/gnu/linux-5.3.6/include/linux/init.h:51:30: note: expanded from macro '__initdata'
#define __initdata __section(.init.data)
....
/home/gnu/linux-5.3.6/arch/arm/include/uapi/asm/swab.h:28:8: error: 'inline' can only appear on functions
static inline attribute_const __u32 __arch_swab32(__u32 x)
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

My emacs version: 26.1
& clang version: 7.0.1-9+b1 (tags/RELEASE_701/final)

Below is the content of variable company-clang-arguments

company-clang-arguments is a variable defined in ‘company-clang.el’.
Its value is
("-I/home/gnu/linux-5.3.6/include/" "-I/home/gnu/linux-5.3.6/arch/arm/include/")
Original value was nil
Local in buffer Makefile; global value is nil

This variable’s value is directory-local, set by the file
‘/home/gnu/linux-5.3.6/.dir-locals.el’.

Documentation:
Additional arguments to pass to clang when completing.
Prefix files (-include ...) can be selected with ‘company-clang-set-prefix’
or automatically through a custom ‘company-clang-prefix-guesser’.

You can customize this variable.

Any suggestion or help?
Many thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions