Skip to content
Advertisement

Optimal way to install clang locally when GCC is outdated

I need to use tools that depend on clang on a Unix machine I remote onto at work. Anything I install is locally installed onto ~/local. I do not have root permissions.

/usr is pretty outdated, with gcc being at version 4.4.7. clang requires gcc 4.7+

I read on linux from scratch that a gcc 6.1 installation requires 8.4 gb. This is not something I can do, because that’s huge.

Can someone advise me on the best workaround to install up to date clang on my ~/local?

Please and thanks.

Edit:

Courtesy of Nishant, here is the short answer:

Set up a personal machine running the same linux distro and cross compile using gcc to your specific architecture. For me, I will run a Redhat 6.5 VM and compile using gcc an arm x64 binary. Thanks Nishant!

Advertisement

Answer

You can get pre-build binaries for Unix system from LLVM’s release website: http://llvm.org/releases/

You can then put the binaries in any local folder you want and source it using the PATH variable, which can be done by modifying your ~/.bashrc file by appending:

export PATH=$PATH:<clang-binary-directory>

Now you will able to use clang from the command line terminal as if it was installed.

If you want to build from source only, you can get older source code of clang which will use gcc 4.4.7 and build it and then use clang to build clang. Or get the latest clang binary and use it to build latest clang.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement