No llvm opt command in Mavericks - macos

I installed Xcode 5.0.1 on Macosx 10.9 Mavericks and the command line tools (I can use gcc/clang on the command line for instance) but the command opt seems to have disappeared.
Was it replaced by something else ?

Apple never shipped 'base' LLVM tools with its within XCode command line tools, only clang. You need to compile the desired revision / release of LLVM by yourself. You can download the pre-built binaries at http://llvm.org/releases/download.html as well.

My strategy (on Mavericks) was to do brew install llvm then symlink:
sudo ln -s /usr/local/Cellar/llvm/3.4/bin/opt /usr/bin/opt
sudo ln -s /usr/local/Cellar/llvm/3.4/bin/llc /usr/bin/llc

I got this to work on High Sierra by installing it via Homebrew.
brew install llvm
Once you're done with that, Homebrew will tell you something like this:
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/llvm/lib
CPPFLAGS: -I/usr/local/opt/llvm/include
If you need Python to find bindings for this keg-only formula, run:
echo /usr/local/opt/llvm/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/llvm.pth
Go ahead and run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
to stick that into your .bashrc / .bash_profile.

I'll add a solution for El Capitan and Sierra since now it shows the error
ln: /usr/bin/opt: Operation not permitted
It's really simple, just go to ~/.bash_source (or the rc file of whatever shell you have) and write alias opt='/usr/local/Cellar/llvm/<llvm_version>/bin/opt'

Related

Installing and running emscripten on OSX 10.15

I recently installed emscripten on my macbook air using homebrew.
But when I try to run it, even if i do a simple emcc --version i get the error llc executable not found at /usr/bin/llc. how can i fix this?
solution: llvm was not installed, so a brew install llvm followed by echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc solved this problem for me.
Hrm. Seems like adding brew install llvm, I'm still not able to call llvm on my end.
So i just installed brew install emscripten
then I did emcc giving me
Welcome to Emscripten!
This is the first time any of the Emscripten tools has been run.
A settings file has been copied to /usr/local/Cellar/emscripten/1.39.18/libexec/.emscripten, at absolute path: /usr/local/Cellar/emscripten/1.39.18/libexec/.emscripten
It contains our best guesses for the important paths, which are:
LLVM_ROOT = /usr/bin
NODE_JS = /usr/local/bin/node
EMSCRIPTEN_ROOT = /usr/local/Cellar/emscripten/1.39.18/libexec
Please edit the file if any of those are incorrect.
This command will now exit. When you are done editing those paths, re-run it.
Then i did emcc again, giving me BINARYEN_ROOT is set to empty value in /usr/local/Cellar/emscripten/1.39.18/libexec/.emscripten.
How did you set your BINARYEN_ROOT? i'm on the newest macos 10.15.5.

Installing GCC on macOS Catalina

I am on macOS Catalina and trying to install GCC by following the instructions here:
https://solarianprogrammer.com/2019/10/12/compiling-gcc-macos/
Everything seems to work fine until I try to configure. Then I get the following:
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
While trying to fix this I found the following:
MacOS "configure: error: cannot run C compiled programs"
However this answer requires going to the following directory:
/Library/Developer/CommandLineTools
The problem is I do not have CommandLineTools in /Library/Developer/ not even as a hidden file. Trying to fix this I found this
How to compile GCC on macOS Catalina?
but there is now answer here and I do not have nix and don't want to mess with it as it appears to not be very compatible with macOS Catalina. So the question is how can I run the configure?
Install GCC on MacOS
learn from above vedio,i use macOX 11.1, install gcc and g++ step:
"brew install gcc", after that, check install success by: "brew info gcc".
"cd /usr/local/bin"
"ls | grep 'gcc'" should see the gcc version you install before, like: gcc-10 or g++-10.
"ln -s gcc-10 gcc" make a symlink from your gcc version to gcc.
close terminal, and open again, input "gcc -v", should see it use gcc now.
If still use clang:
make sure you logout and login again.
use "where gcc" or "which gcc" to check your gcc symlink create success.
"echo $PATH", make sure "/usr/local/bin" show before "/usr/bin" on your PATH, if not, change it on your ~/.zshrc or ~/.bashrc
First you need to install the Command-Line tools.
$ xcode-select --install
Then you probably want to install the headers from a specific .pkg in Terminal:
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
(yours is 10.15, so):
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.15.pkg
After finishing the installation you should have the headers you need to compile with your GCC.
Probably not the elegant answer, but it worked. I was able to find the header files needed using $(xcrun --show-sdk-path) I then copied them all to /usr/local where the gcc location was expecting them to be. Now all works.

Yosemite and Valgrind

