From 9b883be2ad10a726dace13befb7ef9e0805174aa Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Sun, 23 Aug 2020 12:59:39 -0400 Subject: [PATCH 1/7] Add additional errors --- src/mono/configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 72abca2bbf3652..d15b386534b2ff 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -888,7 +888,7 @@ AC_ARG_ENABLE(visibility-hidden, WARN='' if test x"$GCC" = xyes; then WARN='-Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes' - CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length" + CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Werror=c++-compat" # We require C99 with some GNU extensions, e.g. `linux` macro CFLAGS="$CFLAGS -std=gnu99" @@ -925,6 +925,10 @@ if test x"$GCC" = xyes; then WARN="$WARN -Wno-unused-function -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand" # We rely on zero length arrays in structs WARN="$WARN -Wno-zero-length-array" + # Common warnings we have only fixed completely on OSX + WARN="$WARN -Werror=unused-variable -Werror=missing-prototypes" + else + WARN="$WARN -Werror=maybe-uninitalized" fi else # The Sun Forte compiler complains about inline functions that access static variables From 1b0ee6d9b35736bb081b08681653a656a1508511 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Sun, 23 Aug 2020 13:00:11 -0400 Subject: [PATCH 2/7] Fix cpuidex decalaration Is there somewhere better to put this? --- src/mono/mono/mini/simd-intrinsics-netcore.c | 6 ++---- src/mono/mono/utils/mono-hwcap-vars.h | 3 +++ src/mono/mono/utils/mono-hwcap-x86.c | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mono/mono/mini/simd-intrinsics-netcore.c b/src/mono/mono/mini/simd-intrinsics-netcore.c index ab9b3c6b290333..3888ea3bf1d557 100644 --- a/src/mono/mono/mini/simd-intrinsics-netcore.c +++ b/src/mono/mono/mini/simd-intrinsics-netcore.c @@ -28,6 +28,7 @@ mono_simd_intrinsics_init (void) #include "mono/utils/bsearch.h" #include #include +#include #if defined (MONO_ARCH_SIMD_INTRINSICS) && defined(ENABLE_NETCORE) @@ -2177,13 +2178,10 @@ MONO_EMPTY_SOURCE_FILE (simd_intrinsics_netcore); #if defined(ENABLE_NETCORE) && defined(TARGET_AMD64) -gboolean -mono_cpuidex (int id, int sub_id, int *p_eax, int *p_ebx, int *p_ecx, int *p_edx); - void ves_icall_System_Runtime_Intrinsics_X86_X86Base___cpuidex (int abcd[4], int function_id, int subfunction_id) { - mono_cpuidex (function_id, subfunction_id, + mono_hwcap_x86_call_cpuidex (function_id, subfunction_id, &abcd [0], &abcd [1], &abcd [2], &abcd [3]); } #endif diff --git a/src/mono/mono/utils/mono-hwcap-vars.h b/src/mono/mono/utils/mono-hwcap-vars.h index b408568c729f4d..2c60a6441394db 100644 --- a/src/mono/mono/utils/mono-hwcap-vars.h +++ b/src/mono/mono/utils/mono-hwcap-vars.h @@ -81,4 +81,7 @@ MONO_HWCAP_VAR(x86_has_lzcnt) MONO_HWCAP_VAR(x86_has_popcnt) MONO_HWCAP_VAR(x86_has_avx) +gboolean +mono_hwcap_x86_call_cpuidex (int id, int sub_id, int *p_eax, int *p_ebx, int *p_ecx, int *p_edx); + #endif diff --git a/src/mono/mono/utils/mono-hwcap-x86.c b/src/mono/mono/utils/mono-hwcap-x86.c index f1949f5a8dc439..40bf6d37fe7856 100644 --- a/src/mono/mono/utils/mono-hwcap-x86.c +++ b/src/mono/mono/utils/mono-hwcap-x86.c @@ -30,7 +30,7 @@ #endif gboolean -mono_cpuidex (int id, int sub_id, int *p_eax, int *p_ebx, int *p_ecx, int *p_edx) +mono_hwcap_x86_call_cpuidex (int id, int sub_id, int *p_eax, int *p_ebx, int *p_ecx, int *p_edx) { #if defined(_MSC_VER) int info [4]; @@ -111,7 +111,7 @@ mono_hwcap_arch_init (void) { int eax, ebx, ecx, edx; - if (mono_cpuidex (1, 0, &eax, &ebx, &ecx, &edx)) { + if (mono_hwcap_x86_call_cpuidex (1, 0, &eax, &ebx, &ecx, &edx)) { if (edx & (1 << 15)) { mono_hwcap_x86_has_cmov = TRUE; @@ -144,16 +144,16 @@ mono_hwcap_arch_init (void) mono_hwcap_x86_has_avx = TRUE; } - if (mono_cpuidex (0x80000000, 0, &eax, &ebx, &ecx, &edx)) { + if (mono_hwcap_x86_call_cpuidex (0x80000000, 0, &eax, &ebx, &ecx, &edx)) { if ((unsigned int) eax >= 0x80000001 && ebx == 0x68747541 && ecx == 0x444D4163 && edx == 0x69746E65) { - if (mono_cpuidex (0x80000001, 0, &eax, &ebx, &ecx, &edx)) { + if (mono_hwcap_x86_call_cpuidex (0x80000001, 0, &eax, &ebx, &ecx, &edx)) { if (ecx & (1 << 6)) mono_hwcap_x86_has_sse4a = TRUE; } } } - if (mono_cpuidex (0x80000001, 0, &eax, &ebx, &ecx, &edx)) { + if (mono_hwcap_x86_call_cpuidex (0x80000001, 0, &eax, &ebx, &ecx, &edx)) { if (ecx & (1 << 5)) mono_hwcap_x86_has_lzcnt = TRUE; } From 27da9f547a692c10cc6741e8ede1a03a29b86e65 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Sun, 23 Aug 2020 13:04:29 -0400 Subject: [PATCH 3/7] Fix socklen_t fallback type --- src/mono/mono/metadata/w32socket-internals.h | 4 ++-- src/mono/mono/metadata/w32socket-unix.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/metadata/w32socket-internals.h b/src/mono/mono/metadata/w32socket-internals.h index 6cdb94063b17c3..4aeb8021a80302 100644 --- a/src/mono/mono/metadata/w32socket-internals.h +++ b/src/mono/mono/metadata/w32socket-internals.h @@ -20,7 +20,7 @@ #include #ifndef HAVE_SOCKLEN_T -#define socklen_t int +#define socklen_t unsigned int #endif #ifndef HOST_WIN32 @@ -64,7 +64,7 @@ SOCKET mono_w32socket_accept (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking); int -mono_w32socket_connect (SOCKET s, const struct sockaddr *name, int namelen, gboolean blocking); +mono_w32socket_connect (SOCKET s, const struct sockaddr *name, socklen_t namelen, gboolean blocking); int mono_w32socket_recv (SOCKET s, char *buf, int len, int flags, gboolean blocking); diff --git a/src/mono/mono/metadata/w32socket-unix.c b/src/mono/mono/metadata/w32socket-unix.c index ac3bd0f85ff2a1..f5803a42a40b3f 100644 --- a/src/mono/mono/metadata/w32socket-unix.c +++ b/src/mono/mono/metadata/w32socket-unix.c @@ -191,7 +191,7 @@ mono_w32socket_accept (SOCKET sock, struct sockaddr *addr, socklen_t *addrlen, g } int -mono_w32socket_connect (SOCKET sock, const struct sockaddr *addr, int addrlen, gboolean blocking) +mono_w32socket_connect (SOCKET sock, const struct sockaddr *addr, socklen_t addrlen, gboolean blocking) { SocketHandle *sockethandle; gint ret; From d6536f1e00ec808f17bde5aa1228ff584e2f43a9 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Mon, 24 Aug 2020 12:21:12 -0400 Subject: [PATCH 4/7] Just pass -Wc++-compat everywhere, pass -Werror on CI --- src/mono/configure.ac | 6 +----- src/mono/mono.proj | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index d15b386534b2ff..13d7df9c64f495 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -888,7 +888,7 @@ AC_ARG_ENABLE(visibility-hidden, WARN='' if test x"$GCC" = xyes; then WARN='-Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes' - CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Werror=c++-compat" + CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Wc++-compat" # We require C99 with some GNU extensions, e.g. `linux` macro CFLAGS="$CFLAGS -std=gnu99" @@ -925,10 +925,6 @@ if test x"$GCC" = xyes; then WARN="$WARN -Wno-unused-function -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand" # We rely on zero length arrays in structs WARN="$WARN -Wno-zero-length-array" - # Common warnings we have only fixed completely on OSX - WARN="$WARN -Werror=unused-variable -Werror=missing-prototypes" - else - WARN="$WARN -Werror=maybe-uninitalized" fi else # The Sun Forte compiler complains about inline functions that access static variables diff --git a/src/mono/mono.proj b/src/mono/mono.proj index a11853b47c527b..7185f77fcb40d2 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -693,6 +693,11 @@ <_MonoCXXFLAGS Include="-Wl,--build-id=sha1" /> + + + <_MonoConfigureParams Include="--enable-werror" /> + + <_MonoConfigureParams Include="--host=$(_MonoTuple)" /> <_MonoConfigureParams Include="--target=$(_MonoTuple)" /> From a7ebf7193805b7d36c879466fd839a1f65b24eea Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Mon, 24 Aug 2020 12:33:48 -0400 Subject: [PATCH 5/7] Pass -Werror on OSX only --- src/mono/mono.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 7185f77fcb40d2..d0107b4a4c9e66 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -694,7 +694,7 @@ - + <_MonoConfigureParams Include="--enable-werror" /> From 1da7f6b86f8749d5df1b8c7ee34b27df3c77dab9 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Mon, 24 Aug 2020 12:34:05 -0400 Subject: [PATCH 6/7] Another random fix --- src/mono/mono/mini/helpers.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index b62361ed532a15..0a7b0d9b43373b 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -124,10 +124,8 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id) #ifdef HOST_WIN32 const char *tmp = g_get_tmp_dir (); #endif - char *objdump_args = g_getenv ("MONO_OBJDUMP_ARGS"); char *as_file; char *o_file; - char *cmd; int unused G_GNUC_UNUSED; #ifdef HOST_WIN32 @@ -255,9 +253,10 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id) #endif #ifdef HAVE_SYSTEM - cmd = g_strdup_printf (ARCH_PREFIX AS_CMD " %s -o %s", as_file, o_file); + char *cmd = g_strdup_printf (ARCH_PREFIX AS_CMD " %s -o %s", as_file, o_file); unused = system (cmd); g_free (cmd); + char *objdump_args = g_getenv ("MONO_OBJDUMP_ARGS"); if (!objdump_args) objdump_args = g_strdup (""); From 685f175eb70823a667dc06dccb627fc9ebf1eb98 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Mon, 24 Aug 2020 12:45:53 -0400 Subject: [PATCH 7/7] Revert socklen_t typedef change It's no longer warning for me so best to leave it alone --- src/mono/mono/metadata/w32socket-internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/w32socket-internals.h b/src/mono/mono/metadata/w32socket-internals.h index 4aeb8021a80302..0fe5209c321d5e 100644 --- a/src/mono/mono/metadata/w32socket-internals.h +++ b/src/mono/mono/metadata/w32socket-internals.h @@ -20,7 +20,7 @@ #include #ifndef HAVE_SOCKLEN_T -#define socklen_t unsigned int +#define socklen_t int #endif #ifndef HOST_WIN32