Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933804AbcCPHeL (ORCPT ); Wed, 16 Mar 2016 03:34:11 -0400 Received: from conssluserg003.nifty.com ([202.248.44.41]:38093 "EHLO conssluserg003-v.nifty.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932113AbcCPHeJ (ORCPT ); Wed, 16 Mar 2016 03:34:09 -0400 X-Nifty-SrcIP: [209.85.161.176] MIME-Version: 1.0 In-Reply-To: <56E72C58.28997.25D483C7@pageexec.freemail.hu> References: <20160307000208.1bec3e7dc874489d1b4fcbb4@gmail.com> <20160307000427.c82f18670568e1e656fc9532@gmail.com> <56E72C58.28997.25D483C7@pageexec.freemail.hu> Date: Wed, 16 Mar 2016 16:34:02 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 2/5] GCC plugin infrastructure From: Masahiro Yamada To: pageexec@freemail.hu Cc: Emese Revfy , Linux Kbuild mailing list , spender@grsecurity.net, kernel-hardening@lists.openwall.com, Michal Marek , Kees Cook , Rasmus Villemoes , fengguang.wu@intel.com, Dmitry Vyukov , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3037 Lines: 90 Hi PaX, 2016-03-15 6:25 GMT+09:00 PaX Team : > 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 <> > +#include "gcc-common.h" >> >> >> Maybe 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 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 ? > 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