All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/gcc-plugins: consistently use HOSTCC
@ 2021-09-23 15:28 Ross Burton
  2021-09-23 21:28 ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Ross Burton @ 2021-09-23 15:28 UTC (permalink / raw)
  To: linux-hardening, linux-kernel; +Cc: keescook

The GCC plugins are built using HOSTCC, but the path to the GCC plugins
headers is obtained using CC.  This can lead to interesting failures if
the host compiler and cross compiler are different versions, and the
host compiler uses the cross headers.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/gcc-plugins/Kconfig  | 2 +-
 scripts/gcc-plugins/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/gcc-plugins/Kconfig b/scripts/gcc-plugins/Kconfig
index ab9eb4cbe33a..5dad6d780138 100644
--- a/scripts/gcc-plugins/Kconfig
+++ b/scripts/gcc-plugins/Kconfig
@@ -9,7 +9,7 @@ menuconfig GCC_PLUGINS
 	bool "GCC plugins"
 	depends on HAVE_GCC_PLUGINS
 	depends on CC_IS_GCC
-	depends on $(success,test -e $(shell,$(CC) -print-file-name=plugin)/include/plugin-version.h)
+	depends on $(success,test -e $(shell,$(HOSTCC) -print-file-name=plugin)/include/plugin-version.h)
 	default y
 	help
 	  GCC plugins are loadable modules that provide extra features to the
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
index 1952d3bb80c6..a55363f84e19 100644
--- a/scripts/gcc-plugins/Makefile
+++ b/scripts/gcc-plugins/Makefile
@@ -19,7 +19,7 @@ targets += randomize_layout_seed.h randomize_layout_hash.h
 
 always-y += $(GCC_PLUGIN)
 
-GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
+GCC_PLUGINS_DIR = $(shell $(HOSTCC) -print-file-name=plugin)
 
 plugin_cxxflags	= -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
 		  -include $(srctree)/include/linux/compiler-version.h \
-- 
2.25.1


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

* Re: [PATCH] scripts/gcc-plugins: consistently use HOSTCC
  2021-09-23 15:28 [PATCH] scripts/gcc-plugins: consistently use HOSTCC Ross Burton
@ 2021-09-23 21:28 ` Kees Cook
  2021-09-27 15:10   ` Dmitry Osipenko
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2021-09-23 21:28 UTC (permalink / raw)
  To: Ross Burton, linux-kernel, linux-hardening; +Cc: Kees Cook

On Thu, 23 Sep 2021 16:28:11 +0100, Ross Burton wrote:
> The GCC plugins are built using HOSTCC, but the path to the GCC plugins
> headers is obtained using CC.  This can lead to interesting failures if
> the host compiler and cross compiler are different versions, and the
> host compiler uses the cross headers.

(I changed this from HOSTCC to HOSTCXX to match the other invocations.)

Applied to for-next/gcc-plugins, thanks!

[1/1] scripts/gcc-plugins: consistently use HOSTCC
      https://git.kernel.org/kees/c/ef5ecb129791

-- 
Kees Cook


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

* Re: [PATCH] scripts/gcc-plugins: consistently use HOSTCC
  2021-09-23 21:28 ` Kees Cook
@ 2021-09-27 15:10   ` Dmitry Osipenko
  2021-09-27 15:30     ` Ross Burton
       [not found]     ` <DB9PR08MB6460E4643AB5AE8932C1AF94E8A79@DB9PR08MB6460.eurprd08.prod.outlook.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Osipenko @ 2021-09-27 15:10 UTC (permalink / raw)
  To: Kees Cook, Ross Burton, linux-kernel, linux-hardening

24.09.2021 00:28, Kees Cook пишет:
> On Thu, 23 Sep 2021 16:28:11 +0100, Ross Burton wrote:
>> The GCC plugins are built using HOSTCC, but the path to the GCC plugins
>> headers is obtained using CC.  This can lead to interesting failures if
>> the host compiler and cross compiler are different versions, and the
>> host compiler uses the cross headers.
> 
> (I changed this from HOSTCC to HOSTCXX to match the other invocations.)
> 
> Applied to for-next/gcc-plugins, thanks!
> 
> [1/1] scripts/gcc-plugins: consistently use HOSTCC
>       https://git.kernel.org/kees/c/ef5ecb129791
> 

