Search code examples
c++macosclanghomebrewmacos-mojave

How to update clang without upgrading to Catalina


I've just got a MacOS 2 days ago with Mojave 10.14.5 and I was trying to install the latest Clang 12.0.0 but to no avail. I can't upgrade the OS to Catalina, so when I tried the XCode route I could only get the 13.1 version, with LLVM 10.0.1 and Clang-1001.0.46.4.

Then I followed this guide :

https://embeddedartistry.com/blog/2017/02/24/installing-llvm-clang-on-osx/

which was supposed to help me upgrade the llvm and clang through brew, and I successfully did it.

I got it up to LLVM 11.0.0 (I checked it out through "brew info llvm"), nonetheless when I use the command "clang --version", it still gives me:

Apple LLVM version 10.0.1 (clang- 
1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix 
InstalledDir:/Library/Developer/CommandLineTools/u 
sr/bin

So I have 2 questions:

  1. Did I miss something in the brew installation?
  2. Is there another way to update to clang without the OS upgrade?

P.s

In the guide I couldn't do from the "Where to find llvm/clang" and downwards, since many of those commands weren't recognized by the terminal

Repost?


Solution

  • homebrew installs binaries into /usr/local/bin, so you normally need to put that at the start of your PATH:

    export PATH=/usr/local/bin:$PATH
    

    You can check which clang will be run when you type clang in your Terminal by running:

    type clang
    

    If that tells you clang is /usr/bin/clang or /Applications/anything or /Library/anything, that means it is supplied by Apple.

    If it contains /usr/local/anything or /opt/anything, it is probably supplied by homebrew.


    For hombrew problems, try asking the good doctor:

    brew doctor