From 22d7f32fdaa58e9bb81f93d0b5c07aa410d3bf8c Mon Sep 17 00:00:00 2001
From: elivdahan <elivdahan@gmail.com>
Date: Mon, 1 Apr 2019 09:38:20 +0300
Subject: [PATCH] cmake: Fix bzero mis-detection on MinGW

Using a C compiler ignores non-existent functions, and tries to link them anyway.

The compiler optimizes `bzero(buf, 1)` to `movb   $0x0,0xf(%esp)`, so bzero is
not called at all, and the linker succeeds.

Increase the buffer size to 100 to avoid this optimization.
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 453fdfd2..9a70e0a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -683,7 +683,7 @@ endif()
 
 CHECK_C_SOURCE_COMPILES(
 	"#include <strings.h>
-	int main(int argc, char **argv) { char buf[1]; bzero(buf, 1); return 0; }
+	int main(int argc, char **argv) { char buf[100]; bzero(buf, 100); return 0; }
 	" LWS_HAVE_BZERO)
 
 CHECK_FUNCTION_EXISTS(fork LWS_HAVE_FORK)
-- 
GitLab