I'm getting these errors when compiling ARM32 kernel using today's -next:

cc1: error: incompatible gcc/plugin versions
cc1: error: failed to initialize plugin ./scripts/gcc-plugins/arm_ssp_per_task_plugin.so

Both host and cross compiler are the same version:

# gcc-config -l
 [1] armv7a-hardfloat-linux-gnueabi-9.3.0
 [2] armv7a-hardfloat-linux-gnueabi-10.3.0
 [3] armv7a-hardfloat-linux-gnueabi-11.1.0 *

 [4] x86_64-pc-linux-gnu-11.1.0 *

# gcc -v
Используются внутренние спецификации.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Целевая архитектура: x86_64-pc-linux-gnu
Параметры конфигурации: /var/tmp/portage/sys-devel/gcc-11.1.0-r2/work/gcc-11.1.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/11.1.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.1.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.1.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.1.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/11.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 11.1.0-r2 p3' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp
Модель многопоточности: posix
Supported LTO compression algorithms: zlib
gcc версия 11.1.0 (Gentoo 11.1.0-r2 p3)

# armv7a-hardfloat-linux-gnueabi-gcc -v
Используются внутренние спецификации.
COLLECT_GCC=armv7a-hardfloat-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/armv7a-hardfloat-linux-gnueabi/11.1.0/lto-wrapper
Целевая архитектура: armv7a-hardfloat-linux-gnueabi
Параметры конфигурации: /var/tmp/portage/cross-armv7a-hardfloat-linux-gnueabi/gcc-11.1.0-r2/work/gcc-11.1.0/configure --host=x86_64-pc-linux-gnu --target=armv7a-hardfloat-linux-gnueabi --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/armv7a-hardfloat-linux-gnueabi/gcc-bin/11.1.0 --includedir=/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/11.1.0/include --datadir=/usr/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0 --mandir=/usr/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0/man --infodir=/usr/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0/info --with-gxx-include-dir=/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/11.1.0/include/g++-v11 --with-python-dir=/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 11.1.0-r2 p3' --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/armv7a-hardfloat-linux-gnueabi --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-fixed-point --with-float=hard --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp
Модель многопоточности: posix
Supported LTO compression algorithms: zlib
gcc версия 11.1.0 (Gentoo 11.1.0-r2 p3) 


Please fix, thanks in advance.

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

* Re: [PATCH] scripts/gcc-plugins: consistently use HOSTCC
  2021-09-27 15:10   ` Dmitry Osipenko
@ 2021-09-27 15:30     ` Ross Burton
       [not found]     ` <DB9PR08MB6460E4643AB5AE8932C1AF94E8A79@DB9PR08MB6460.eurprd08.prod.outlook.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Ross Burton @ 2021-09-27 15:30 UTC (permalink / raw)
  To: Dmitry Osipenko, Kees Cook, linux-kernel, linux-hardening

> I'm getting these errors when compiling ARM32 kernel using today's -next:

Hm, yes, I think I managed to misunderstand something and fixed one build whilst breaking another.

Kees, can you drop this?  I’ll come back with a v2.

Ross

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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

* Re: [PATCH] scripts/gcc-plugins: consistently use HOSTCC
       [not found]     ` <DB9PR08MB6460E4643AB5AE8932C1AF94E8A79@DB9PR08MB6460.eurprd08.prod.outlook.com>
