Skip to content

Commit ba93ecc

Browse files
authored
[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
1 parent 3321c2d commit ba93ecc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lld/MachO/SyntheticSections.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,12 +2079,12 @@ void ObjCMethListSection::finalize() {
20792079
void ObjCMethListSection::writeTo(uint8_t *bufStart) const {
20802080
uint8_t *buf = bufStart;
20812081
for (const ConcatInputSection *isec : inputs) {
2082-
assert(buf - bufStart == long(isec->outSecOff) &&
2082+
assert(buf - bufStart == std::ptrdiff_t(isec->outSecOff) &&
20832083
"Writing at unexpected offset");
20842084
uint32_t writtenSize = writeRelativeMethodList(isec, buf);
20852085
buf += writtenSize;
20862086
}
2087-
assert(buf - bufStart == sectionSize &&
2087+
assert(buf - bufStart == std::ptrdiff_t(sectionSize) &&
20882088
"Written size does not match expected section size");
20892089
}
20902090

0 commit comments

Comments
 (0)