[lld] Fix warning in lld/Macho while building lld for wasm (PR #120889)

via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 22 03:40:01 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld

Author: Anutosh Bhat (anutosh491)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/120889.diff


1 Files Affected:

- (modified) lld/MachO/SyntheticSections.cpp (+1-1) 


``````````diff
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");
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/120889


More information about the llvm-commits mailing list