All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [BUG v5.2-rc1] ARM build broken
       [not found] <4DB08A04-D03A-4441-85DE-64A13E6D709C@goldelico.com>
@ 2019-05-20 15:59 ` Kees Cook
       [not found]   ` <D8F987B2-8F41-46DE-B298-89541D7A9774@goldelico.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Kees Cook @ 2019-05-20 15:59 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: lkml, Masahiro Yamada, Discussions about the Letux Kernel

On Mon, May 20, 2019 at 05:15:02PM +0200, H. Nikolaus Schaller wrote:
> Hi,
> it seems as if ARM build is broken since ARM now hard enables CONFIG_HAVE_GCC_PLUGINS
> which indirectly enables CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK. Compiling this breaks
> on my system (Darwin build host) due to conflicts in system headers and Linux headers.
> 
> So how can I turn off all these GCC_PLUGINS?
> 
> The offending patch seems to be
> 
> 	security: Create "kernel hardening" config area
> 
> especially the new "default y" for GCC_PLUGINS. After removing that line from
> scripts/gcc-plugins/Kconfig makes my compile succeed.

The intention is to enable it _if_ the plugins are available as part of
the build environment. The "default y" on GCC_PLUGINS is mediated by:
        depends on HAVE_GCC_PLUGINS
        depends on PLUGIN_HOSTCC != ""

So it seems that something isn't working in the plugin detection maybe?
Can you send your build error, compiler version, .config, etc? I've not
been able to reproduce this problem. (And I'm not aware of any of the
automated build systems failing in this area yet either...) Perhaps it's
something specific to building under Darwin?

Thanks!

-- 
Kees Cook

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

* Re: [BUG v5.2-rc1] ARM build broken
       [not found]   ` <D8F987B2-8F41-46DE-B298-89541D7A9774@goldelico.com>
@ 2019-05-20 18:53     ` Kees Cook
  2019-05-20 19:35       ` H. Nikolaus Schaller
  2019-05-20 21:21       ` Chris Packham
  0 siblings, 2 replies; 9+ messages in thread
From: Kees Cook @ 2019-05-20 18:53 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: lkml, Masahiro Yamada, Chris Packham, Ard Biesheuvel,
	Discussions about the Letux Kernel

[Adding Chris and Ard, who might have more compiler versions that me...]

On Mon, May 20, 2019 at 07:08:39PM +0200, H. Nikolaus Schaller wrote:
> > Am 20.05.2019 um 17:59 schrieb Kees Cook <keescook@chromium.org>:
> > 
> > On Mon, May 20, 2019 at 05:15:02PM +0200, H. Nikolaus Schaller wrote:
> >> Hi,
> >> it seems as if ARM build is broken since ARM now hard enables CONFIG_HAVE_GCC_PLUGINS
> >> which indirectly enables CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK. Compiling this breaks
> >> on my system (Darwin build host) due to conflicts in system headers and Linux headers.
> >> 
> >> So how can I turn off all these GCC_PLUGINS?
> >> 
> >> The offending patch seems to be
> >> 
> >> 	security: Create "kernel hardening" config area
> >> 
> >> especially the new "default y" for GCC_PLUGINS. After removing that line from
> >> scripts/gcc-plugins/Kconfig makes my compile succeed.
> > 
> > The intention is to enable it _if_ the plugins are available as part of
> > the build environment. The "default y" on GCC_PLUGINS is mediated by:
> >        depends on HAVE_GCC_PLUGINS
> 
> HAVE_GCC_PLUGINS has the following description:
> 
> 	An arch should select this symbol if it supports building with
>           GCC plugins.
> 
> So an ARCH (ARM) selects it unconditionally of the build environment.
> 
> >        depends on PLUGIN_HOSTCC != ""
> 
> Well, we have it set to "g++" for ages and it was not a problem.
> So both conditions are true.

PLUGIN_HOSTCC should have passed the scripts/gcc-plugin.sh test, so
that's correct. And the result (CONFIG_GCC_PLUGINS) is correct: it
doesn't enable or disable anything itself.

What you want is to disable CONFIG_STACKPROTECTOR_PER_TASK, which
is the knob for the feature:

