[compiler-rt] [compiler-rt][rtsan] intercept setbuf, setvbuf, setlinebuf and setbuffer (PR #121616)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 4 03:24:04 PST 2025
Zentrik wrote:
I get the following error when cross compiling for aarch64 mac os
```
[11:06:34] ninja: job failed: /opt/bin/aarch64-apple-darwin20-libgfortran5-cxx11/aarch64-apple-darwin20-clang++ --target=arm64-apple-darwin20 --sysroot=/opt/aarch64-apple-darwin20/aarch64-apple-darwin20/sys-root -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/workspace/build/projects/compiler-rt/lib/rtsan -I/workspace/srcdir/llvm-project/compiler-rt/lib/rtsan -I/workspace/build/include -I/workspace/srcdir/llvm-project/llvm/include -I/workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/.. -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wall -Wno-unused-parameter -O3 -DNDEBUG -arch arm64 -stdlib=libc++ -mmacosx-version-min=11.0 -isysroot /opt/aarch64-apple-darwin20/aarch64-apple-darwin20/sys-root -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -ftrivial-auto-var-init=pattern -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -std=c++17 -MD -MT projects/compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_interceptors_posix.cpp.o -MF projects/compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_interceptors_posix.cpp.o.d -o projects/compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_interceptors_posix.cpp.o -c /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp:334:19: error: conflicting types for 'setbuffer'
[11:06:34] INTERCEPTOR(void, setbuffer, FILE *stream, char *buf, size_t size) {
[11:06:34] ^
[11:06:34] /opt/aarch64-apple-darwin20/aarch64-apple-darwin20/sys-root/usr/include/stdio.h:375:7: note: previous declaration is here
[11:06:34] void setbuffer(FILE *, char *, int);
[11:06:34] ^
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp:339:19: error: functions that differ only in their return type cannot be overloaded
[11:06:34] INTERCEPTOR(void, setlinebuf, FILE *stream) {
[11:06:34] ~~~~ ^
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/../interception/interception.h:332:53: note: expanded from macro 'INTERCEPTOR'
[11:06:34] INTERCEPTOR_ZZZ(/*no symbol variants*/, ret_type, func, __VA_ARGS__)
[11:06:34] ~~~~~~~~ ^
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/../interception/interception.h:326:23: note: expanded from macro 'INTERCEPTOR_ZZZ'
[11:06:34] extern "C" ret_type func(__VA_ARGS__) suffix; \
[11:06:34] ~~~~~~~~ ^
[11:06:34] /opt/aarch64-apple-darwin20/aarch64-apple-darwin20/sys-root/usr/include/stdio.h:376:6: note: previous declaration is here
[11:06:34] int setlinebuf(FILE *);
[11:06:34] ~~~ ^
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp:341:15: error: call to 'setlinebuf' is ambiguous
[11:06:34] return REAL(setlinebuf)(stream);
[11:06:34] ^~~~~~~~~~
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/../interception/interception.h:266:18: note: expanded from macro 'REAL'
[11:06:34] # define REAL(x) x
[11:06:34] ^
[11:06:34] /opt/aarch64-apple-darwin20/aarch64-apple-darwin20/sys-root/usr/include/stdio.h:376:6: note: candidate function
[11:06:34] int setlinebuf(FILE *);
[11:06:34] ^
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp:339:19: note: candidate function
[11:06:34] INTERCEPTOR(void, setlinebuf, FILE *stream) {
[11:06:34] ^
[11:06:34] /workspace/srcdir/llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp:341:3: error: void function 'wrap_setlinebuf' should not return a value [-Wreturn-type]
[11:06:34] return REAL(setlinebuf)(stream);
[11:06:34] ^ ~~~~~~~~~~~~~~~~~~~~~~~~
[11:06:34] 4 errors generated.
```
It looks like these functions have different declarations on darwin, e.g. https://github.com/alexey-lysiuk/macos-sdk/blob/0efb06490f664d335a4fdff9198df7d03e87deda/MacOSX15.2.sdk/usr/include/_stdio.h#L472-L473?
Looks like openbsd has a similar problem, https://github.com/openbsd/src/blob/54e45245a3816722a38ebb90c176c2eef1f561c2/include/stdio.h#L364-L365?
https://github.com/llvm/llvm-project/pull/121616
More information about the llvm-commits
mailing list