[lld] 3594769 - [ELF] Define NOMINMAX to fix zlib.h caused build failure on Windows (#70368)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 2 05:59:58 PDT 2023
Author: Yaxun (Sam) Liu
Date: 2023-11-02T08:59:54-04:00
New Revision: 3594769f202ee47c18718215a6f210ad757c9822
URL: https://github.com/llvm/llvm-project/commit/3594769f202ee47c18718215a6f210ad757c9822
DIFF: https://github.com/llvm/llvm-project/commit/3594769f202ee47c18718215a6f210ad757c9822.diff
LOG: [ELF] Define NOMINMAX to fix zlib.h caused build failure on Windows (#70368)
On Windows when zlib is enabled, zlib header introduced some Windows
headers which defines max as a macro. Since OutputSections.cpp uses
std::max with template argument, this causes compilation error.
Define macro NOMINMAX to avoid this.
Added:
Modified:
lld/ELF/OutputSections.cpp
Removed:
################################################################################
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 2dc425927109403..ee937418678707c 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -22,6 +22,8 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/TimeProfiler.h"
#if LLVM_ENABLE_ZLIB
+// Avoid introducing max as a macro from Windows headers.
+#define NOMINMAX
#include <zlib.h>
#endif
#if LLVM_ENABLE_ZSTD
More information about the llvm-commits
mailing list