[lld] Fix warning in lld/Macho while building lld for wasm (PR #120889)
Anutosh Bhat via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 22 03:39:28 PST 2024
https://github.com/anutosh491 created https://github.com/llvm/llvm-project/pull/120889
While building clang & lld against emscripten for wasm, I see the following
```
│ │ /home/runner/work/recipes/recipes/output/bld/rattler-build_llvm_1734801187/work/lld/MachO/SyntheticSections.cpp:2075:25: warning: comparison of integers of
│ │ different signs: 'long' and 'const uint32_t' (aka 'const unsigned int') [-Wsign-compare]
│ │ 2075 | assert(buf - bufStart == sectionSize &&
│ │ | ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
│ │ $BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot/include/assert.h:8:28: note: expanded from macro 'assert'
│ │ 8 | #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
│ │ | ^
```
Casting `sectionSize` using `long` should be enough I think
>From b616a99b2452a21aa541226230f823b176a9ead6 Mon Sep 17 00:00:00 2001
From: anutosh491 <andersonbhat491 at gmail.com>
Date: Sun, 22 Dec 2024 17:08:02 +0530
Subject: [PATCH] Fix warning in lld/Macho while building lld for wasm
---
lld/MachO/SyntheticSections.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 28fb8047cacd9a..0806448f921aad 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -2084,7 +2084,7 @@ void ObjCMethListSection::writeTo(uint8_t *bufStart) const {
uint32_t writtenSize = writeRelativeMethodList(isec, buf);
buf += writtenSize;
}
- assert(buf - bufStart == sectionSize &&
+ assert(buf - bufStart == long(sectionSize) &&
"Written size does not match expected section size");
}
More information about the llvm-commits
mailing list