D22217: Pass extra build flags to compiler for parsing.

Aaron Puchert noreply at phabricator.kde.org
Sat Jul 20 21:18:51 BST 2019


aaronpuchert added a comment.


  Overall I think this is a good idea, although we need to figure out some details. Could you either remove commented out flags or add a comment why we have them (commented out)?

INLINE COMMENTS

> gcclikecompiler.cpp:80
> +    // Keep these arguments which may affect defines and includes.
> +    // All must be supported by both gcc and clang.
> +    static QSet<QString> hasOneArg({

Since we pass them to the Clang parser, they need only be supported by Clang, and if supported by both compilers, they should have the same semantics.

> gcclikecompiler.cpp:82-83
> +    static QSet<QString> hasOneArg({
> +        QStringLiteral("--std"),
> +        QStringLiteral("--stdlib"),
> +        QStringLiteral("--sysroot"),

Clang has these two with a single dash. For GCC I can find only `-nostdlib`. I didn't try it though.

> gcclikecompiler.cpp:84
> +        QStringLiteral("--stdlib"),
> +        QStringLiteral("--sysroot"),
> +        //QStringLiteral("-arch"),

Clang seems to have `-i[[framework]with]sysroot`, but not `--sysroot`.

> gcclikecompiler.cpp:90
> +    static QStringList startsOneArg({
> +        QStringLiteral("-B"),
> +        QStringLiteral("-march="),

How does this affect includes?

> gcclikecompiler.cpp:96
> +        QStringLiteral("--sysroot="),
> +        QStringLiteral("-x"),
> +        //QStringLiteral("--language="),

I haven't seen a build system set this. Why would it do that? The file type is usually inferred from the file ending, so you can just use the proper file ending.

> gcclikecompiler.cpp:106-107
> +        // rtti flags affect __cpp_rtti define which overrides arguments
> +        QStringLiteral("-frtti"),
> +        QStringLiteral("-fno-rtti"),
> +        //QStringLiteral("-ObjC"),

Some other `-f` flags are good candidates, e.g. `-fexceptions`, `-fgnu-keywords`, `-f[no-]signed-char`, `-ftrigraphs`, `-fwritable-strings` (although the latter two are perhaps not so important), or those enabling language features, like `-fmodules[-ts]`, `-fcoroutines-ts`.

> gcclikecompiler.cpp:125-126
> +                }
> +            ))
> +        {
> +            // keep this arg

Why did you break here before the brace?

REPOSITORY
  R32 KDevelop

REVISION DETAIL
  https://phabricator.kde.org/D22217

To: bungeman, #kdevelop
Cc: aaronpuchert, kdevelop-devel, hmitonneau, christiant, glebaccon, domson, antismap, iodelay, alexeymin, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20190720/7ae93d0d/attachment-0001.html>


More information about the KDevelop-devel mailing list