linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: pageexec@freemail.hu
Cc: Emese Revfy <re.emese@gmail.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	spender@grsecurity.net, kernel-hardening@lists.openwall.com,
	Michal Marek <mmarek@suse.com>, Kees Cook <keescook@chromium.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	fengguang.wu@intel.com, Dmitry Vyukov <dvyukov@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 2/5] GCC plugin infrastructure
Date: Wed, 16 Mar 2016 16:34:02 +0900	[thread overview]
Message-ID: <CAK7LNAQjjTdkO454bL9h=ad_LzCnW_s4qO9gJmOUvVCH_1b+GQ@mail.gmail.com> (raw)
In-Reply-To: <56E72C58.28997.25D483C7@pageexec.freemail.hu>

Hi PaX,


2016-03-15 6:25 GMT+09:00 PaX Team <pageexec@freemail.hu>:
> On 11 Mar 2016 at 15:25, Masahiro Yamada wrote:
>
>> > diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
>> > new file mode 100644
>> > index 0000000..eaa4fce
>> > --- /dev/null
>> > +++ b/scripts/gcc-plugin.sh
>> > @@ -0,0 +1,51 @@
>> > +#!/bin/sh
>> > +srctree=$(dirname "$0")
>> > +gccplugins_dir=$($3 -print-file-name=plugin)
>> > +plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/../tools/gcc -I"${gccplugins_dir}"/include 2>&1 <<EOF
>> > +#include "gcc-common.h"
>>
>>
>> Maybe <gcc-common.h> because it is not located at the same directory?
>
> [snip]
>> > +#include "emit-rtl.h"
>> > +#include "debug.h"
>> > +#include "target.h"
>> > +#include "langhooks.h"
>> > +#include "cfgloop.h"
>> > +#include "cgraph.h"
>> > +#include "opts.h"
>>
>> All of these are included by "...", not <...>.
>>
>>
>> As mentioned above, I want you to use "..." style
>> when you need to use relative path from the source.
>>
>> I do not see most of them in tools/gcc/.
>
> no, that'd be incorrect for several reasons. first, the rule to use <...> vs. "..."
> include directives is not about the header being in the same directory but whether
> the header is a system header or one provided by the given program. roughly speaking,
> system headers are those that are available through the compiler's default include
> paths (gcc's own headers, those of glibc and other libraries under /usr/include, etc).
> gcc plugin headers are *not* available by default, one has to query the compiler about
> their path (see -print-file-name=plugin above) and explicitly add it to the compiler's
> include search path.

Are you sure?

I'd recommend you to read the following:
https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html


scripts/gcc-plugin.sh adds
  - ${srctree}"/../tools/gcc
  - ${gccplugins_dir}/include

to the header search path with "-I" option.


GCC looks for headers requested with #include <file>
in directories specified with "-I" as well as in the default ones.



> second, regardless of whether plugin headers are available by default or not, we
> still couldn't use them during cross-compilation as the plugin headers we want are
> those of the target compiler (that will load the plugin eventually), not that of
> the host compiler (which merely compiles the plugin and in theory doesn't even have
> to be gcc or a plugin capable gcc).

So, how could this be the reason why we should avoid #include <file>?



> for these reasons the correct include directive is "..." and not <...>. if it helps
> to understand the situation better, consider that gcc plugins are to gcc as kernel
> modules are to vmlinux and all kernel headers are included via "..." as well, regardless
> of whether they're in the same directory or not.

Of course, you could use #include "..." as well to include kernel headers,
but you should not do that.

You should do so only when you need to include headers that are local
to your directory.


-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2016-03-16  7:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-06 23:02 [PATCH v5 0/5] Introduce GCC plugin infrastructure Emese Revfy
2016-03-06 23:03 ` [PATCH v5 1/5] Shared library support Emese Revfy
2016-03-07 21:05   ` Kees Cook
2016-03-07 21:32     ` Emese Revfy
2016-03-11  6:19   ` Masahiro Yamada
2016-03-14 20:14     ` Emese Revfy
2016-03-16  7:50       ` Masahiro Yamada
2016-03-06 23:04 ` [PATCH v5 2/5] GCC plugin infrastructure Emese Revfy
2016-03-09  9:01   ` [kernel-hardening] " David Brown
2016-03-09 20:50     ` Kees Cook
2016-03-09 22:07       ` Emese Revfy
2016-03-09 22:03     ` Emese Revfy
2016-03-11  6:25   ` Masahiro Yamada
2016-03-14 20:52     ` Emese Revfy
2016-03-16  7:41       ` Masahiro Yamada
2016-03-16 21:06         ` Emese Revfy
2016-03-14 21:25     ` PaX Team
2016-03-16  7:34       ` Masahiro Yamada [this message]
2016-03-16 12:49         ` PaX Team
2016-03-17  4:09           ` Masahiro Yamada
2016-03-24  0:07     ` Emese Revfy
2016-03-26  2:39       ` Masahiro Yamada
2016-03-27 21:09         ` Emese Revfy
2016-04-02  4:32           ` Masahiro Yamada
2016-03-06 23:05 ` [PATCH v5 3/5] Add Cyclomatic complexity GCC plugin Emese Revfy
2016-03-11  6:26   ` Masahiro Yamada
2016-03-14 21:02     ` Emese Revfy
2016-03-06 23:06 ` [PATCH v5 4/5] Documentation for the GCC plugin infrastructure Emese Revfy
2016-03-06 23:07 ` [PATCH v5 5/5] Add sancov plugin Emese Revfy
2016-03-07 21:07   ` Kees Cook
2016-03-07 21:29     ` Emese Revfy
2016-03-08 10:54     ` Dmitry Vyukov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK7LNAQjjTdkO454bL9h=ad_LzCnW_s4qO9gJmOUvVCH_1b+GQ@mail.gmail.com' \
    --to=yamada.masahiro@socionext.com \
    --cc=dvyukov@google.com \
    --cc=fengguang.wu@intel.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mmarek@suse.com \
    --cc=pageexec@freemail.hu \
    --cc=re.emese@gmail.com \
    --cc=spender@grsecurity.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).