'macos llvm-symbolizer not found

I am trying to use address sanitization when calling my program with clang, however it doesn't seem to be installed. If I type which llvm-symbolizer I get llvm-symbolizer not found. I also checked under /usr/bin and /usr/local/bin and under the location where clang is installed /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin but still I can't find llvm-symbolizer (though there are other llvm-* executables in the last path).

Is there a way I can install this on macos? Also, I couldn't find it in brew. I am using clang built in macos: Apple clang version 12.0.0 (clang-1200.0.32.21).



Solution 1:[1]

My version of llvm-symbolizer was installed with Homebrew. You have to install llvm with brew install llvm to get it. It then shows up as:

% which llvm-symbolizer
/usr/local/Cellar/llvm/11.0.0/bin/llvm-symbolizer

Solution 2:[2]

By the way, some people may have installed llvm but not linked some binaries to path. The sure-fire way to add all llvm binaries to path is:

PATH="$PATH:$(brew --prefix)/opt/llvm/bin"

$(brew --prefix)/opt/llvm is a symbolic link to the most recent installed version of llvm, and bin is obviously the binaries therein.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Hunter Kohler