From d600a01005748fba46bea3d52f170dc535496f47 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Wed, 22 Jan 2025 18:42:55 -0500 Subject: [PATCH 1/7] -Wwrite-strings --- libc/cmake/modules/LLVMLibCTestRules.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 96fa6c3a707e4..8f78d3a4e9c8a 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -34,7 +34,7 @@ function(_get_common_test_compile_options output_var c_test flags) # list(APPEND compile_options "-Wconversion") # list(APPEND compile_options "-Wno-sign-conversion") # list(APPEND compile_options "-Wimplicit-fallthrough") - # list(APPEND compile_options "-Wwrite-strings") + list(APPEND compile_options "-Wwrite-strings") list(APPEND compile_options "-Wextra-semi") # Silence this warning because _Complex is a part of C99. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") From 1c5c871c2a71ead4553f5c418856c51e168ca1c0 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Wed, 22 Jan 2025 18:44:56 -0500 Subject: [PATCH 2/7] -Wimplicit-fallthrough --- libc/cmake/modules/LLVMLibCTestRules.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 8f78d3a4e9c8a..29b9eddfe5244 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -33,7 +33,7 @@ function(_get_common_test_compile_options output_var c_test flags) endif() # list(APPEND compile_options "-Wconversion") # list(APPEND compile_options "-Wno-sign-conversion") - # list(APPEND compile_options "-Wimplicit-fallthrough") + list(APPEND compile_options "-Wimplicit-fallthrough") list(APPEND compile_options "-Wwrite-strings") list(APPEND compile_options "-Wextra-semi") # Silence this warning because _Complex is a part of C99. From 51b9c578afdf3956041665e3167aa291d7dc7214 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Wed, 22 Jan 2025 21:04:13 -0500 Subject: [PATCH 3/7] non GCC warnings --- libc/cmake/modules/LLVMLibCTestRules.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 29b9eddfe5244..e676130c6b9a8 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -46,13 +46,13 @@ function(_get_common_test_compile_options output_var c_test flags) list(APPEND compile_options "-Wno-gnu-imaginary-constant") endif() list(APPEND compile_options "-Wno-pedantic") - # if(NOT CMAKE_COMPILER_IS_GNUCXX) - # list(APPEND compile_options "-Wnewline-eof") - # list(APPEND compile_options "-Wnonportable-system-include-path") - # list(APPEND compile_options "-Wstrict-prototypes") - # list(APPEND compile_options "-Wthread-safety") - # list(APPEND compile_options "-Wglobal-constructors") - # endif() + if(NOT CMAKE_COMPILER_IS_GNUCXX) + list(APPEND compile_options "-Wnewline-eof") + list(APPEND compile_options "-Wnonportable-system-include-path") + list(APPEND compile_options "-Wstrict-prototypes") + list(APPEND compile_options "-Wthread-safety") + # list(APPEND compile_options "-Wglobal-constructors") + endif() endif() set(${output_var} ${compile_options} PARENT_SCOPE) endfunction() From be9ec1ac8875d5d4e32c5be5095a60da5fd02e12 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Fri, 24 Jan 2025 21:11:21 -0500 Subject: [PATCH 4/7] PR review comments --- libc/cmake/modules/LLVMLibCTestRules.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index e676130c6b9a8..ca7f02c0f10a2 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -34,6 +34,7 @@ function(_get_common_test_compile_options output_var c_test flags) # list(APPEND compile_options "-Wconversion") # list(APPEND compile_options "-Wno-sign-conversion") list(APPEND compile_options "-Wimplicit-fallthrough") + list(APPEND compile_options "-Wstrict-prototypes") list(APPEND compile_options "-Wwrite-strings") list(APPEND compile_options "-Wextra-semi") # Silence this warning because _Complex is a part of C99. @@ -46,10 +47,9 @@ function(_get_common_test_compile_options output_var c_test flags) list(APPEND compile_options "-Wno-gnu-imaginary-constant") endif() list(APPEND compile_options "-Wno-pedantic") - if(NOT CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") list(APPEND compile_options "-Wnewline-eof") list(APPEND compile_options "-Wnonportable-system-include-path") - list(APPEND compile_options "-Wstrict-prototypes") list(APPEND compile_options "-Wthread-safety") # list(APPEND compile_options "-Wglobal-constructors") endif() From 56c7755d0e1dc4c36f53e9177654b56ca06104ec Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:03:10 -0500 Subject: [PATCH 5/7] Move `-Wextra-semi` and `-Wstrict-prototypes` back to Clang only --- libc/cmake/modules/LLVMLibCTestRules.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 58d5000ff3b3f..d2f204ef5746d 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -1,11 +1,6 @@ function(_get_common_test_compile_options output_var c_test flags) _get_compile_options_from_flags(compile_flags ${flags}) - # Remove -fno-math-errno if it was added. - if(LIBC_ADD_FNO_MATH_ERRNO) - list(REMOVE_ITEM compile_options "-fno-math-errno") - endif() - set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${LIBC_TEST_COMPILE_OPTIONS_DEFAULT} @@ -39,9 +34,7 @@ function(_get_common_test_compile_options output_var c_test flags) # list(APPEND compile_options "-Wconversion") # list(APPEND compile_options "-Wno-sign-conversion") list(APPEND compile_options "-Wimplicit-fallthrough") - list(APPEND compile_options "-Wstrict-prototypes") list(APPEND compile_options "-Wwrite-strings") - list(APPEND compile_options "-Wextra-semi") # Silence this warning because _Complex is a part of C99. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(NOT c_test) @@ -53,6 +46,8 @@ function(_get_common_test_compile_options output_var c_test flags) endif() list(APPEND compile_options "-Wno-pedantic") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + list(APPEND compile_options "-Wstrict-prototypes") + list(APPEND compile_options "-Wextra-semi") list(APPEND compile_options "-Wnewline-eof") list(APPEND compile_options "-Wnonportable-system-include-path") list(APPEND compile_options "-Wthread-safety") From d8bf783df292e4e0f322d9fd3d46c05ef73fcf12 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Wed, 5 Feb 2025 18:19:26 -0500 Subject: [PATCH 6/7] Update LLVMLibCTestRules.cmake --- libc/cmake/modules/LLVMLibCTestRules.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index d2f204ef5746d..e66d1e49c297b 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -1,5 +1,9 @@ function(_get_common_test_compile_options output_var c_test flags) _get_compile_options_from_flags(compile_flags ${flags}) + # Remove -fno-math-errno if it was added. + if(LIBC_ADD_FNO_MATH_ERRNO) + list(REMOVE_ITEM compile_options "-fno-math-errno") + endif() set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} From 9c91ac9d38b6ec4a9699799d00355ca4318eb40f Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Wed, 5 Feb 2025 19:06:36 -0500 Subject: [PATCH 7/7] Fix NL --- libc/cmake/modules/LLVMLibCTestRules.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index e66d1e49c297b..5709a11b1a201 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -1,5 +1,6 @@ function(_get_common_test_compile_options output_var c_test flags) _get_compile_options_from_flags(compile_flags ${flags}) + # Remove -fno-math-errno if it was added. if(LIBC_ADD_FNO_MATH_ERRNO) list(REMOVE_ITEM compile_options "-fno-math-errno")