I have installed LLVM via brew on macOS with the below mentioned command:
brew install --with-toolchain llvm#3.9
I would like to use clang-tidy but some checks are missing, for example misc-string-compare.
What could be the problem?
As far as I can see, misc-string-compare was introduced in LLVM 4.0
Related
I've installed gcc-4.6 using the homebrew-alternatives gcc formula, but I can't seem to get it to use that GCC to install other formulas. Specifically Open-MPI and boost.
Does anyone know how to make Homebrew use this new compiler?
Thanks!
It looks like the latest versions of Homebrew now support the HOMEBREW_CC and HOMEBREW_CXX environment variables.
So now you can do the following:
$ HOMEBREW_CC=gcc-4.2 HOMEBREW_CXX=g++-4.2 brew install ice
Homebrew can't adapt to other versions of gcc using command line options. You can easily override the older compiler, though, if you edit the open-mpi and boost formula. For example, you can add a few commands after the "def install" in open-mpi.rb:
def install
# Force compilation with gcc-4.6
ENV['CC'] = '/usr/local/bin/gcc-4.6'
ENV['LD'] = '/usr/local/bin/gcc-4.6'
ENV['CXX'] = '/usr/local/bin/g++-4.6'
# Compiler complains about link compatibility with FORTRAN otherwise
ENV.delete('CFLAGS')
ENV.delete('CXXFLAGS')
That worked for me on Lion. Good luck.
These answers are all fairly old now. It seems that recent versions of homebrew have a '--cc' option that enables you to select the c compiler to use. For example
brew install --cc=gcc-6 <package-name>
will install using the brew version of gcc
From their wiki it sounds like they don't support other compilers:
Installing a custom version of GCC or autotools into the $PATH has the potential to break lots of compiles. So we stick to the Apple-provided compilers.
I'd like to install gcc version 9.3.0 on my Mac Os Big Sur. I was wondering if I can do this still using brew?
I already have the most up to date version of brew but I would like to possibly downgrade or have in addition gcc v9.3.0.
I followed the three commands below
brew tap-new $USER/local-gcc
brew extract --version=9.3.0 gcc $USER/local-gcc
brew install gcc#9.3.0
but when I do
brew info gcc
it still says I have v10.2.0. Is there a way to switch between different versions? As far as I can tell brew switch is now broken.
If there is another way to get a working gcc v 9.3.0 that you can recommend I am happy to try it too. Thanks in advance.
EDIT:
I have the most up to date version of gcc on my Mac OS Big Sur machine via brew install gcc but now I would like to have gcc#9 in addition or in place of it. I have gcc#9in /usr/local/Cellar/gcc#9/9.3.0_1 but I can't find a way for my system to use this rather than gcc10. When I do brew ls --versions gcc, it still returns gcc 10.2.0_4.
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:
Did I miss something in the brew installation?
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?
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
I've installed clang-3.4.2-7.el7.x86_64.rpm on RHEL 7 and it came with llvm, but i couldn't find the scan-build utility.
I have already installed gcc and cmake and all other tools that are mentioned here But unfortunately i can't execute the scan-build commands.
BTW, I want to integrate it with Clang Scan-Build Plugin.
Am I missing something in the configuration?
It's in the package clang-analyzer
Clang analyzer doesn't get installed by default, to install it with the current version of LLVM 6.0 run:
yum install llvm-toolset-6.0-clang-analyzer
You may also want to install llvm-toolset-6.0-clang-tools-extra.
How to install Clang/LLVM 6 on RHEL has this and other details.
I'd like to build the latest version of gcc on a mac. I have the latest xcode but I'm looking for some of the c++0x features that are in more recent versions (the lambda functions, etc).
Are there any good step-by-step tutorials on doing this?
You should look at the Homebrew project.
Homebrew allows you to do things like this:
brew install gcc
Mac homebrew installation instructions are available here.
Add GCC support to a fresh Xcode 4.2 installation using this homebrew formula:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
Upgrading from Xcode 4.1 doesn't drop existing GCC support, so this formula is only useful if you're working with a fresh 4.2+ installation.
One option is to install MacPorts and install the gcc46 package:
sudo port install gcc46
Another option is to download the source code and build it as follows:
tar xzvf gcc-4.6.0.tar.gz
cd gcc-4.6.0
./configure
make
Note that GCC 4.6.0 requires as prerequisites GMP 4.2+, MPFR 2.3.1+, and MPC 0.8.0+. If ./configure fails, it's probably because you're missing one of these (though it should give you a helpful error message in any case).
Building will take a while—likely several hours, depending on your hardware.
I would suggest building it yourself (Adam details how to do so). This will give you fine control on where to install and all the options you want to select. My experience from having multiple versions of gcc is that, if care is not taken apple's version of gcc can be damaged.
To speed up gcc installation you might want to look at --enable-languages option. If there are languages you don't need installed with the new gcc then you may not want to select them.