macos: workaround AppleClang compiler strrchr optimization bug
Apple shipped a clang built for macOS with an optimization enabled that is not available on macOS. This compiler error may then be faced:
ld: Undefined symbols:
_memrchr, referenced from:
name_read(char const*) in map.cpp.o
This is a compiler error:
On Mac OSX (macOS version 12.4, sdk version 12.1) llvm can replace call to
strrchr()
with call tomemrchr()
when string length is known at compile time. This results in link error, becausememrchr
is not present inlibSystem
.
-- https://github.com/llvm/llvm-project/issues/62254
We workaround this by making the string length not known at build time on macOS to avoid triggering the unavailable compiler optimization.