package/cmocka: don't allow building for Thumb1
PATCH 1/1 package/cmocka: don't allow building for Thumb1
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/
--- package/cmocka/Config.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
package/cmocka/Config.in +3 -2
@@ -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
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 15 lines · Joel Carlson
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");
Quoted 8 lines
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
Quoted 19 lines
Signed-off-by Joel Carlson <[email protected]>--- package/cmocka/Config.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)package/cmocka/Config.in +1
-0@@ -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,
package/cmocka/Config.in config BR2_PACKAGE_CMOCKA · line 16
Quoted 7 lines
package/cmocka/Config.in +2
-2@@ -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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 3 lines · On Thu, 9 Mar 2023 22:54:27 +0100 Arnout Vandecappelle <[email protected]> wrote:
Instead of adding an arch exception, have you tried (conditionally) adding
-DWITH_STACK_CLASH_PROTECTION=OFF toCMOCKA_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
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot