Skip to content

Commit 67108b2

Browse files
committed
Build libsanitizer_common_rt with -Wno-format
Many lines that call `InternalScopedString::AppendF`, including the below, https://github.com/llvm/llvm-project/blob/26a1d6601d727a96f4301d0d8647b5a42760ae0c/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp#L31 are format-checked by https://github.com/llvm/llvm-project/blob/26a1d6601d727a96f4301d0d8647b5a42760ae0c/compiler-rt/lib/sanitizer_common/sanitizer_common.h#L650 which checks if the formats of arguments conform to that of functions like `printf`. But this errors out because the format strings currently do not match their arguments. llvm/llvm-project@9c8f888#diff-5bf0494d1b61b99e55aefb25e59e41b678f20a392c2c6d77e5fbdc97c2ca4c3f started the effort to check `__attribute__((format))` in the codebase, but apparently there were too many violating instances, it made the code build with `-Wno-format` (presumably as an temporary solution): https://github.com/llvm/llvm-project/blob/26a1d6601d727a96f4301d0d8647b5a42760ae0c/compiler-rt/lib/sanitizer_common/CMakeLists.txt#L223-L224 So this adds `-Wno-format` to our cflags as well. The reason it was fine without it until now is, we didn't build the whole file thanks to this line: https://github.com/emscripten-core/emscripten/blob/a9b347bfcabda59a5edff60ee18b8a0ab70aa9dc/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp#L15 But recent refactoring efforts including llvm/llvm-project#73032, llvm/llvm-project#73192, and llvm/llvm-project#73193 moved many parts out of that file to be built by a specific platform (e.g. fushia) and made the file build unconditionally. I tried to add back `#if SANITIZER_SYMBOLIZER_MARKUP` to that file but then this line (https://github.com/llvm/llvm-project/blob/26a1d6601d727a96f4301d0d8647b5a42760ae0c/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp#L67) breaks with an undefined referenc error. So just build the library with `-Wno-format`, which is also what the upstream is effectively doing, seems a simpler solution.
1 parent 9272ada commit 67108b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/system_libs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ class libsanitizer_common_rt(CompilerRTLibrary, MTLibrary):
20522052
'system/lib/compiler-rt/lib',
20532053
'system/lib/libc']
20542054
never_force = True
2055-
cflags = ['-D_LARGEFILE64_SOURCE']
2055+
cflags = ['-D_LARGEFILE64_SOURCE', '-Wno-format']
20562056

20572057
src_dir = 'system/lib/compiler-rt/lib/sanitizer_common'
20582058
src_glob = '*.cpp'

0 commit comments

Comments
 (0)