Can you tell me how to install valgrind on yosemite? When I try to install it i get " checking for the kernel version... unsupported (14.0.0)
configure: error: Valgrind works on Darwin 10.x, 11.x, 12.x and 13.x (Mac OS X 10.6/7/8/9) "
There is no official path or update, and I didn't found anything (except http://comments.gmane.org/gmane.comp.kde.devel.bugs/1553705 , but they didn't resolve that problem).
As there's no stable release that supports Yosemite, you can install the latest development version with
brew install --HEAD valgrind
Whilst it may have been the case in past OS X release cycles that Valgrind took a period of time before achieving reasonable feature support, basic OS X 10.10 support is already available in Valgrind trunk due to significant work on pre-release Yosemite.
From the mailing list:
There has been some effort recently to improve Valgrind's support for
Yosemite. If you develop on Mac OS, you might like to try out the
trunk (svn co svn://svn.valgrind.org/valgrind/trunk) and report any
breakage you get. Support for Yosemite is good enough that at least
one large graphical application (Firefox) runs OK. Support for the
previous release, 10.9 (Mavericks), is also substantially improved.
Note that the work has targetted 64 bit processes only. 32 bit might
work, and probably better on Mavericks, but I suspect it will be
increasingly problematic on Yosemite due to Valgrind's 32 bit x86
instruction set support not having progressed passed SSSE3.
Julian Seward
http://sourceforge.net/p/valgrind/mailman/message/33047840/
Full disclosure: I'm one of the new Valgrind developers who contributed patches to support OS X 10.10
Valerio's svn workflow will download every branch which is time and resource consuming. A better procedure is to download just the trunk:
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
cd valgrind
./autogen.sh
./configure
make
make install
Here is my take on it. I more or less had a clean mac with xcode installed.
Got it compiling and running with the following:
# build/install autoconf/automake/libtool so that 'autogen' works
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
tar -xzf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure && make && sudo make install
cd ..
curl -OL http://ftpmirror.gnu.org/automake/automake-1.14.tar.gz
tar -xzf automake-1.14.tar.gz
cd automake-1.14
./configure && make && sudo make install
cd..
curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
tar -xzf libtool-2.4.2.tar.gz
cd libtool-2.4.2
./configure && make && sudo make install
cd ..
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
cd valgrind
./autogen.sh
# important: configure-params, otherwise make ends in errors
./configure -disable-tls --enable-only64bit --build=amd64-darwin
make
# sudo, otherwise it fails due to permissions
sudo make install
Note that callgrind_control (from valgrind-3.11.0 SVN) doesn't appear to work on OS X, looks like a perl-script and the commandline tool which it runs (vgdb -l) prints something 'unexpected' which that script doesn't correctly parse ( so it won't be able to find the other process running with valgrind ).
Alternatively, the perl script just calls vgdb, we can also directly do that ( just figure out your process-id manually):
vgdb --pid=2858 instrumentation on
Worked for me on 10.10.1 :
svn co svn://svn.valgrind.org/valgrind
cd valgrind
./autogen.sh
./configure
make
make install
All of the solutions listed here failed for me. What finally ended up working was to use mac ports.
sudo port install valgrind-devel
Here's how to install it using alternative sources besides the official svn (because it seems to be intermittently available).
https://crispyappstudiosblog.wordpress.com/2015/07/07/installing-valgrind-on-osx-yosemite/
1) Navigate to this git mirror of the svn and download the latest
available version: http://repo.or.cz/w/valgrind.git
2) You need VEX as well, so grab the latest version here:
http://repo.or.cz/w/vex.git
3) Extract both of them. Put the entire contents of the VEX folder
into a folder called VEX in the top level of the valgrind directory.
cd to the valgrind directory, and execute the following:
Run ./autogen.sh
Run ./configure
Run make
Run sudo make install
Test it out by running valgrind --version You should be running at
least 3.11.0 SVN for it work on Yosemite.
I installed it on my mac by installing homebrew and then running this 3 commands in the terminal.
brew update
brew doctor
brew install --HEAD valgrind
PS: I have Os X El Capitan (10.11) but this should work with previous versions too.
I finally got Valgrind to work on my OSX El Capitan 10.11.12.
User Kalmiya's answer worked for me first after I installed Xcode commandline tools.
Type this in the terminal:
xcode-select --install
Now follow Kalmiya's post, step by step.
https://stackoverflow.com/a/30366798/3633475
Here is another take on the svn install. The previous ones did not work for me, since I needed to have automake and autoconf installed, which I did not, even though I had the latest version of the Xcode command line tools installed.
I got the following from this site. I also had to link automake and autoconf after doing brew install automake and brew install autoconf by doing brew link automake and brew link autoconf for this to work.
# Check out their repo...
$ svn co svn://svn.valgrind.org/valgrind/trunk valgrind-trunk
# and hop into it.
$ cd valgrind-trunk
# You need to have autoconf and automake installed to build Valgrind
# This example uses Homebrew to install these dependencies
# (MacPorts should also work)
# (Permission error? add sudo!)
$ brew install automake
$ brew install autoconf
# run autogen.sh in valgrind-trunk
$ ./autogen.sh
# Tricky, there are some hard wired paths in the Valgrind sources.
# You need to symlink the mach folder in your XCode SDK to /usr/include/mach
# Be sure to use the proper Xcode SDK "MacOSX10.10.sdk" in the path!
$ ln -sv /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/mach /usr/include/mach
# Run configure + set install paths in valgrind-trunk
$ ./configure --prefix=/usr/local
# Run Make and make install (permission error? add sudo!) in valgrind-trunk
$ make
$ make install
# Check it works
$ valgrind --version
valgrind-3.11.0.SVN
I have used kalmiya's instructions to build valgrind as a conda package for OSX Yosemite. For those who work with anaconda/conda, just do
conda install -c https://conda.binstar.org/groakat valgrind
Side-note:
I needed to install the command line tools as described below to get valgrind compiled.
https://stackoverflow.com/a/30471647/2156909
I got valgrind on Yosemite compiled, but had to use a hack to do so. While I think you should be using xcode-select install to get all command line tools (after which valgrind should make properly), but if you don't want to do this (eg. size of Xcode tools too big), you can also get the Darwin OSX code and copy the following files to /usr/include/mach
mach_vm.defs
task.defs
thread_act.defs
vm_map.defs
This allowed a clean compile and install, although note it is a rather slack hack.

