[lld] ba93ecc - [lld][MachO] Fix warning while building for wasm (#120889)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 01:49:54 PST 2025


Author: Anutosh Bhat
Date: 2025-01-05T17:49:50+08:00
New Revision: ba93eccded30862969a3c5f547d837d6d102c863

URL: https://github.com/llvm/llvm-project/commit/ba93eccded30862969a3c5f547d837d6d102c863
DIFF: https://github.com/llvm/llvm-project/commit/ba93eccded30862969a3c5f547d837d6d102c863.diff

LOG: [lld][MachO] Fix warning while building for wasm (#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` should be enough I think

Added: 
    

Modified: 
    lld/MachO/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 28fb8047cacd9a..417b7cf93efa7d 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -2079,12 +2079,12 @@ void ObjCMethListSection::finalize() {
 void ObjCMethListSection::writeTo(uint8_t *bufStart) const {
   uint8_t *buf = bufStart;
   for (const ConcatInputSection *isec : inputs) {
-    assert(buf - bufStart == long(isec->outSecOff) &&
+    assert(buf - bufStart == std::ptr
diff _t(isec->outSecOff) &&
            "Writing at unexpected offset");
     uint32_t writtenSize = writeRelativeMethodList(isec, buf);
     buf += writtenSize;
   }
-  assert(buf - bufStart == sectionSize &&
+  assert(buf - bufStart == std::ptr
diff _t(sectionSize) &&
          "Written size does not match expected section size");
 }
 


        


More information about the llvm-commits mailing list