config STACKPROTECTOR_PER_TASK
        bool "Use a unique stack canary value for each task"
        depends on GCC_PLUGINS && STACKPROTECTOR && SMP && !XIP_DEFLATED_DATA
        select GCC_PLUGIN_ARM_SSP_PER_TASK
        default y

> Build error:
> 
>  HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o - due to: scripts/gcc-plugins/gcc-common.h
> In file included from scripts/gcc-plugins/arm_ssp_per_task_plugin.c:3:0:
> scripts/gcc-plugins/gcc-common.h:153:0: warning: "__unused" redefined
> #define __unused __attribute__((__unused__))
> ^

Does the following patch fix your build? (I assume that line is just a
warning, but if not...)

diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
index 552d5efd7cb7..17f06079a712 100644
--- a/scripts/gcc-plugins/gcc-common.h
+++ b/scripts/gcc-plugins/gcc-common.h
@@ -150,8 +150,12 @@ void print_gimple_expr(FILE *, gimple, int, int);
 void dump_gimple_stmt(pretty_printer *, gimple, int, int);
 #endif
 
+#ifndef __unused
 #define __unused __attribute__((__unused__))
+#endif
+#ifndef __visible
 #define __visible __attribute__((visibility("default")))
+#endif
 
 #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
 #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))

>  HOSTLLD -shared scripts/gcc-plugins/arm_ssp_per_task_plugin.so - due to target missing
> Undefined symbols for architecture x86_64:
>  "gen_reg_rtx(machine_mode)", referenced from:
>      (anonymous namespace)::arm_pertask_ssp_rtl_pass::execute() in arm_ssp_per_task_plugin.o

However, this part sounds more like what was fixed with
259799ea5a9a ("gcc-plugins: arm_ssp_per_task_plugin: Fix for older GCC < 6")

And maybe some additional fixes for 4.9 are needed?

> This is because CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK became automatically enabled and was never
> before. So the compiler may lack some library search path for building this plugin (which we
> did never miss).

Right -- maybe CONFIG_STACKPROTECTOR_PER_TASK doesn't work with old gcc
4.9.2? I'll see if I can find that compiler version...

-- 
Kees Cook

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

* Re: [BUG v5.2-rc1] ARM build broken
  2019-05-20 18:53     ` Kees Cook
@ 2019-05-20 19:35       ` H. Nikolaus Schaller
  2019-05-20 20:25         ` Kees Cook
  2019-05-20 21:21       ` Chris Packham
  1 sibling, 1 reply; 9+ messages in thread
From: H. Nikolaus Schaller @ 2019-05-20 19:35 UTC (permalink / raw)
  To: Kees Cook
  Cc: lkml, Masahiro Yamada, Chris Packham, Ard Biesheuvel,
	Discussions about the Letux Kernel

Hi,

> Am 20.05.2019 um 20:53 schrieb Kees Cook <keescook@chromium.org>:
> 
> [Adding Chris and Ard, who might have more compiler versions that me...]
> 
> On Mon, May 20, 2019 at 07:08:39PM +0200, H. Nikolaus Schaller wrote:
>>> Am 20.05.2019 um 17:59 schrieb Kees Cook <keescook@chromium.org>:
>>> 
>>> On Mon, May 20, 2019 at 05:15:02PM +0200, H. Nikolaus Schaller wrote:
>>>> Hi,
>>>> it seems as if ARM build is broken since ARM now hard enables CONFIG_HAVE_GCC_PLUGINS
>>>> which indirectly enables CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK. Compiling this breaks
>>>> on my system (Darwin build host) due to conflicts in system headers and Linux headers.
>>>> 
>>>> So how can I turn off all these GCC_PLUGINS?
>>>> 
>>>> The offending patch seems to be
>>>> 
>>>> 	security: Create "kernel hardening" config area
>>>> 
>>>> especially the new "default y" for GCC_PLUGINS. After removing that line from
>>>> scripts/gcc-plugins/Kconfig makes my compile succeed.
>>> 
>>> The intention is to enable it _if_ the plugins are available as part of
>>> the build environment. The "default y" on GCC_PLUGINS is mediated by:
>>>       depends on HAVE_GCC_PLUGINS
>> 
>> HAVE_GCC_PLUGINS has the following description:
>> 
>> 	An arch should select this symbol if it supports building with
>>          GCC plugins.
>> 
>> So an ARCH (ARM) selects it unconditionally of the build environment.
>> 
>>>       depends on PLUGIN_HOSTCC != ""
>> 
>> Well, we have it set to "g++" for ages and it was not a problem.
>> So both conditions are true.
> 
> PLUGIN_HOSTCC should have passed the scripts/gcc-plugin.sh test, so
> that's correct. And the result (CONFIG_GCC_PLUGINS) is correct: it
> doesn't enable or disable anything itself.
> 
> What you want is to disable CONFIG_STACKPROTECTOR_PER_TASK, which
> is the knob for the feature:
> 
> config STACKPROTECTOR_PER_TASK
>        bool "Use a unique stack canary value for each task"
>        depends on GCC_PLUGINS && STACKPROTECTOR && SMP && !XIP_DEFLATED_DATA
>        select GCC_PLUGIN_ARM_SSP_PER_TASK
>        default y

