[libc-commits] [libc] Reapply "[libc] build with -Werror (#73966)" (PR #74506)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Jan 8 08:52:31 PST 2024


https://github.com/nickdesaulniers updated https://github.com/llvm/llvm-project/pull/74506

>From fa4b0d12919c7be1db525a2102a2e62b18b3f399 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 5 Dec 2023 10:09:32 -0800
Subject: [PATCH] Reapply "[libc] build with -Werror (#73966)"

This reverts commit 6886a52d6dbefff77f33de12ff85d654e2557f81.

Most of the errors observed in postsubmit have been addressed. We can
fix-forward the remaining ones.

Link: https://lab.llvm.org/buildbot/#/changes/117129
---
 libc/cmake/modules/LLVMLibCObjectRules.cmake | 4 ++++
 libc/docs/dev/code_style.rst                 | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index c3e3fa2dccfe53..6eba17ae9201c8 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -43,6 +43,10 @@ function(_get_common_compile_options output_var flags)
     list(APPEND compile_options "-fno-rtti")
     list(APPEND compile_options "-Wall")
     list(APPEND compile_options "-Wextra")
+    # -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
+    if(NOT LIBC_WNO_ERROR)
+      list(APPEND compile_options "-Werror")
+    endif()
     list(APPEND compile_options "-Wconversion")
     list(APPEND compile_options "-Wno-sign-conversion")
     list(APPEND compile_options "-Wimplicit-fallthrough")
diff --git a/libc/docs/dev/code_style.rst b/libc/docs/dev/code_style.rst
index a050a4c1d3dd7d..eeeced0359adbc 100644
--- a/libc/docs/dev/code_style.rst
+++ b/libc/docs/dev/code_style.rst
@@ -178,3 +178,11 @@ these functions do not call the constructors and destructors of the
 allocated/deallocated objects. So, use these functions carefully and only
 when it is absolutely clear that constructor and destructor invocation is
 not required.
+
+Warnings in sources
+===================
+
+We expect contributions to be free of warnings from the `minimum supported
+compiler versions`__ (and newer).
+
+.. __: https://libc.llvm.org/compiler_support.html#minimum-supported-versions



More information about the libc-commits mailing list