[PATCH] D134134: Mark memrchr as unavailable on Windows
Mateusz MikuĊa via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 18 05:52:30 PDT 2022
mati865 created this revision.
mati865 added a reviewer: LLVM.
mati865 added a project: LLVM.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mati865 requested review of this revision.
Herald added a subscriber: llvm-commits.
Otherwise LLVM will optimise strrchr into memrchr on Windows resulting in linker error:
$ cat memrchr_test.c
#include <string.h>
int main(int argc, char **argv) {
return (long)strrchr("KkMm", argv[argc-1][0]);
}
$ clang memrchr_test.c -O
memrchr_test.c:3:12: warning: cast to smaller integer type 'long' from 'char *' [-Wpointer-to-int-cast]
return (long)strrchr("KkMm", argv[argc-1][0]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
ld.lld: error: undefined symbol: memrchr
>>> referenced by D:/msys64/tmp/memrchr_test-e7aabd.o:(main)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Example taken from MSYS2 Discord and tested with windows-gnu target.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134134
Files:
llvm/lib/Analysis/TargetLibraryInfo.cpp
Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -439,6 +439,7 @@
TLI.setUnavailable(LibFunc_htons);
TLI.setUnavailable(LibFunc_lchown);
TLI.setUnavailable(LibFunc_lstat);
+ TLI.setUnavailable(LibFunc_memrchr);
TLI.setUnavailable(LibFunc_ntohl);
TLI.setUnavailable(LibFunc_ntohs);
TLI.setUnavailable(LibFunc_pread);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134134.461068.patch
Type: text/x-patch
Size: 506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220918/8adbb0ce/attachment.bin>
More information about the llvm-commits
mailing list