Ah, disabling this makes it compile.

Unfortunately it is not explicitly disabled by e.g. omap2plus_defconfig and therefore
automatically set through the "default y". So I have to manipulate the defconfig first.

> 
>> Build error:
>> 
>> HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o - due to: scripts/gcc-plugins/gcc-common.h
>> In file included from scripts/gcc-plugins/arm_ssp_per_task_plugin.c:3:0:
>> scripts/gcc-plugins/gcc-common.h:153:0: warning: "__unused" redefined
>> #define __unused __attribute__((__unused__))
>> ^
> 
> Does the following patch fix your build? (I assume that line is just a
> warning, but if not...)
> 
> diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
> index 552d5efd7cb7..17f06079a712 100644
> --- a/scripts/gcc-plugins/gcc-common.h
> +++ b/scripts/gcc-plugins/gcc-common.h
> @@ -150,8 +150,12 @@ void print_gimple_expr(FILE *, gimple, int, int);
> void dump_gimple_stmt(pretty_printer *, gimple, int, int);
> #endif
> 
> +#ifndef __unused
> #define __unused __attribute__((__unused__))
> +#endif
> +#ifndef __visible
> #define __visible __attribute__((visibility("default")))
> +#endif
> 
> #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
> #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))

Yes, fixes this issue.

> 
>> HOSTLLD -shared scripts/gcc-plugins/arm_ssp_per_task_plugin.so - due to target missing
>> Undefined symbols for architecture x86_64:
>> "gen_reg_rtx(machine_mode)", referenced from:
>>     (anonymous namespace)::arm_pertask_ssp_rtl_pass::execute() in arm_ssp_per_task_plugin.o
> 
> However, this part sounds more like what was fixed with
> 259799ea5a9a ("gcc-plugins: arm_ssp_per_task_plugin: Fix for older GCC < 6")
> 
> And maybe some additional fixes for 4.9 are needed?

Looks similar although not a compiler but linker error. Which indicates a library search issue.

Unfortunately gcc plugins is something I didn't even know that it exists until some hours ago :)

So I have no idea where e.g. _plugin_default_version_check, _default_target_rtl or _register_callback
should be provided.

If it is part of the gcc build-from-source tree I may have a chance to add the path to the CCXFLAGS.
Or is it to be provided from the kernel tree?

> 
>> This is because CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK became automatically enabled and was never
>> before. So the compiler may lack some library search path for building this plugin (which we
>> did never miss).
> 
> Right -- maybe CONFIG_STACKPROTECTOR_PER_TASK doesn't work with old gcc
> 4.9.2? I'll see if I can find that compiler version...

I think Debian Jessie used the same compiler version as default gcc.

BR and thanks,
Nikolaus Schaller


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

* Re: [BUG v5.2-rc1] ARM build broken
  2019-05-20 19:35       ` H. Nikolaus Schaller
@ 2019-05-20 20:25         ` Kees Cook
  0 siblings, 0 replies; 9+ messages in thread
From: Kees Cook @ 2019-05-20 20:25 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: lkml, Masahiro Yamada, Chris Packham, Ard Biesheuvel,
	Discussions about the Letux Kernel

