[libvirt] [PATCH 0/2] build: -Wframe-larger-than shenanigans
The recent cputest addition broke the build with clang for me, since clang calculates the stack size differently than gcc. Put the strict limit into all warning by default (this starts enforcing it for examples, for example) and raise the limit by a few orders, which might appear Sisyphean but I believe it's needed for putting two conflicting limits on the compiler command line. Ján Tomko (2): build: warn on a large frame by default build: relax the relaxed stack frame limit further m4/virt-compile-warnings.m4 | 4 ++-- src/Makefile.am | 2 -- tools/Makefile.am | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) -- 2.19.2
My commit e73889b6311f5b43d859caa4bae84bfdb299967a split the -Wframe-larger-than warning setting into two different variables - STRICT_FRAME_LIMIT_CFLAGS for the library code and RELAXED_FRAME_LIMIT_CFLAGS which was needed for tests. Use the strict limit by default and specify the warning flag twice for the parts that require a larger stack frame, relying on the fact that the compiler will pick up the latter value. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- m4/virt-compile-warnings.m4 | 2 +- src/Makefile.am | 2 -- tools/Makefile.am | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index be5dc3de51..5f930756b0 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -171,7 +171,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # This should be < 256 really. Currently we're down to 4096, # but using 1024 bytes sized buffers (mostly for virStrerror) # stops us from going down further - gl_WARN_ADD([-Wframe-larger-than=4096], [STRICT_FRAME_LIMIT_CFLAGS]) + wantwarn="$wantwarn -Wframe-larger-than=4096" gl_WARN_ADD([-Wframe-larger-than=32768], [RELAXED_FRAME_LIMIT_CFLAGS]) # Extra special flags diff --git a/src/Makefile.am b/src/Makefile.am index 0267f16625..15480d7b9a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,8 +31,6 @@ AM_CPPFLAGS = -I../gnulib/lib \ -Dabs_top_srcdir="\"$(abs_top_srcdir)\"" \ $(NULL) -WARN_CFLAGS += $(STRICT_FRAME_LIMIT_CFLAGS) - AM_CFLAGS = $(LIBXML_CFLAGS) \ $(GLIB_CFLAGS) \ $(WARN_CFLAGS) \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 67b342d306..426a6ba661 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -29,8 +29,6 @@ AM_CPPFLAGS = \ # needed STANDALONE_CPPFLAGS = -I$(top_srcdir) -WARN_CFLAGS += $(STRICT_FRAME_LIMIT_CFLAGS) - AM_CFLAGS = \ $(WARN_CFLAGS) \ $(COVERAGE_CFLAGS) \ -- 2.19.2
On 12/14/19 6:49 PM, Ján Tomko wrote:
My commit e73889b6311f5b43d859caa4bae84bfdb299967a split the -Wframe-larger-than warning setting into two different variables - STRICT_FRAME_LIMIT_CFLAGS for the library code and RELAXED_FRAME_LIMIT_CFLAGS which was needed for tests.
Use the strict limit by default and specify the warning flag twice for the parts that require a larger stack frame, relying on the fact that the compiler will pick up the latter value.
Signed-off-by: Ján Tomko <jtomko@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Pick 256k as the limit. While -Wno-frame-larger-than would make more sense for usage in our test suite, the -Wno version seems to have no effect if -Wframe-larger-than was already specified. Use an (un)reasonably large value instead. Fixes the build with clang: ../../tests/cputest.c:964:1: error: stack frame size of 33176 bytes in function 'mymain' [-Werror,-Wframe-larger-than=] mymain(void) ^ 1 error generated. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- m4/virt-compile-warnings.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 5f930756b0..fc0b9bfa55 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -172,7 +172,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # but using 1024 bytes sized buffers (mostly for virStrerror) # stops us from going down further wantwarn="$wantwarn -Wframe-larger-than=4096" - gl_WARN_ADD([-Wframe-larger-than=32768], [RELAXED_FRAME_LIMIT_CFLAGS]) + gl_WARN_ADD([-Wframe-larger-than=262144], [RELAXED_FRAME_LIMIT_CFLAGS]) # Extra special flags dnl -fstack-protector stuff passes gl_WARN_ADD with gcc -- 2.19.2
On 12/14/19 6:49 PM, Ján Tomko wrote:
Pick 256k as the limit.
While -Wno-frame-larger-than would make more sense for usage in our test suite, the -Wno version seems to have no effect if -Wframe-larger-than was already specified.
Use an (un)reasonably large value instead.
Fixes the build with clang: ../../tests/cputest.c:964:1: error: stack frame size of 33176 bytes in function 'mymain' [-Werror,-Wframe-larger-than=] mymain(void) ^ 1 error generated.
Signed-off-by: Ján Tomko <jtomko@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
participants (2)
-
Daniel Henrique Barboza -
Ján Tomko