linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RFC] Add additional include path for gcc plugins
@ 2021-09-15  9:23 Dan Li
  2021-09-15 10:00 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Li @ 2021-09-15  9:23 UTC (permalink / raw)
  To: masahiroy, michal.lkml, keescook
  Cc: linux-kbuild, linux-kernel, linux-hardening, Dan Li

When kernel enables gcc plugin, some header files are missing in some
tool chains (as in the following example)

These header files can be found in other toolchains, and sometimes
the md5hash of these files are same(in most versions).

Should we add a parameter to plugin to allow users to import their own
header file directories?

---
  HOSTCXX scripts/gcc-plugins/stackleak_plugin.so
In file included from scripts/gcc-plugins/gcc-common.h:103:0,
                 from scripts/gcc-plugins/stackleak_plugin.c:30:
/workspace/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/../
lib/gcc/aarch64-none-linux-gnu/9.2.1/plugin/include/builtins.h:23:17:
 fatal error: mpc.h: No such file or directory
 #include <mpc.h>

Signed-off-by: Dan Li <ashimida@linux.alibaba.com>
---
 Makefile                     | 3 +++
 scripts/gcc-plugins/Makefile | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 09bb314..e6134f3 100644
--- a/Makefile
+++ b/Makefile
@@ -1036,6 +1036,9 @@ include-$(CONFIG_UBSAN)		+= scripts/Makefile.ubsan
 include-$(CONFIG_KCOV)		+= scripts/Makefile.kcov
 include-$(CONFIG_GCC_PLUGINS)	+= scripts/Makefile.gcc-plugins
 
+GCC_PLUGINS_EXT_CFLAGS=
+export GCC_PLUGINS_EXT_CFLAGS
+
 include $(addprefix $(srctree)/, $(include-y))
 
 # scripts/Makefile.gcc-plugins is intentionally included last.
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
index 1952d3b..0b3e27a 100644
--- a/scripts/gcc-plugins/Makefile
+++ b/scripts/gcc-plugins/Makefile
@@ -23,7 +23,7 @@ GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
 
 plugin_cxxflags	= -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
 		  -include $(srctree)/include/linux/compiler-version.h \
-		   -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
+		   -I $(GCC_PLUGINS_DIR)/include -I $(obj) $(GCC_PLUGINS_EXT_CFLAGS) -std=gnu++11 \
 		   -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
 		   -ggdb -Wno-narrowing -Wno-unused-variable \
 		   -Wno-format-diag
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [RFC] Add additional include path for gcc plugins
  2021-09-15  9:23 [PATCH] [RFC] Add additional include path for gcc plugins Dan Li
@ 2021-09-15 10:00 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2021-09-15 10:00 UTC (permalink / raw)
  To: Dan Li
  Cc: Michal Marek, Kees Cook, Linux Kbuild mailing list,
	Linux Kernel Mailing List, linux-hardening

On Wed, Sep 15, 2021 at 6:23 PM Dan Li <ashimida@linux.alibaba.com> wrote:
>
> When kernel enables gcc plugin, some header files are missing in some
> tool chains (as in the following example)
>
> These header files can be found in other toolchains, and sometimes
> the md5hash of these files are same(in most versions).
>
> Should we add a parameter to plugin to allow users to import their own
> header file directories?
>
> ---
>   HOSTCXX scripts/gcc-plugins/stackleak_plugin.so
> In file included from scripts/gcc-plugins/gcc-common.h:103:0,
>                  from scripts/gcc-plugins/stackleak_plugin.c:30:
> /workspace/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/../
> lib/gcc/aarch64-none-linux-gnu/9.2.1/plugin/include/builtins.h:23:17:
>  fatal error: mpc.h: No such file or directory
>  #include <mpc.h>


gcc-plugins are compiled by the host compiler (usually g++).
Kbuild already provides 'HOSTCXXFLAGS'
to pass-in additional flags to it.

But, if you need to tweak include paths, you are already screwed up, maybe.

Some time ago, I got a question about plugin builds failing due to missing gmp.h
but it was solvable by installing a package.

https://lore.kernel.org/all/CAK7LNART2qQBY7Vc8rhMiXS_Fwty7qpWjwwfPrUegTb-gjy6sA@mail.gmail.com/






> Signed-off-by: Dan Li <ashimida@linux.alibaba.com>
> ---
>  Makefile                     | 3 +++
>  scripts/gcc-plugins/Makefile | 2 +-
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 09bb314..e6134f3 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1036,6 +1036,9 @@ include-$(CONFIG_UBSAN)           += scripts/Makefile.ubsan
>  include-$(CONFIG_KCOV)         += scripts/Makefile.kcov
>  include-$(CONFIG_GCC_PLUGINS)  += scripts/Makefile.gcc-plugins
>
> +GCC_PLUGINS_EXT_CFLAGS=
> +export GCC_PLUGINS_EXT_CFLAGS
> +
>  include $(addprefix $(srctree)/, $(include-y))
>
>  # scripts/Makefile.gcc-plugins is intentionally included last.
> diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
> index 1952d3b..0b3e27a 100644
> --- a/scripts/gcc-plugins/Makefile
> +++ b/scripts/gcc-plugins/Makefile
> @@ -23,7 +23,7 @@ GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
>
>  plugin_cxxflags        = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
>                   -include $(srctree)/include/linux/compiler-version.h \
> -                  -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
> +                  -I $(GCC_PLUGINS_DIR)/include -I $(obj) $(GCC_PLUGINS_EXT_CFLAGS) -std=gnu++11 \
>                    -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
>                    -ggdb -Wno-narrowing -Wno-unused-variable \
>                    -Wno-format-diag
> --
> 2.7.4
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-15 10:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15  9:23 [PATCH] [RFC] Add additional include path for gcc plugins Dan Li
2021-09-15 10:00 ` Masahiro Yamada

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).