On Mon, May 20, 2019 at 09:35:45PM +0200, H. Nikolaus Schaller wrote:
> 
> > Am 20.05.2019 um 20:53 schrieb Kees Cook <keescook@chromium.org>:
> > 
> > 
> >> Build error:
> >> 
> >> HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o - due to: scripts/gcc-plugins/gcc-common.h
> >> In file included from scripts/gcc-plugins/arm_ssp_per_task_plugin.c:3:0:
> >> scripts/gcc-plugins/gcc-common.h:153:0: warning: "__unused" redefined
> >> #define __unused __attribute__((__unused__))
> >> ^
> > 
> > Does the following patch fix your build? (I assume that line is just a
> > warning, but if not...)
> > 
> > diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
> > index 552d5efd7cb7..17f06079a712 100644
> > --- a/scripts/gcc-plugins/gcc-common.h
> > +++ b/scripts/gcc-plugins/gcc-common.h
> > @@ -150,8 +150,12 @@ void print_gimple_expr(FILE *, gimple, int, int);
> > void dump_gimple_stmt(pretty_printer *, gimple, int, int);
> > #endif
> > 
> > +#ifndef __unused
> > #define __unused __attribute__((__unused__))
> > +#endif
> > +#ifndef __visible
> > #define __visible __attribute__((visibility("default")))
> > +#endif
> > 
> > #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
> > #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
> 
> Yes, fixes this issue.

Ah, good! Okay, then the rest of the build errors were from not
finishing to build the plugin correctly. Thanks for debugging this; I'll
get the fix sent to Linus. :)

-- 
Kees Cook

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

* Re: [BUG v5.2-rc1] ARM build broken
  2019-05-20 18:53     ` Kees Cook
  2019-05-20 19:35       ` H. Nikolaus Schaller
@ 2019-05-20 21:21       ` Chris Packham
  2019-05-21 11:23         ` H. Nikolaus Schaller
  1 sibling, 1 reply; 9+ messages in thread
From: Chris Packham @ 2019-05-20 21:21 UTC (permalink / raw)
  To: Kees Cook, H. Nikolaus Schaller
  Cc: lkml, Masahiro Yamada, Ard Biesheuvel,
	Discussions about the Letux Kernel

On 21/05/19 6:54 AM, Kees Cook wrote:
> [Adding Chris and Ard, who might have more compiler versions that me...]

Late to the thread but ...