how to install libX11 on OSx 10.9?

I am trying to install ROOT (cern.root.ch). When I run ./configure , I get a message that libX11 is missing and must be installed.
I did some research and found that I need to install
) XQuartz (I already have the latest version.)
) Command line tools in Xcode.
I tried installing Command Line Tools from apple's developer website. The installation goes through smoothly but how do I know whether it has been installed? I still get libX11 missing error with root's configure command.
I also tried xcode-select --install and it once went through smoothly and then later again gives error saying this package is no longer maintained - or something of that sort.
I understand I may have multiple installations... But I am still facing the problem of not having libX11 and not being able to install ROOT.
Thanks,
Hershal.
This link and the one referenced in it suggests you use homebrew (brew) to install it
$ ruby <(curl -fsS https://raw.github.com/mxcl/homebrew/go)
$ brew doctor
Remember to add the Homebrew directory to your PATH by adding the directory (found with brew --prefix) to your .bashrc, .zshrc or whatever shell file you’re using (.bashrc is the OS X default). We’ll also add the XQuartz binaries to the PATH in case anything needs them in the future.
export PATH=/usr/local/bin:/opt/X11/bin:$PATH
Start a new Terminal session to pick up the changes.
Now that Homebrew is installed, we can use it to install the required dependencies. Each may take some time as Homebrew generally compiles from source.
$ brew install gfortran # Fortran compiler
$ brew install python # Python interpreter
$ brew install pcre # Regular Expressions library
$ brew install fftw # Fast Fourier Transforms
$ brew install cmake # Cross-platform make
install root
$ brew tap homebrew/science
$ brew install --with-cocoa root
You don't say whether you have installed XCode as well as the commandline tools but I think you will need it

<omp.h> library isn't found in the GCC version (4.2.1) in Mavericks

I have a problem with GCC. I want to update it to a new version, from the 4.2.1, to program with parallel programming. However, in this version there is no library . How can I download an updated version?
The error that the terminal give me is:
omp_hello.c:11:10: fatal error: 'omp.h' file not found
#include <omp.h>
^
1 error generated.
download gcc-4.9-bin.tar.gz download or newer from
http://hpc.sourceforge.net/:
http://prdownloads.sourceforge.net/hpc/gcc-4.9-bin.tar.gz
cd to your downloads folder and un-gzip
the archive gunzip gcc-4.9-bin.tar.gz (Google Chrome would do that
automatically)
in the same folder run sudo tar -xvf gcc-4.9-bin.tar -C / - this will place new executable to /usr/local/bin
add the following to ~/.bash_profile: export PATH=/usr/local/bin:$PATH
open new terminal and run which gcc. This should point to /usr/local/bin/gcc
I got this message when I tried to reinstall GCC via Homebrew.
GCC has been built with multilib support. Notably, OpenMP may not work:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670
If you need OpenMP support you may want to
brew reinstall gcc --without-multilib
So, if you have Homebrew installed, you could try (on the terminal):
brew reinstall gcc --without-multilib
This process may take a while !
According to this thread on apple's forums, try using gcc-4.9-bin.tar .
First install the gcc-4.9 and type "xcode-select --install" on your terminal.
Then, use "/usr/local/bin/gcc " as compiler.
I solve it just adding aliases to .bash_profile
# Aliases in order to use brew gcc
alias gcc='gcc-5'
alias cc='gcc-5'
alias g++='g++-5'
alias c++='c++-5'

Resources