[Qt-creator] Qt Creator for Linux Kernel Development
Eike Ziller
Eike.Ziller at qt.io
Wed Nov 23 10:21:56 CET 2016
> On Nov 23, 2016, at 6:51 AM, Jason A. Donenfeld <Jason at zx2c4.com> wrote:
>
> Hello Eike & Qt Creator mailing list,
>
> I'm insane and decided to try using an IDE for Linux kernel
> development. Much to my delight, it actually works well. (Everybody on
> the mailing list to which this message is cross-posted just vomited a
> little bit in their mouth and swallowed, but fear not: I'm a competent
> VIM user too. It's just that sometimes clickity clicking around Qt
> Creator is buttery nice. Here's a screenshot [2].)
>
> I'm working on a small kernel module [1], and for it I made a very
> minimal .pro file to import its files into Qt Creator. I even hooked
> the build/run commands up to my qemu testing rig. Seems to work pretty
> well. Here's the .pro I use:
>
> CONFIG -= qt
> INCLUDEPATH = /usr/src/linux/arch/x86/include
> /usr/src/linux/arch/x86/include/generated/uapi /usr/src/linux/
> arch/x86/include/generated /usr/src/linux/include
> /usr/src/linux/arch/x86/include/uapi /usr/src/linux/arch/x
> 86/include/generated/uapi /usr/src/linux/include/uapi
> /usr/src/linux/include/generated/uapi
> DEFINES = __KERNEL__ DEBUG MODULE
> SOURCES = $$system(find -L . -type f -iname $$system_quote(*.c) -and
> -not -path $$system_quote(./tests/*)) $
> $system(find -L . -type f -iname $$system_quote(*.S) -and -not -path
> $$system_quote(./tests/*))
> HEADERS = $$system(find -L . -type f -iname $$system_quote(*.h) -and
> -not -path $$system_quote(./tests/*))
>
> As you can see, it's a real hack.
>
> I also do development on the main Linux kernel tree, and similarly for
> that, I have a .pro file that works well:
>
> CONFIG -= qt
> INCLUDEPATH = $$system(find -L include/ -type d)
> SOURCES = $$system(find -L . -type f -iname \'*.c\')
> HEADERS = $$system(find -L . -type f -iname \'*.h\')
> INCLUDEPATH = include/ arch/x86/include
>
> Download the linux sources, put that in the tree, and load it up in Qt
> Creator. It works. Amazing!
>
> But don't get too excited. Unfortunately, there are two issues that
> make things unbearable:
>
> (A) Qt Creator doesn't seem to parse the C correctly. Things like
> designated initializers and a few other C features here and there just
> don't get parsed correctly, and the IDE stops being useful. I suspect
> this is because things are actually being parsed in C++ mode. Bummer.
> Developers: any interest in improving C support in Qt Creator?
Are you using the ClangCodeModel plugin? If not, you probably should.
It does not help for things like find usages and locator, since for this we still use the built-in model,
and fixes for the built-in model will be very limited.
But for working with the individual _source_ file it should at least help.
I can even open Objective-C++ files and get decent highlighting and even
get some completion for Objective-C ;)
One other issue are header files - there is no way Qt Creator can automatically tell if a
.h file is supposed to be C, C++, Objective-C, Objective-C++, ....
One hack workaround for C might be to remove *.h from the text/x-c++hdr mime type in Options > Environment > Mime Types,
but that would be a big and global hack (if it worked) ;)
We could probably provide a project setting for a “default” language to use though, which would then also be sharable with all in the project sources with a .shared file.
Br, Eike
> (B) There is no way to tell Qt Creator that a particular header file
> is included in every file -- that is, that gcc's "-include" is in use.
> There is a way of messing with the "C++ Code Model" on a file-by-file
> basis, for the duration of the time that the file is open, but no way
> to automatically have it included in every file of the project. This
> is a major hindrance. It means that every ifdef for every kconfig
> option is a grayed out unclickable region, rendering most things
> useless. Developers: any interest in fixing this? I spoke to a few of
> you in IRC several months ago about this, and there was interest, but
> it seems to have evaporated.
>
> So, anyway, if you think it would be cool to be able to say, "Qt
> Creator is used for Linux Kernel Development!", then maybe we can work
> together to actually get things working properly. It's already 85%
> there, and the remaining chunk seems well within reach.
>
> Not only that, but if Qt Creator becomes generally usable for ordinary
> C projects, it would most likely become a regular tool during my
> professional activities, namely, auditing large code bases for
> vulnerabilities and improving the security of systems.
>
> Let me know if you are interested in assisting with this.
>
> Thanks,
> Jason
>
>
>
> [1] https://www.wireguard.io/
> [2] https://data.zx2c4.com/qt-creator-wireguard-development.png
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
--
Eike Ziller
Principal Software Engineer
The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.ziller at qt.io
http://qt.io
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the WireGuard
mailing list