> 
> On Mon, May 20, 2019 at 07:08:39PM +0200, H. Nikolaus Schaller wrote:
>>> Am 20.05.2019 um 17:59 schrieb Kees Cook <keescook@chromium.org>:
>>>
>>> On Mon, May 20, 2019 at 05:15:02PM +0200, H. Nikolaus Schaller wrote:
>>>> Hi,
>>>> it seems as if ARM build is broken since ARM now hard enables CONFIG_HAVE_GCC_PLUGINS
>>>> which indirectly enables CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK. Compiling this breaks
>>>> on my system (Darwin build host) due to conflicts in system headers and Linux headers.
>>>>
>>>> So how can I turn off all these GCC_PLUGINS?
>>>>
>>>> The offending patch seems to be
>>>>
>>>> 	security: Create "kernel hardening" config area
>>>>
>>>> especially the new "default y" for GCC_PLUGINS. After removing that line from
>>>> scripts/gcc-plugins/Kconfig makes my compile succeed.
>>>
>>> The intention is to enable it _if_ the plugins are available as part of
>>> the build environment. The "default y" on GCC_PLUGINS is mediated by:
>>>         depends on HAVE_GCC_PLUGINS
>>
>> HAVE_GCC_PLUGINS has the following description:
>>
>> 	An arch should select this symbol if it supports building with
>>            GCC plugins.
>>
>> So an ARCH (ARM) selects it unconditionally of the build environment.
>>
>>>         depends on PLUGIN_HOSTCC != ""
>>
>> Well, we have it set to "g++" for ages and it was not a problem.
>> So both conditions are true.
> 
> PLUGIN_HOSTCC should have passed the scripts/gcc-plugin.sh test, so
> that's correct. And the result (CONFIG_GCC_PLUGINS) is correct: it
> doesn't enable or disable anything itself.
> 
> What you want is to disable CONFIG_STACKPROTECTOR_PER_TASK, which
> is the knob for the feature:
> 
> config STACKPROTECTOR_PER_TASK
>          bool "Use a unique stack canary value for each task"
>          depends on GCC_PLUGINS && STACKPROTECTOR && SMP && !XIP_DEFLATED_DATA
>          select GCC_PLUGIN_ARM_SSP_PER_TASK
>          default y
> 
>> Build error:
>>
>>   HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o - due to: scripts/gcc-plugins/gcc-common.h
>> In file included from scripts/gcc-plugins/arm_ssp_per_task_plugin.c:3:0:
>> scripts/gcc-plugins/gcc-common.h:153:0: warning: "__unused" redefined
>> #define __unused __attribute__((__unused__))
>> ^
> 
> Does the following patch fix your build? (I assume that line is just a
> warning, but if not...)
> 
> diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
> index 552d5efd7cb7..17f06079a712 100644
> --- a/scripts/gcc-plugins/gcc-common.h
> +++ b/scripts/gcc-plugins/gcc-common.h
> @@ -150,8 +150,12 @@ void print_gimple_expr(FILE *, gimple, int, int);
>   void dump_gimple_stmt(pretty_printer *, gimple, int, int);
>   #endif
>   
> +#ifndef __unused
>   #define __unused __attribute__((__unused__))
> +#endif
> +#ifndef __visible
>   #define __visible __attribute__((visibility("default")))
> +#endif
>   
>   #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
>   #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
> 
>>   HOSTLLD -shared scripts/gcc-plugins/arm_ssp_per_task_plugin.so - due to target missing
>> Undefined symbols for architecture x86_64:
>>   "gen_reg_rtx(machine_mode)", referenced from:
>>       (anonymous namespace)::arm_pertask_ssp_rtl_pass::execute() in arm_ssp_per_task_plugin.o
> 
> However, this part sounds more like what was fixed with
> 259799ea5a9a ("gcc-plugins: arm_ssp_per_task_plugin: Fix for older GCC < 6")
> 
> And maybe some additional fixes for 4.9 are needed?
> 
>> This is because CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK became automatically enabled and was never
>> before. So the compiler may lack some library search path for building this plugin (which we
>> did never miss).
> 
> Right -- maybe CONFIG_STACKPROTECTOR_PER_TASK doesn't work with old gcc
> 4.9.2? I'll see if I can find that compiler version...
> 

My build environment is based on debian-jessie

$ g++ --version
g++ (Debian 4.9.2-10) 4.9.2

