Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/cmocka: don't allow building for Thumb1
@ 2023-01-02  7:15 Joel Carlson
  2023-03-09 21:54 ` Arnout Vandecappelle
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Carlson @ 2023-01-02  7:15 UTC (permalink / raw)
  To: buildroot

The cmocka package checks if a toolchain supports the
-fstack-clash-protection compiler flag, and if it does automatically
uses it. That flag is not supported by GCC for Thumb1 builds (at least
as of both GCC 11 and GCC 12). So disallow building cmocka for Thumb1.
Building for ARM or Thumb2 is fine.

As an example in GCC 12.2.0, within the file gcc/config/arm/arm.cc, the
error occurs in the thumb1_expand_prologue() call:

    /* If we have a frame, then do stack checking.  FIXME: not implemented.  */
    if ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
         || flag_stack_clash_protection)
        && size)
      sorry ("%<-fstack-check=specific%> for Thumb-1");

An example build error output:
/tmp/instance-7/output-1/build/cmocka-1.1.5/src/cmocka.c: In function 'c_strmatch.part.0':
/tmp/instance-7/output-1/build/cmocka-1.1.5/src/cmocka.c:539:1: sorry, unimplemented: '-fstack-check=specific' for Thumb-1
  539 | }
        | ^

Fixes:
http://autobuild.buildroot.net/results/4044b3a71d3130d934c7a7c0c5badfabb2a97030/

Signed-off-by: Joel Carlson <JoelsonCarl@gmail.com>
---
 package/cmocka/Config.in | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/package/cmocka/Config.in b/package/cmocka/Config.in
index cf49d0f6be..6cadaa616a 100644
--- a/package/cmocka/Config.in
+++ b/package/cmocka/Config.in
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_CMOCKA
 	bool cmocka
 	depends on !BR2_STATIC_LIBS
+	depends on !BR2_ARM_INSTRUCTIONS_THUMB
 	help
 	  cmocka is an elegant unit testing framework for C with support
 	  for mock objects. It only requires the standard C library,
@@ -11,5 +12,5 @@ config BR2_PACKAGE_CMOCKA
 
 	  https://cmocka.org
 
-comment "cmocka needs a toolchain w/ dynamic library"
-	depends on BR2_STATIC_LIBS
+comment "cmocka needs a toolchain w/ dynamic library, and can't be built for Thumb1"
+	depends on BR2_STATIC_LIBS || BR2_ARM_INSTRUCTIONS_THUMB
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] package/cmocka: don't allow building for Thumb1
  2023-01-02  7:15 [Buildroot] [PATCH 1/1] package/cmocka: don't allow building for Thumb1 Joel Carlson
@ 2023-03-09 21:54 ` Arnout Vandecappelle
  2023-07-30 22:13   ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 3+ messages in thread
From: Arnout Vandecappelle @ 2023-03-09 21:54 UTC (permalink / raw)
  To: Joel Carlson, buildroot



On 02/01/2023 08:15, Joel Carlson wrote:
> The cmocka package checks if a toolchain supports the
> -fstack-clash-protection compiler flag, and if it does automatically
> uses it. That flag is not supported by GCC for Thumb1 builds (at least
> as of both GCC 11 and GCC 12). So disallow building cmocka for Thumb1.
> Building for ARM or Thumb2 is fine.
> 
> As an example in GCC 12.2.0, within the file gcc/config/arm/arm.cc, the
> error occurs in the thumb1_expand_prologue() call:
> 
>      /* If we have a frame, then do stack checking.  FIXME: not implemented.  */
>      if ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
>           || flag_stack_clash_protection)
>          && size)
>        sorry ("%<-fstack-check=specific%> for Thumb-1");
> 
> An example build error output:
> /tmp/instance-7/output-1/build/cmocka-1.1.5/src/cmocka.c: In function 'c_strmatch.part.0':
> /tmp/instance-7/output-1/build/cmocka-1.1.5/src/cmocka.c:539:1: sorry, unimplemented: '-fstack-check=specific' for Thumb-1
>    539 | }
>          | ^
> 
> Fixes:
> http://autobuild.buildroot.net/results/4044b3a71d3130d934c7a7c0c5badfabb2a97030/

  Instead of adding an arch exception, have you tried (conditionally) adding 
-DWITH_STACK_CLASH_PROTECTION=OFF to CMOCKA_CONFIGURE_OPTS? I think that that 
should bypass the check.

  Regards,
  Arnout

> 
> Signed-off-by: Joel Carlson <JoelsonCarl@gmail.com>
> ---
>   package/cmocka/Config.in | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/package/cmocka/Config.in b/package/cmocka/Config.in
> index cf49d0f6be..6cadaa616a 100644
> --- a/package/cmocka/Config.in
> +++ b/package/cmocka/Config.in
> @@ -1,6 +1,7 @@
>   config BR2_PACKAGE_CMOCKA
>   	bool cmocka
>   	depends on !BR2_STATIC_LIBS
> +	depends on !BR2_ARM_INSTRUCTIONS_THUMB
>   	help
>   	  cmocka is an elegant unit testing framework for C with support
>   	  for mock objects. It only requires the standard C library,
> @@ -11,5 +12,5 @@ config BR2_PACKAGE_CMOCKA
>   
>   	  https://cmocka.org
>   
> -comment "cmocka needs a toolchain w/ dynamic library"
> -	depends on BR2_STATIC_LIBS
> +comment "cmocka needs a toolchain w/ dynamic library, and can't be built for Thumb1"
> +	depends on BR2_STATIC_LIBS || BR2_ARM_INSTRUCTIONS_THUMB
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] package/cmocka: don't allow building for Thumb1
  2023-03-09 21:54 ` Arnout Vandecappelle
@ 2023-07-30 22:13   ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-07-30 22:13 UTC (permalink / raw)
  To: Arnout Vandecappelle; +Cc: buildroot

On Thu, 9 Mar 2023 22:54:27 +0100
Arnout Vandecappelle <arnout@mind.be> wrote:

>   Instead of adding an arch exception, have you tried (conditionally) adding 
> -DWITH_STACK_CLASH_PROTECTION=OFF to CMOCKA_CONFIGURE_OPTS? I think that that 
> should bypass the check.

It works!

So I applied Joel's patch but essentially rewrote it (and its commit
message) to use the solution proposed by Arnout.

Thanks!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2023-07-30 22:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-02  7:15 [Buildroot] [PATCH 1/1] package/cmocka: don't allow building for Thumb1 Joel Carlson
2023-03-09 21:54 ` Arnout Vandecappelle
2023-07-30 22:13   ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox