[libvirt] [PATCH] tests: ignore -Wframe-larger-than= with clang

Roman Bogorodskiy bogorodskiy at gmail.com
Sat Apr 1 12:35:11 UTC 2017


When building with clang and using CFLAGS for debugging (like -O2 -g),
build fails on building tests unless configured with --disable-werror:

virshtest.c:253:1: error: stack frame size of 5512 bytes in function 'mymain' [-Werror,-Wframe-larger-than=]
mymain(void)

To fix that, introduce VIR_WARNINGS_NO_FRAME_LARGER_THAN(_RESET)
macros that disable "-Wframe-larger-than=" diagnostics when
compiling with clang and use that for tests that fail.
---
 src/internal.h          | 13 +++++++++++++
 tests/cputest.c         |  4 ++++
 tests/qemuhotplugtest.c |  3 +++
 tests/sockettest.c      |  5 +++++
 tests/virshtest.c       |  4 ++++
 tests/virstringtest.c   |  5 +++++
 6 files changed, 34 insertions(+)

diff --git a/src/internal.h b/src/internal.h
index d64be93b3..c1f4aff27 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -286,6 +286,19 @@
 #  define VIR_WARNINGS_NO_WLOGICALOP_STRCHR
 # endif
 
+/* Workaround for clang's triggering  "-Wframe-larger-than=" on tests
+ * when compiling with '-O0' */
+# ifndef VIR_WARNINGS_NO_FRAME_LARGER_THAN
+#  if defined(__clang__)
+#   define VIR_WARNINGS_NO_FRAME_LARGER_THAN                       \
+     _Pragma ("clang diagnostic push")                             \
+     _Pragma ("clang diagnostic ignored \"-Wframe-larger-than=\"")
+#   define VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET  _Pragma("clang diagnostic pop")
+#  else
+#   define VIR_WARNINGS_NO_FRAME_LARGER_THAN
+#   define VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+#  endif /* defined(__clang__) */
+# endif
 
 /*
  * Use this when passing possibly-NULL strings to printf-a-likes.
diff --git a/tests/cputest.c b/tests/cputest.c
index 3d3e43f16..b00352390 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -732,6 +732,8 @@ static const char *models[]     = { "qemu64", "core2duo", "Nehalem" };
 static const char *haswell[]    = { "SandyBridge", "Haswell" };
 static const char *ppc_models[] = { "POWER6", "POWER7", "POWER8" };
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
 static int
 mymain(void)
 {
@@ -1012,4 +1014,6 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
 VIRT_TEST_MAIN(mymain)
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index cdeb3f1bf..5492d09c6 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -574,6 +574,7 @@ testQemuHotplugCpuIndividual(const void *opaque)
 }
 
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
 
 static int
 mymain(void)
@@ -856,4 +857,6 @@ mymain(void)
     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
 VIRT_TEST_MAIN(mymain)
diff --git a/tests/sockettest.c b/tests/sockettest.c
index 4d49b38aa..a33b98f6f 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -264,6 +264,9 @@ testIsLocalhostHelper(const void *opaque)
     return 0;
 }
 
+
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
 static int
 mymain(void)
 {
@@ -482,4 +485,6 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
 VIRT_TEST_MAIN(mymain)
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 2f1022416..149e33feb 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -249,6 +249,8 @@ static int testCompareEcho(const void *data)
 }
 
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
 static int
 mymain(void)
 {
@@ -419,6 +421,8 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
 VIRT_TEST_MAIN(mymain)
 
 #endif /* WIN32 */
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index db1731f96..914eeea24 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -693,6 +693,9 @@ static int testStripControlChars(const void *args)
     return ret;
 }
 
+
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
 static int
 mymain(void)
 {
@@ -961,4 +964,6 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
 VIRT_TEST_MAIN(mymain)
-- 
2.11.0




More information about the libvir-list mailing list