[PATCH 2/2] build: Work around clang's stack size calculation without optimization

Peter Krempa posted 2 patches 1 year ago
[PATCH 2/2] build: Work around clang's stack size calculation without optimization
Posted by Peter Krempa 1 year ago
When building without optimization on clang, certain big functions trip
the stack size limit despite not actually reaching it. Relax the stack
limit size for clang without optimization.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 meson.build | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 6b6f7ccb7c..d29761bc71 100644
--- a/meson.build
+++ b/meson.build
@@ -247,8 +247,17 @@ alloc_max = run_command(
   check: true,
 )

+stack_frame_size = 2048
+
+# clang without optimization enlarges stack frames in certain corner cases
+if cc.get_id() == 'clang' and get_option('optimization') == '0'
+    stack_frame_size = 4096
+endif
+
 # sanitizer instrumentation may enlarge stack frames
-stack_frame_size = get_option('b_sanitize') == 'none' ? 2048 : 32768
+if get_option('b_sanitize') == 'none'
+  stack_frame_size == 32768
+endif

 # array_bounds=2 check triggers false positive on some GCC
 # versions when using sanitizers. Seen on Fedora 34 with
-- 
2.41.0
Re: [PATCH 2/2] build: Work around clang's stack size calculation without optimization
Posted by Daniel P. Berrangé 1 year ago
On Mon, Sep 04, 2023 at 12:13:37PM +0200, Peter Krempa wrote:
> When building without optimization on clang, certain big functions trip
> the stack size limit despite not actually reaching it. Relax the stack
> limit size for clang without optimization.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  meson.build | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|