@ 2021-09-27 16:12       ` Kees Cook
  0 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2021-09-27 16:12 UTC (permalink / raw)
  To: Ross Burton; +Cc: Dmitry Osipenko, linux-kernel, linux-hardening

On Mon, Sep 27, 2021 at 03:25:19PM +0000, Ross Burton wrote:
> Hm, yes, I think I managed to misunderstand something and fixed one build whilst breaking another.
> 
> Kees, can you drop this?  I’ll come back with a v2.

Sure! Dropped from -next.

-Kees

> 
> Ross
> 
> From: Dmitry Osipenko <digetx@gmail.com>
> Date: Monday, 27 September 2021 at 16:10
> To: Kees Cook <keescook@chromium.org>, Ross Burton <Ross.Burton@arm.com>, linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>, linux-hardening@vger.kernel.org <linux-hardening@vger.kernel.org>
> Subject: Re: [PATCH] scripts/gcc-plugins: consistently use HOSTCC
> 24.09.2021 00:28, Kees Cook пишет:
> > On Thu, 23 Sep 2021 16:28:11 +0100, Ross Burton wrote:
> >> The GCC plugins are built using HOSTCC, but the path to the GCC plugins
> >> headers is obtained using CC.  This can lead to interesting failures if
> >> the host compiler and cross compiler are different versions, and the
> >> host compiler uses the cross headers.
> >
> > (I changed this from HOSTCC to HOSTCXX to match the other invocations.)
> >
> > Applied to for-next/gcc-plugins, thanks!
> >
> > [1/1] scripts/gcc-plugins: consistently use HOSTCC
> >       https://git.kernel.org/kees/c/ef5ecb129791
> >
> 
> I'm getting these errors when compiling ARM32 kernel using today's -next:
> 
> cc1: error: incompatible gcc/plugin versions
> cc1: error: failed to initialize plugin ./scripts/gcc-plugins/arm_ssp_per_task_plugin.so
> 
> Both host and cross compiler are the same version:
> 
> # gcc-config -l
>  [1] armv7a-hardfloat-linux-gnueabi-9.3.0
>  [2] armv7a-hardfloat-linux-gnueabi-10.3.0
>  [3] armv7a-hardfloat-linux-gnueabi-11.1.0 *
> 
>  [4] x86_64-pc-linux-gnu-11.1.0 *
> 
> # gcc -v
> Используются внутренние спецификации.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
> Целевая архитектура: x86_64-pc-linux-gnu
> Параметры конфигурации: /var/tmp/portage/sys-devel/gcc-11.1.0-r2/work/gcc-11.1.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/11.1.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.1.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.1.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.1.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/11.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 11.1.0-r2 p3' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp
> Модель многопоточности: posix
> Supported LTO compression algorithms: zlib
> gcc версия 11.1.0 (Gentoo 11.1.0-r2 p3)
> 
> # armv7a-hardfloat-linux-gnueabi-gcc -v
> Используются внутренние спецификации.
> COLLECT_GCC=armv7a-hardfloat-linux-gnueabi-gcc
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/armv7a-hardfloat-linux-gnueabi/11.1.0/lto-wrapper
> Целевая архитектура: armv7a-hardfloat-linux-gnueabi
> Параметры конфигурации: /var/tmp/portage/cross-armv7a-hardfloat-linux-gnueabi/gcc-11.1.0-r2/work/gcc-11.1.0/configure --host=x86_64-pc-linux-gnu --target=armv7a-hardfloat-linux-gnueabi --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/armv7a-hardfloat-linux-gnueabi/gcc-bin/11.1.0 --includedir=/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/11.1.0/include --datadir=/usr/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0 --mandir=/usr/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0/man --infodir=/usr/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0/info --with-gxx-include-dir=/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/11.1.0/include/g++-v11 --with-python-dir=/share/gcc-data/armv7a-hardfloat-linux-gnueabi/11.1.0/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 11.1.0-r2 p3' --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/armv7a-hardfloat-linux-gnueabi --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-fixed-point --with-float=hard --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp
> Модель многопоточности: posix
> Supported LTO compression algorithms: zlib
> gcc версия 11.1.0 (Gentoo 11.1.0-r2 p3)
> 
> 
> Please fix, thanks in advance.
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

-- 
Kees Cook

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

end of thread, other threads:[~2021-09-27 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 15:28 [PATCH] scripts/gcc-plugins: consistently use HOSTCC Ross Burton
2021-09-23 21:28 ` Kees Cook
2021-09-27 15:10   ` Dmitry Osipenko
2021-09-27 15:30     ` Ross Burton
     [not found]     ` <DB9PR08MB6460E4643AB5AE8932C1AF94E8A79@DB9PR08MB6460.eurprd08.prod.outlook.com>
2021-09-27 16:12       ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.