After the fix I posted (which is now commit 259799ea5a9a ("gcc-plugins: 
arm_ssp_per_task_plugin: Fix for older GCC < 6")) I wasn't having any 
more problems.



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

* Re: [BUG v5.2-rc1] ARM build broken
  2019-05-20 21:21       ` Chris Packham
@ 2019-05-21 11:23         ` H. Nikolaus Schaller
  2019-05-21 20:36           ` Kees Cook
  0 siblings, 1 reply; 9+ messages in thread
From: H. Nikolaus Schaller @ 2019-05-21 11:23 UTC (permalink / raw)
  To: Chris Packham, Kees Cook
  Cc: lkml, Masahiro Yamada, Ard Biesheuvel,
	Discussions about the Letux Kernel

Hi Chris,

> Am 20.05.2019 um 23:21 schrieb Chris Packham <Chris.Packham@alliedtelesis.co.nz>:
> 
> On 21/05/19 6:54 AM, Kees Cook wrote:
>> [Adding Chris and Ard, who might have more compiler versions that me...]
> 
> Late to the thread but ...
> 
>> 
>> On Mon, May 20, 2019 at 07:08:39PM +0200, H. Nikolaus Schaller wrote:
>>>> Am 20.05.2019 um 17:59 schrieb Kees Cook <keescook@chromium.org>:
>>>> 
>>>> On Mon, May 20, 2019 at 05:15:02PM +0200, H. Nikolaus Schaller wrote:
>>>>> Hi,
>>>>> it seems as if ARM build is broken since ARM now hard enables CONFIG_HAVE_GCC_PLUGINS
>>>>> which indirectly enables CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK. Compiling this breaks
>>>>> on my system (Darwin build host) due to conflicts in system headers and Linux headers.
>>>>> 
>>>>> So how can I turn off all these GCC_PLUGINS?
>>>>> 
>>>>> The offending patch seems to be
>>>>> 
>>>>> 	security: Create "kernel hardening" config area
>>>>> 
>>>>> especially the new "default y" for GCC_PLUGINS. After removing that line from
>>>>> scripts/gcc-plugins/Kconfig makes my compile succeed.
>>>> 
>>>> The intention is to enable it _if_ the plugins are available as part of
>>>> the build environment. The "default y" on GCC_PLUGINS is mediated by:
>>>>        depends on HAVE_GCC_PLUGINS
>>> 
>>> HAVE_GCC_PLUGINS has the following description:
>>> 
>>> 	An arch should select this symbol if it supports building with
>>>           GCC plugins.
>>> 
>>> So an ARCH (ARM) selects it unconditionally of the build environment.
>>> 
>>>>        depends on PLUGIN_HOSTCC != ""
>>> 
>>> Well, we have it set to "g++" for ages and it was not a problem.
>>> So both conditions are true.
>> 
>> PLUGIN_HOSTCC should have passed the scripts/gcc-plugin.sh test, so
>> that's correct. And the result (CONFIG_GCC_PLUGINS) is correct: it
>> doesn't enable or disable anything itself.
>> 
>> What you want is to disable CONFIG_STACKPROTECTOR_PER_TASK, which
>> is the knob for the feature:
>> 
>> config STACKPROTECTOR_PER_TASK
>>         bool "Use a unique stack canary value for each task"
>>         depends on GCC_PLUGINS && STACKPROTECTOR && SMP && !XIP_DEFLATED_DATA
>>         select GCC_PLUGIN_ARM_SSP_PER_TASK
>>         default y
>> 
>>> Build error:
>>> 
>>>  HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o - due to: scripts/gcc-plugins/gcc-common.h
>>> In file included from scripts/gcc-plugins/arm_ssp_per_task_plugin.c:3:0:
>>> scripts/gcc-plugins/gcc-common.h:153:0: warning: "__unused" redefined
>>> #define __unused __attribute__((__unused__))
>>> ^
>> 
>> Does the following patch fix your build? (I assume that line is just a
>> warning, but if not...)
>> 
>> diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
>> index 552d5efd7cb7..17f06079a712 100644
>> --- a/scripts/gcc-plugins/gcc-common.h
>> +++ b/scripts/gcc-plugins/gcc-common.h
>> @@ -150,8 +150,12 @@ void print_gimple_expr(FILE *, gimple, int, int);
>>  void dump_gimple_stmt(pretty_printer *, gimple, int, int);
>>  #endif
>> 
>> +#ifndef __unused
>>  #define __unused __attribute__((__unused__))
>> +#endif
>> +#ifndef __visible
>>  #define __visible __attribute__((visibility("default")))
>> +#endif
>> 
>>  #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
>>  #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
>> 
>>>  HOSTLLD -shared scripts/gcc-plugins/arm_ssp_per_task_plugin.so - due to target missing
>>> Undefined symbols for architecture x86_64:
>>>  "gen_reg_rtx(machine_mode)", referenced from:
>>>      (anonymous namespace)::arm_pertask_ssp_rtl_pass::execute() in arm_ssp_per_task_plugin.o
>> 
>> However, this part sounds more like what was fixed with
>> 259799ea5a9a ("gcc-plugins: arm_ssp_per_task_plugin: Fix for older GCC < 6")
>> 
>> And maybe some additional fixes for 4.9 are needed?
>> 
>>> This is because CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK became automatically enabled and was never
>>> before. So the compiler may lack some library search path for building this plugin (which we
>>> did never miss).
>> 
>> Right -- maybe CONFIG_STACKPROTECTOR_PER_TASK doesn't work with old gcc
>> 4.9.2? I'll see if I can find that compiler version...
>> 
> 
> My build environment is based on debian-jessie
> 
> $ g++ --version
> g++ (Debian 4.9.2-10) 4.9.2
> 
> After the fix I posted (which is now commit 259799ea5a9a ("gcc-plugins: 
> arm_ssp_per_task_plugin: Fix for older GCC < 6")) I wasn't having any 
> more problems.

Ok, fine.

So it indeed looks as if my host-g++ can not properly build gcc-plugins for
the arm cross-gcc. This may come from using Darwin as the build host... So
it may have/use/need a different gcc for building the gcc-plugin for
cross-building the kernel.

Hm. Yes. The cross-toolchain was bootstrapped from scratch. The HOSTCC
comes from Macports and may be a different version. So it is likely that
the HOSTCC from Macports can not build a compatible gcc-plugin for the
cross-gcc.

That seems to be a significant assumption about the build infrastructure
which now became permanently enabled by the "default y" for GCC_PLUGINS.

I am not sure what the right way forward is. Probably for me it is to find
out if I can fix my cross-toolchain. Or if the kernel should better check
if gcc-plugins can really be built, if they are automatically enabled.
Or keep all gcc-plugins disabled until explicitly configured for?

BR and thanks,
Nikolaus


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

* Re: [BUG v5.2-rc1] ARM build broken
  2019-05-21 11:23         ` H. Nikolaus Schaller
@ 2019-05-21 20:36           ` Kees Cook
  2019-05-22  6:02             ` H. Nikolaus Schaller
  0 siblings, 1 reply; 9+ messages in thread
From: Kees Cook @ 2019-05-21 20:36 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: Chris Packham, lkml, Masahiro Yamada, Ard Biesheuvel,
	Discussions about the Letux Kernel

On Tue, May 21, 2019 at 01:23:36PM +0200, H. Nikolaus Schaller wrote:
> >>>  HOSTLLD -shared scripts/gcc-plugins/arm_ssp_per_task_plugin.so - due to target missing
> >>> Undefined symbols for architecture x86_64:
> >>>  "gen_reg_rtx(machine_mode)", referenced from:
> >>>      (anonymous namespace)::arm_pertask_ssp_rtl_pass::execute() in arm_ssp_per_task_plugin.o

Are you seeing this error still, even after the fix I sent? Perhaps I
misunderstood that it solves all of the build issues?

> That seems to be a significant assumption about the build infrastructure
> which now became permanently enabled by the "default y" for GCC_PLUGINS.
> 
> I am not sure what the right way forward is. Probably for me it is to find
> out if I can fix my cross-toolchain. Or if the kernel should better check
> if gcc-plugins can really be built, if they are automatically enabled.
> Or keep all gcc-plugins disabled until explicitly configured for?

Right, that seems to be the case: it seems that the gcc plugin build
sanity detection script is not working in your environment. You can
check it directly.

Here's the bits from the Kconfig (though I added --show-error for you,
in case that's useful):

preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC))

scripts/gcc-plugin.sh --show-error "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)"

I'm not sure what your kernel build picks for gcc-version, HOSTCXX
HOSTCC and CC...

-- 
Kees Cook

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

* Re: [BUG v5.2-rc1] ARM build broken
  2019-05-21 20:36           ` Kees Cook
@ 2019-05-22  6:02             ` H. Nikolaus Schaller
  2019-06-03  7:46               ` [Letux-kernel] " H. Nikolaus Schaller
  0 siblings, 1 reply; 9+ messages in thread
From: H. Nikolaus Schaller @ 2019-05-22  6:02 UTC (permalink / raw)
  To: Kees Cook
  Cc: Chris Packham, lkml, Masahiro Yamada, Ard Biesheuvel,
	Discussions about the Letux Kernel

Hi Kees,

> Am 21.05.2019 um 22:36 schrieb Kees Cook <keescook@chromium.org>:
> 
> On Tue, May 21, 2019 at 01:23:36PM +0200, H. Nikolaus Schaller wrote:
>>>>> HOSTLLD -shared scripts/gcc-plugins/arm_ssp_per_task_plugin.so - due to target missing
>>>>> Undefined symbols for architecture x86_64:
>>>>> "gen_reg_rtx(machine_mode)", referenced from:
>>>>>     (anonymous namespace)::arm_pertask_ssp_rtl_pass::execute() in arm_ssp_per_task_plugin.o
> 
> Are you seeing this error still, even after the fix I sent?

Yes.

> Perhaps I
> misunderstood that it solves all of the build issues?

There was a compiler warning and a linker error. The patch only fixes the compiler warning.

> 
>> That seems to be a significant assumption about the build infrastructure
>> which now became permanently enabled by the "default y" for GCC_PLUGINS.
>> 
>> I am not sure what the right way forward is. Probably for me it is to find
>> out if I can fix my cross-toolchain. Or if the kernel should better check
>> if gcc-plugins can really be built, if they are automatically enabled.
>> Or keep all gcc-plugins disabled until explicitly configured for?
> 
> Right, that seems to be the case: it seems that the gcc plugin build
> sanity detection script is not working in your environment. You can
> check it directly.
> 
> Here's the bits from the Kconfig (though I added --show-error for you,
> in case that's useful):
> 
> preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC))
> 
> scripts/gcc-plugin.sh --show-error "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)"
> 
> I'm not sure what your kernel build picks for gcc-version, HOSTCXX
> HOSTCC and CC...

It turns out that HOSTCC and HOSTCXX are a gcc-4.9.4 installed through MacPorts.
And CC is the self-bootstrapped cross-gcc-4.9.2 toolchain for arm.

The problem is likely that they do not know of each other, i.e. the required
include and library search paths. Therefore HOSTCXX can't build plugins compatible
with CC because it does not even know its existence. Or the gcc-4.9.4 from MacPorts
is missing the gcc-plugin library to link against which would explain the HOSTLLD
error message as well.

This seems not to be found by the tests of scripts/gcc-plugin.sh. I have to check why...

BR and thanks,
Nikolaus


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

* Re: [Letux-kernel] [BUG v5.2-rc1] ARM build broken
  2019-05-22  6:02             ` H. Nikolaus Schaller
@ 2019-06-03  7:46               ` H. Nikolaus Schaller
  0 siblings, 0 replies; 9+ messages in thread
From: H. Nikolaus Schaller @ 2019-06-03  7:46 UTC (permalink / raw)
  To: Kees Cook
  Cc: Masahiro Yamada, Chris Packham, lkml, Ard Biesheuvel,
	Discussions about the Letux Kernel

Hi Kees,

> Am 22.05.2019 um 08:02 schrieb H. Nikolaus Schaller <hns@goldelico.com>:
> 
> It turns out that HOSTCC and HOSTCXX are a gcc-4.9.4 installed through MacPorts.
> And CC is the self-bootstrapped cross-gcc-4.9.2 toolchain for arm.
> 
> The problem is likely that they do not know of each other, i.e. the required
> include and library search paths. Therefore HOSTCXX can't build plugins compatible
> with CC because it does not even know its existence. Or the gcc-4.9.4 from MacPorts
> is missing the gcc-plugin library to link against which would explain the HOSTLLD
> error message as well.
> 
> This seems not to be found by the tests of scripts/gcc-plugin.sh. I have to check why...

Well, here are some findings:
* gcc-plugin.sh does not check if the g++ is really capable of linking a gcc-plugin
* it only syntax-checks if g++ supports the designated initializer GNU extension
* my gcc from MacPorts passes this test
* but seems not to be able to properly build any gcc-plugin.so
* I also get the similar linker errors when trying this gcc-plugin example:
  https://thinkingeek.com/2015/08/16/a-simple-plugin-for-gcc-part-1/
* the step that fails with the MacPorts gcc is linking the gcc-plugin.so from the gcc-plugin.o file
* I have not found any hint where this step should get the missing symbols from
  There is no lgcc or similar available

So I'd suggest to expand gcc-plugin.sh to not only syntax-check but also test if a
plugin.so can be successfully linked.

Maybe something like

	$2 -std=gnu++98 -shared -o /tmp/plugin.so -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1

Maybe the test source code should reference plugin_default_version_check() to trigger
the linker.

BR and thanks,
Nikolaus

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

end of thread, other threads:[~2019-06-03  7:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4DB08A04-D03A-4441-85DE-64A13E6D709C@goldelico.com>
2019-05-20 15:59 ` [BUG v5.2-rc1] ARM build broken Kees Cook
     [not found]   ` <D8F987B2-8F41-46DE-B298-89541D7A9774@goldelico.com>
2019-05-20 18:53     ` Kees Cook
2019-05-20 19:35       ` H. Nikolaus Schaller
2019-05-20 20:25         ` Kees Cook
2019-05-20 21:21       ` Chris Packham
2019-05-21 11:23         ` H. Nikolaus Schaller
2019-05-21 20:36           ` Kees Cook
2019-05-22  6:02             ` H. Nikolaus Schaller
2019-06-03  7:46               ` [Letux-kernel] " H. Nikolaus Schaller

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.