Building with LLVM in $HOME/opt

209 views
Skip to first unread message

Joseph Rushton Wakeling

unread,
Nov 13, 2012, 5:54:12 AM11/13/12
to ldc...@googlegroups.com
Hello all,

I've just got access to a new cluster at work, so of course I'm starting by
installing D ... :-)

As I'm the only one in the group so far using D (give me time, give me time...)
I'm installing everything in $HOME/opt -- so e.g. DMD goes in
$HOME/opt/dmd/[bin,lib,include], etc.

The cluster is running Ubuntu 12.04, so LLVM 3.1 is not available in package
archives, only 3.0. Not to worry; I've downloaded the clang+llvm-3.1
precompiled binaries from llvm.org and they're in $HOME/opt/clanv+llvm.

Question is, how to invoke cmake so that the build process will look for the
libraries here. What I've found searching around online all talks about editing
the cmake setup files, which seems overkill when AFAICS all I really need to do
is make sure that an extra -I and -L option is passed to the compiler during
build time.

Can anyone advise?

Thanks & best wishes,

-- Joe

David Nadlinger

unread,
Nov 13, 2012, 7:15:48 AM11/13/12
to ldc...@googlegroups.com
On 13 Nov 2012, at 11:54, Joseph Rushton Wakeling wrote:
> The cluster is running Ubuntu 12.04, so LLVM 3.1 is not available in
> package archives, only 3.0. Not to worry; I've downloaded the
> clang+llvm-3.1 precompiled binaries from llvm.org and they're in
> $HOME/opt/clanv+llvm.
>
> Question is, how to invoke cmake so that the build process will look
> for the libraries here. What I've found searching around online all
> talks about editing the cmake setup files, which seems overkill when
> AFAICS all I really need to do is make sure that an extra -I and -L
> option is passed to the compiler during build time.

Setting the LLVM_CONFIG CMake variable to the path of the llvm-config
binary of the installation you want to use (e.g. using ccmake) should do
the trick.

By the way, even if 3.1 is preferred, LDC should work fine against LLVM
3.0 – the auto tester even runs it.

David

joseph....@gmail.com

unread,
Nov 13, 2012, 10:30:05 AM11/13/12
to ldc...@googlegroups.com
On Tuesday, 13 November 2012 13:15:52 UTC+1, David Nadlinger wrote:
> Setting the LLVM_CONFIG CMake variable to the path of the llvm-config
> binary of the installation you want to use (e.g. using ccmake) should do
> the trick.

Cool, will look into that. I tried setting the CMAKE_PREFIX_PATH but that failed with the following error:

------------------------------------------------------------------------
-- Found LLVM: /home/joseph/opt/clang+llvm-3.1 (found suitable version "3.1", required is "3.0")
-- Could NOT find LIBCONFIG++ (missing: LIBCONFIG++_INCLUDE_DIR LIBCONFIG++_LIBRARY)
-- Using path for llvm/Intrinsics.td: /home/joseph/opt/clang+llvm-3.1/include
-- Looking for _SC_ARG_MAX
-- Looking for _SC_ARG_MAX - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBCONFIG++_INCLUDE_DIR
used as include directory in directory /home/joseph/code/D/ldc
used as include directory in directory /home/joseph/code/D/ldc/runtime
used as include directory in directory /home/joseph/code/D/ldc/tests/d2
LIBCONFIG++_LIBRARY
linked by target "ldc2" in directory /home/joseph/code/D/ldc
------------------------------------------------------------------------


> By the way, even if 3.1 is preferred, LDC should work fine against LLVM
> 3.0 – the auto tester even runs it.

Oh, nice -- I recall some commits in the source history that made me think only 3.1 would work these days.

Anyway, trying to build against the system LLVM generates this error:

------------------------------------------------------------------------
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
llvm-config: unknown component name: all-targets
CMake Error at cmake/Modules/FindLLVM.cmake:77 (string):
string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
command.
Call Stack (most recent call first):
cmake/Modules/FindLLVM.cmake:96 (llvm_set_libs)
CMakeLists.txt:16 (find_package)


CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
Could NOT find LLVM: Found unsuitable version "2.9", but required is at
least "3.0" (found /usr/lib/llvm-2.9)
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:250 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindLLVM.cmake:105 (find_package_handle_standard_args)
CMakeLists.txt:16 (find_package)
------------------------------------------------------------------------

... even though llvm-3.0-dev is installed: it looks like both -2.9-dev and -3.0-dev are both there.

Joseph Rushton Wakeling

unread,
Nov 13, 2012, 10:50:01 AM11/13/12
to ldc...@googlegroups.com
On 11/13/2012 04:30 PM, joseph....@gmail.com wrote:
> On Tuesday, 13 November 2012 13:15:52 UTC+1, David Nadlinger wrote:
>> Setting the LLVM_CONFIG CMake variable to the path of the llvm-config
>> binary of the installation you want to use (e.g. using ccmake) should do
>> the trick.
>
> Cool, will look into that. I tried setting the CMAKE_PREFIX_PATH but that failed with the following error:

Setting LLVM_CONFIG=$HOME/opt/clang+llvm/bin/llvm-config exits with the same
error, i.e.

-- Could NOT find LIBCONFIG++ (missing: LIBCONFIG++_INCLUDE_DIR
LIBCONFIG++_LIBRARY)

... and all that follows. :-(

David Nadlinger

unread,
Nov 13, 2012, 12:41:36 PM11/13/12
to ldc...@googlegroups.com
On 13 Nov 2012, at 16:50, Joseph Rushton Wakeling wrote
> Setting LLVM_CONFIG=$HOME/opt/clang+llvm/bin/llvm-config exits with
> the same error, i.e.
>
> -- Could NOT find LIBCONFIG++ (missing: LIBCONFIG++_INCLUDE_DIR
> LIBCONFIG++_LIBRARY)

This means that you are missing libconfig++ and its header files
(https://github.com/ldc-developers/ldc/wiki/Installation). It was
changed some time ago from a hard error to a warning because the
detection didn't work reliably. However, the error messages seem to have
suffered when the detection was moved away from using pkg-config. Could
you please add a GitHub issue?

In case you do have libconfig++ available and CMake isn't able to find
it, try setting the variables manually.

David

joseph....@gmail.com

unread,
Nov 13, 2012, 2:22:38 PM11/13/12
to ldc...@googlegroups.com
On Tuesday, 13 November 2012 18:41:41 UTC+1, David Nadlinger wrote:
> This means that you are missing libconfig++ and its header files
> (https://github.com/ldc-developers/ldc/wiki/Installation). It was
> changed some time ago from a hard error to a warning because the
> detection didn't work reliably. However, the error messages seem to have
> suffered when the detection was moved away from using pkg-config. Could
> you please add a GitHub issue?

Aggh, I'm an idiot -- I had libconfig but not libconfig++. Fixed, and now the install works.

Do you still want me to add an issue, since as it turns out the error was correct?

Reply all
Reply to author
Forward
0 new messages