Perhaps the easiest way to install this archive is to use the following 2 commands:
wget http://llvm.org/releases/3.2/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz
sudo tar -C /usr/local -xvf clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz --strip 1
This works nicely on my 12.04 VM and gives the following:
andrew@ithaca:~$ clang --version
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
andrew@ithaca:~$
This installation takes away the ability to easily remove the package with standard Ubuntu package management tools but the following single command will remove all of the installed files:
sudo rm -v /usr/local/bin/{clang*,llc,lli,llvm*,macho-dump,opt,bugpoint,c-index-test} && \
sudo rm -rfv /usr/local/docs/llvm && \
sudo rm -rfv /usr/local/include/{clang,clang-c,llvm,llvm-c} && \
sudo rm -v /usr/local/share/man/man1/clang.1 && \
sudo rm -rfv /usr/local/lib/clang && \
sudo rm -v /usr/local/lib/{BugpointPasses.so,libclang*,libLLVM*,libLTO*,libprofile_rt*,LLVM*}
Tested on my own system and it removes the files cleanly...
Ok, so I successfully compiled Halide on Ubuntu 13.04 by installing llvm
, clang
, and build-essential
. My only guess as to your issue is that the LLVM or clang from the PPA you installed might not have worked quite right. It seems it's actually possible to get LLVM 3.2 from Ubuntu for 12.04, via what is known as the "proposed" archive. You might try purging the LLVM you have and installing it from "proposed". I'll explain how to do that below. Since you mentioned you're new to Ubuntu (in the original question version), I'll first explain what each command you've already used does, as best I can.
So, sudo apt-get install llvm-3.2
attempts to install the package named llvm-3.2
from the current repositories enabled on your system. In your case, it couldn't be found, so the command failed. sudo apt-get install llvm
installed the llvm
package, which is probably a special package that just uses the most up-to-date LLVM available in your standard repositories. In your case, that was 2.9. Same idea applies to sudo apt-get install clang
. sudo add-apt-repository ppa:kxstudio-team/builds
adds what's called a personal package archive or PPA to your system. This lets you get more software from another repository, or software source. See https://help.launchpad.net/Packaging/PPA for more info. Finally, sudo apt-get update
tells Ubuntu to get information on what packages are available from the currently available repositories. You might take a look at http://www.debian.org/doc/manuals/debian-faq/ch-pkgtools.en.html for more info on package management in Debian (most of which should apply to Ubuntu as well, since Ubuntu is based on Debian).
So, the steps to remove the packages you've got and install the versions available from precise-proposed:
- Use
sudo apt-get purge llvm-3.2 clang-3.2
to completely remove LLVM and clang from your system.
- (Optional) Use
sudo add-apt-repository --remove ppa:kxstudio-team/builds
to remove the PPA from your system.
- Follow the instructions at https://wiki.ubuntu.com/Testing/EnableProposed to enable the Proposed archive (right at the top of the page), and also follow the instructions for "Selective upgrading from -proposed". The first part will enable the actual Ubuntu version of the
llvm-3.2
package, and the second will keep the system from trying to upgrade everything to the Proposed versions.
- Use
sudo apt-get update
to pull in the information on what packages and versions are now available.
- Use
sudo apt-get install llvm-3.2/precise-proposed
to install LLVM 3.2, and use sudo apt-get install clang/precise-proposed
to install Clang 3.0 (I think that's the version you should get).
- NEW STEP: Do
sudo ln -s /usr/bin/llvm-config-3.2 /usr/local/bin/llvm-config
to make the system treat llvm-config-3.2
(which is the llvm-config
that came with llvm-3.2
) as llvm-config
. More completely, this creates a symbolic link (or symlink) to llvm-config-3.2 in another place where Ubuntu will look for programs (more info: ln, FHS, PATH). Thus, when you run "llvm-config", Ubuntu will find the symlink and run the program it points to (llvm-config-3.2
).
- See if everything compiles correctly now.
Hopefully that works. I've not tested any of this, so use at your own risk, etc. I'm pretty sure, however, that it shouldn't do anything terrible.
EDIT: Note that llvm
and llvm-3.2
are independent. llvm
depends on llvm-2.9
(see here), while llvm-3.2
is separate (see dependencies here)
Also, I'm not sure if you know about tab completion; it can be helpful if you're looking for a command but don't quite know the name (for example, in this case, it would probably have shown that llvm-config
was called llvm-config-3.2
).
Best Answer
If you check what is contained in the package
clang-format-6.0
(dpkg -L clang-format-6.0
) you will find that it does not installclang-format
into the/usr/bin
directory. But you will find that it does install it to/usr/lib/llvm-6.0/bin
instead.One possible solution would be to add
/usr/lib/llvm-6.0/bin
to yourPATH
variable. Under this pathclang-format
is available. The command/usr/bin/clang-format-6.0
is just a symbolic link to it, so it should be equivalent to usingclang-format-6.0
. Why the package maintainer decided to not link/usr/bin/clang-format
as well is not clear to me.If you are unsure how to do that you may want to look it up here: https://help.ubuntu.com/community/EnvironmentVariables