Building cling standalone with libc++abi and libc++ on Linux

Since 2013 I have been able to create a “pure” LLVM/clang/libc++/libc++abi 3.3 environment for our Linux distros (Ubuntu 12.04 LTS 64bit, RHEL 6.x, Fedora 17 and later), where “pure” means the environment is free from GNU libstdc++.

This approach is very liberating as it enables us to use C++1y fully even on old Linux (e.g. RHEL 6.x) and is orthogonal to the GNU based build environment. Furthermore, using a distro’s native package management system to handle install/uninstall packages, all hosts are kept clean, not messed up with the typical ./configure && make install.

Last year for 3.3, I used an autotools + native packaging utility based approach. This year, for 3.4 I am again successful in creating a “pure” environment but with cmake, with my own patches to all relevant CMakeLists.txt files and modules. So, today, I wanted to take a stab to build cling as a standalone package (both deb and rpm) free from libstdc++ as well.

Upon reviewing cling’s CMakeLists.txt, first I was encouraged. It seemed that it enables standalone build, despite the build instruction http://root.cern.ch/drupal/content/cling-build-instructions doesn’t say so :frowning: But, upon reviewing for example the following, I knew to get everything going in a “pure” environment would take a lot more work than I have time to:

from src/cmake/modules/HandleLLVMOptions.cmake

20 # Also test that we aren't using too old of a version of libstdc++ with the 21 # Clang compiler. This is tricky as there is no real way to check the 22 # version of libstdc++ directly. Instead we test for a known bug in 23 # libstdc++4.6 that is fixed in libstdc++4.7. 24 if(NOT LLVM_ENABLE_LIBCXX) 25 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) 26 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) 27 set(CMAKE_REQUIRED_FLAGS "-std=c++0x") 28 if (ANDROID) 29 set(CMAKE_REQUIRED_LIBRARIES "atomic") 30 endif() 31 check_cxx_source_compiles(" 32 #include <atomic> 33 std::atomic<float> x(0.0f); 34 int main() { return (float)x; }" 35 LLVM_NO_OLD_LIBSTDCXX) 36 #if(NOT LLVM_NO_OLD_LIBSTDCXX) 37 # message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!") 38 #endif() 39 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) 40 set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) 41 endif() 42 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 43 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0) 44 message(FATAL_ERROR "Host Visual Studio must be at least 2012 (MSVC 17.0)") 45 endif() 46 endif() 47 endif()

The above obviously hard-coded in the assumption that cling is to be built with GCC. No, I haven’t need to use GCC or libstdc++ for more than a year already. clang has been able to self-host since 2010 http://blog.llvm.org/2010/02/clang-successfully-self-hosts.html so using GCC is not mandatory.

Does the cling team have a plan to enable cling to build in a “pure” environment?

Hi,

Sorry - I don’t understand your question. I can build cling with clang. We build cling on MacOS using clang and libc++. I can build cling on Ubuntu with gcc 4.8 and its libstdc++. Can you show me what configure you want to run and what fails?

Cheers, Axel.

Hi Axel,

You said:

The bold-faced part is exactly what I prefer to avoid :slight_smile:. Please see below.

[code]zperry@nb1:~$ cat /etc/issue
Ubuntu 12.04.4 LTS \n \l

zperry@nb1:~ clang++ --version clang version 3.4 (tags/RELEASE_34/final) Target: x86_64-unknown-linux-gnu Thread model: posix zperry@nb1:~ ldd /usr/bin/clang++
linux-vdso.so.1 => (0x00007fff685ff000)
libc++abi.so.1 => /usr/lib/libc++abi.so.1 (0x00007fedfc2ff000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fedfc0fb000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fedfbed3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fedfbcb6000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fedfba9f000)
libc++.so.1 => /usr/lib/libc++.so.1 (0x00007fedfb7e7000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fedfb4eb000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fedfb2d5000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fedfaf14000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fedfad0c000)
/lib64/ld-linux-x86-64.so.2 (0x00007fedfc568000)
[/code]

Note that in our environment, clang is independent of GNU libstdc++. The Q is actually very simple: how can we build cling with such an environment that’s independent of libstdc++?

So far, with the LLVM 3.4 release, all I need to do is the following:

export CC=/usr/bin/clang export CXX=/usr/bin/clang++ export CXXFLAGS="-stdlib=libc++" export LDFLAGS=-lc++abi cmake -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX=/usr .. make -j 4 make package

and I have a

zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4/build$ ls -l *.deb -rw-rw-r-- 1 zperry zperry 50823776 Mar 20 11:00 llvm-dev_3.4-1_amd64.deb

But with your patched LLVM, the above would error out due to these GCC specific checks.

Cheers,

– Zack

Hi,

The part of HandleLLVMOptions.cmake exists in both cling’s patched llvm and vanilla llvm. Could you state the exact steps you do and the error message you get?

Cheers, Axel.

Hi Alex,

First, please let me show you the diff between the vanilla LLVM’s HandleLLVMOptions.cmake and cling’s HandleLLVMOptions.cmake:

[code]zperry@nb1:/tmp$ diff -u HandleLLVMOptions.cmake.orig HandleLLVMOptions.cmake.cling
— HandleLLVMOptions.cmake.orig 2014-03-26 12:27:24.460652728 -0700
+++ HandleLLVMOptions.cmake.cling 2014-03-26 12:28:05.628856848 -0700
@@ -2,16 +2,48 @@

options and executing the appropriate CMake commands to realize the users’

selections.

+include(HandleLLVMStdlib)
include(AddLLVMDefinitions)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

-if( CMAKE_COMPILER_IS_GNUCXX )

  • set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
    -elseif( MSVC )
  • set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF)
    -elseif( “${CMAKE_CXX_COMPILER_ID}” MATCHES “Clang” )
  • set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
    +if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
  • if(CMAKE_CXX_COMPILER_ID STREQUAL “GNU”)
  • if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
  •  message(FATAL_ERROR "Host GCC version must be at least 4.7!")
    
  • endif()
  • elseif(CMAKE_CXX_COMPILER_ID STREQUAL “Clang”)
  • if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
  •  message(FATAL_ERROR "Host Clang version must be at least 3.1!")
    
  • endif()
  • Also test that we aren’t using too old of a version of libstdc++ with the

  • Clang compiler. This is tricky as there is no real way to check the

  • version of libstdc++ directly. Instead we test for a known bug in

  • libstdc++4.6 that is fixed in libstdc++4.7.

  • if(NOT LLVM_ENABLE_LIBCXX)
  •  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
    
  •  set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
    
  •  set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
    
  •  if (ANDROID)
    
  •    set(CMAKE_REQUIRED_LIBRARIES "atomic")
    
  •  endif()
    
  •  check_cxx_source_compiles("
    

+#include
+std::atomic x(0.0f);
+int main() { return (float)x; }"

  •    LLVM_NO_OLD_LIBSTDCXX)
    
  •  #if(NOT LLVM_NO_OLD_LIBSTDCXX)
    
  •  #  message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!")
    
  •  #endif()
    
  •  set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
    
  •  set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
    
  • endif()
  • elseif(CMAKE_CXX_COMPILER_ID MATCHES “MSVC”)
  • if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
  •  message(FATAL_ERROR "Host Visual Studio must be at least 2012 (MSVC 17.0)")
    
  • endif()
  • endif()
    endif()

if( LLVM_ENABLE_ASSERTIONS )
@@ -24,13 +56,13 @@
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL “DEBUG” )
add_definitions( -UNDEBUG )
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.

  • set(REGEXP_NDEBUG “(^| )[/-]D *NDEBUG($| )”)
  • string (REGEX REPLACE “${REGEXP_NDEBUG}” " "
  •  CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    
  • string (REGEX REPLACE “${REGEXP_NDEBUG}” " "
  •  CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
    
  • string (REGEX REPLACE “${REGEXP_NDEBUG}” " "
  •  CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
    
  • set(REGEXP_NDEBUG “(^| )[/-]D *NDEBUG($| )”)
  • string (REGEX REPLACE “${REGEXP_NDEBUG}” " "
  •  CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    
  • string (REGEX REPLACE “${REGEXP_NDEBUG}” " "
  •  CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
    
  • string (REGEX REPLACE “${REGEXP_NDEBUG}” " "
  •  CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
    
    endif()
    else()
    if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL “RELEASE” )
    @@ -41,6 +73,7 @@
    endif()

if(WIN32)

  • set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
    if(CYGWIN)
    set(LLVM_ON_WIN32 0)
    set(LLVM_ON_UNIX 1)
    @@ -48,8 +81,6 @@
    set(LLVM_ON_WIN32 1)
    set(LLVM_ON_UNIX 0)
    endif(CYGWIN)
  • set(LTDL_SHLIB_EXT “.dll”)
  • set(EXEEXT “.exe”)

    Maximum path length is 160 for non-unicode paths

    set(MAXPATHLEN 160)
    else(WIN32)
    @@ -57,11 +88,10 @@
    set(LLVM_ON_WIN32 0)
    set(LLVM_ON_UNIX 1)
    if(APPLE)
  •  set(LTDL_SHLIB_EXT ".dylib")
    
  •  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
    
    else(APPLE)
  •  set(LTDL_SHLIB_EXT ".so")
    
  •  set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
    
    endif(APPLE)
  • set(EXEEXT “”)

    FIXME: Maximum path length is currently set to ‘safe’ fixed value

    set(MAXPATHLEN 2024)
    else(UNIX)
    @@ -69,6 +99,17 @@
    endif(UNIX)
    endif(WIN32)

+set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
+set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+# We use *.dylib rather than *.so on darwin.
+set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+if(APPLE)

  • Darwin-specific linker flags for loadable modules.

  • set(CMAKE_MODULE_LINKER_FLAGS “${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress”)
    +endif()

function(add_flag_or_print_warning flag)
check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
@@ -246,6 +287,10 @@
if (LLVM_ENABLE_WERROR)
add_llvm_definitions( -Werror )
endif (LLVM_ENABLE_WERROR)

  • if (LLVM_ENABLE_CXX11)
  • check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
  • append_if(CXX_SUPPORTS_CXX11 “-std=c++11” CMAKE_CXX_FLAGS)
  • endif (LLVM_ENABLE_CXX11)
    endif( MSVC )

macro(append_common_sanitizer_flags)
@@ -297,3 +342,34 @@
CMAKE_GENERATOR STREQUAL “Ninja”)
append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
+
+# Add flags for add_dead_strip().
+# FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
+# But MinSizeRel seems to add that automatically, so maybe disable these
+# flags instead if LLVM_NO_DEAD_STRIP is set.
+if(NOT CYGWIN AND NOT WIN32)

  • if(NOT ${CMAKE_SYSTEM_NAME} MATCHES “Darwin”)
  • check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS)
  • if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
  •  # Don't add -ffunction-section if it can be disabled with -fno-function-sections.
    
  •  # Doing so will break sanitizers.
    
  •  check_c_compiler_flag("-Werror -ffunction-sections" C_SUPPORTS_FFUNCTION_SECTIONS)
    
  •  check_cxx_compiler_flag("-Werror -ffunction-sections" CXX_SUPPORTS_FFUNCTION_SECTIONS)
    
  •  append_if(C_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_C_FLAGS)
    
  •  append_if(CXX_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_CXX_FLAGS)
    
  • endif()
  • check_c_compiler_flag("-Werror -fdata-sections" C_SUPPORTS_FDATA_SECTIONS)
  • check_cxx_compiler_flag("-Werror -fdata-sections" CXX_SUPPORTS_FDATA_SECTIONS)
  • append_if(C_SUPPORTS_FDATA_SECTIONS “-fdata-sections” CMAKE_C_FLAGS)
  • append_if(CXX_SUPPORTS_FDATA_SECTIONS “-fdata-sections” CMAKE_CXX_FLAGS)
  • endif()
    +endif()

+if(MSVC)

  • Remove flags here, for exceptions and RTTI.

  • Each target property or source property should be responsible to control

  • them.

  • CL.EXE complains to override flags like “/GR /GR-”.

  • string(REGEX REPLACE “(^| ) */EH[-cs]+ *( |$)” “\1 \2” CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS}”)
  • string(REGEX REPLACE “(^| ) */GR-? *( |$)” “\1 \2” CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS}”)
    +endif()[/code]

Next, please let me show you how I normally build the vanilla LLVM with libc++abi, libc++, and clang 3.4 on a Ubuntu 12.04 64bit, starting from an empty build subdirectory:

zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4$ clear zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4$ export CC=/usr/bin/clang zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4$ export CXX=/usr/bin/clang++ zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4$ export CXXFLAGS="-stdlib=libc++" zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4$ export LDFLAGS=-lc++abi zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4$ cd build zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4/build$ CC=clang CXX=clang++ cmake -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX=/usr .. -- The C compiler identification is Clang 3.4.0 -- The CXX compiler identification is Clang 3.4.0 -- Check for working C compiler: /usr/bin/clang -- Check for working C compiler: /usr/bin/clang -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/clang++ -- Check for working CXX compiler: /usr/bin/clang++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Looking for C++ include cxxabi.h -- Looking for C++ include cxxabi.h - found -- Looking for dirent.h -- Looking for dirent.h - found -- Looking for dlfcn.h -- Looking for dlfcn.h - found -- Looking for errno.h -- Looking for errno.h - found -- Looking for execinfo.h -- Looking for execinfo.h - found -- Looking for fcntl.h -- Looking for fcntl.h - found -- Looking for inttypes.h -- Looking for inttypes.h - found -- Looking for limits.h -- Looking for limits.h - found -- Looking for malloc.h -- Looking for malloc.h - found -- Looking for malloc/malloc.h -- Looking for malloc/malloc.h - not found -- Looking for ndir.h -- Looking for ndir.h - not found -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for sanitizer/msan_interface.h -- Looking for sanitizer/msan_interface.h - found -- Looking for signal.h -- Looking for signal.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for sys/dir.h -- Looking for sys/dir.h - found -- Looking for sys/ioctl.h -- Looking for sys/ioctl.h - found -- Looking for sys/mman.h -- Looking for sys/mman.h - found -- Looking for sys/ndir.h -- Looking for sys/ndir.h - not found -- Looking for sys/param.h -- Looking for sys/param.h - found -- Looking for sys/resource.h -- Looking for sys/resource.h - found -- Looking for sys/stat.h -- Looking for sys/stat.h - found -- Looking for sys/time.h -- Looking for sys/time.h - found -- Looking for sys/uio.h -- Looking for sys/uio.h - found -- Looking for sys/wait.h -- Looking for sys/wait.h - found -- Looking for termios.h -- Looking for termios.h - found -- Looking for unistd.h -- Looking for unistd.h - found -- Looking for utime.h -- Looking for utime.h - found -- Looking for valgrind/valgrind.h -- Looking for valgrind/valgrind.h - not found -- Looking for zlib.h -- Looking for zlib.h - found -- Looking for fenv.h -- Looking for fenv.h - found -- Looking for FE_ALL_EXCEPT -- Looking for FE_ALL_EXCEPT - found -- Looking for FE_INEXACT -- Looking for FE_INEXACT - found -- Looking for mach/mach.h -- Looking for mach/mach.h - not found -- Looking for mach-o/dyld.h -- Looking for mach-o/dyld.h - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Looking for pthread_getspecific in pthread -- Looking for pthread_getspecific in pthread - found -- Looking for pthread_rwlock_init in pthread -- Looking for pthread_rwlock_init in pthread - found -- Looking for pthread_mutex_lock in pthread -- Looking for pthread_mutex_lock in pthread - found -- Looking for dlopen in dl -- Looking for dlopen in dl - found -- Looking for clock_gettime in rt -- Looking for clock_gettime in rt - found -- Looking for compress2 in z -- Looking for compress2 in z - found -- Looking for setupterm in tinfo -- Looking for setupterm in tinfo - found -- Looking for arc4random -- Looking for arc4random - not found -- Looking for backtrace -- Looking for backtrace - found -- Looking for getpagesize -- Looking for getpagesize - found -- Looking for getrusage -- Looking for getrusage - found -- Looking for setrlimit -- Looking for setrlimit - found -- Looking for isatty -- Looking for isatty - found -- Looking for isinf -- Looking for isinf - not found -- Looking for isinf -- Looking for isinf - found -- Looking for finite -- Looking for finite - not found -- Looking for isnan -- Looking for isnan - not found -- Looking for isnan -- Looking for isnan - found -- Looking for ceilf -- Looking for ceilf - found -- Looking for floorf -- Looking for floorf - found -- Looking for fmodf -- Looking for fmodf - found -- Looking for log -- Looking for log - found -- Looking for log2 -- Looking for log2 - found -- Looking for log10 -- Looking for log10 - found -- Looking for exp -- Looking for exp - found -- Looking for exp2 -- Looking for exp2 - found -- Looking for exp10 -- Looking for exp10 - not found -- Looking for futimens -- Looking for futimens - found -- Looking for futimes -- Looking for futimes - found -- Looking for writev -- Looking for writev - found -- Looking for nearbyintf -- Looking for nearbyintf - found -- Looking for mallinfo -- Looking for mallinfo - found -- Looking for malloc_zone_statistics -- Looking for malloc_zone_statistics - not found -- Looking for mkdtemp -- Looking for mkdtemp - found -- Looking for mkstemp -- Looking for mkstemp - found -- Looking for mktemp -- Looking for mktemp - found -- Looking for closedir -- Looking for closedir - found -- Looking for opendir -- Looking for opendir - found -- Looking for readdir -- Looking for readdir - found -- Looking for getcwd -- Looking for getcwd - found -- Looking for gettimeofday -- Looking for gettimeofday - found -- Looking for getrlimit -- Looking for getrlimit - found -- Looking for posix_spawn -- Looking for posix_spawn - found -- Looking for pread -- Looking for pread - found -- Looking for realpath -- Looking for realpath - found -- Looking for sbrk -- Looking for sbrk - found -- Looking for srand48 -- Looking for srand48 - found -- Looking for lrand48 -- Looking for lrand48 - found -- Looking for drand48 -- Looking for drand48 - found -- Looking for strtoll -- Looking for strtoll - found -- Looking for strtoq -- Looking for strtoq - found -- Looking for strerror -- Looking for strerror - found -- Looking for strerror_r -- Looking for strerror_r - found -- Looking for strerror_s -- Looking for strerror_s - not found -- Looking for setenv -- Looking for setenv - found -- Looking for dlerror -- Looking for dlerror - found -- Looking for dlopen -- Looking for dlopen - found -- Looking for __GLIBC__ -- Looking for __GLIBC__ - found -- Performing Test HAVE_INT64_T -- Performing Test HAVE_INT64_T - Success -- Performing Test HAVE_UINT64_T -- Performing Test HAVE_UINT64_T - Success -- Performing Test HAVE_U_INT64_T -- Performing Test HAVE_U_INT64_T - Success -- Performing Test LLVM_HAS_ATOMICS -- Performing Test LLVM_HAS_ATOMICS - Success -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.7.8") -- Performing Test SUPPORTS_NO_VARIADIC_MACROS_FLAG -- Performing Test SUPPORTS_NO_VARIADIC_MACROS_FLAG - Success -- Target triple: x86_64-unknown-linux-gnu -- Native target architecture is X86 -- Threads enabled. -- Doxygen disabled. -- Performing Test C_SUPPORTS_FLAG -- Performing Test C_SUPPORTS_FLAG - Success -- Performing Test CXX_SUPPORTS_FLAG -- Performing Test CXX_SUPPORTS_FLAG - Success -- Building with -fPIC -- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG -- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success -- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG -- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG - Success -- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG -- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success -- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG -- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success -- Performing Test CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG -- Performing Test CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG - Success -- Found PythonInterp: /usr/bin/python (found version "2.7.3") -- Constructing LLVMBuild project information -- Targeting X86 -- Performing Test SUPPORTS_GLINE_TABLES_ONLY_FLAG -- Performing Test SUPPORTS_GLINE_TABLES_ONLY_FLAG - Success -- Performing Test SUPPORTS_NO_C99_EXTENSIONS_FLAG -- Performing Test SUPPORTS_NO_C99_EXTENSIONS_FLAG - Success -- Performing Test SUPPORTS_NO_NON_VIRTUAL_DTOR_FLAG -- Performing Test SUPPORTS_NO_NON_VIRTUAL_DTOR_FLAG - Success -- Performing Test SUPPORTS_GLOBAL_CONSTRUCTORS_FLAG -- Performing Test SUPPORTS_GLOBAL_CONSTRUCTORS_FLAG - Success -- Configuring done -- Generating done -- Build files have been written to: /home/zperry/work/llvm/clang3.4/_tars/llvm-3.4/build zperry@nb1:~/work/llvm/clang3.4/_tars/llvm-3.4/build$

Finally, doing the same, again starting from an empty build subdirectory resulted the following:

[code]zperry@nb1:~/work/llvm/cling/src/build$ CC=clang CXX=clang++ cmake -DLLVM_TARGETS_TO_BUILD=“X86” -DCMAKE_BUILD_TYPE=“Release” -DCMAKE_INSTALL_PREFIX=/usr …
– The C compiler identification is Clang 3.4.0
– The CXX compiler identification is Clang 3.4.0
– Check for working C compiler: /usr/bin/clang
– Check for working C compiler: /usr/bin/clang – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working CXX compiler: /usr/bin/clang++
– Check for working CXX compiler: /usr/bin/clang++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Looking for C++ include cxxabi.h
– Looking for C++ include cxxabi.h - found
– Looking for dirent.h
– Looking for dirent.h - found
– Looking for dlfcn.h
– Looking for dlfcn.h - found
– Looking for errno.h
– Looking for errno.h - found
– Looking for execinfo.h
– Looking for execinfo.h - found
– Looking for fcntl.h
– Looking for fcntl.h - found
– Looking for inttypes.h
– Looking for inttypes.h - found
– Looking for limits.h
– Looking for limits.h - found
– Looking for malloc.h
– Looking for malloc.h - found
– Looking for malloc/malloc.h
– Looking for malloc/malloc.h - not found
– Looking for ndir.h
– Looking for ndir.h - not found
– Looking for pthread.h
– Looking for pthread.h - found
– Looking for signal.h
– Looking for signal.h - found
– Looking for stdint.h
– Looking for stdint.h - found
– Looking for sys/dir.h
– Looking for sys/dir.h - found
– Looking for sys/ioctl.h
– Looking for sys/ioctl.h - found
– Looking for sys/mman.h
– Looking for sys/mman.h - found
– Looking for sys/ndir.h
– Looking for sys/ndir.h - not found
– Looking for sys/param.h
– Looking for sys/param.h - found
– Looking for sys/resource.h
– Looking for sys/resource.h - found
– Looking for sys/stat.h
– Looking for sys/stat.h - found
– Looking for sys/time.h
– Looking for sys/time.h - found
– Looking for sys/uio.h
– Looking for sys/uio.h - found
– Looking for sys/wait.h
– Looking for sys/wait.h - found
– Looking for termios.h
– Looking for termios.h - found
– Looking for unistd.h
– Looking for unistd.h - found
– Looking for utime.h
– Looking for utime.h - found
– Looking for valgrind/valgrind.h
– Looking for valgrind/valgrind.h - not found
– Looking for zlib.h
– Looking for zlib.h - found
– Looking for fenv.h
– Looking for fenv.h - found
– Looking for FE_ALL_EXCEPT
– Looking for FE_ALL_EXCEPT - found
– Looking for FE_INEXACT
– Looking for FE_INEXACT - found
– Looking for mach/mach.h
– Looking for mach/mach.h - not found
– Looking for mach-o/dyld.h
– Looking for mach-o/dyld.h - not found
– Looking for pthread_create in pthread
– Looking for pthread_create in pthread - found
– Looking for pthread_getspecific in pthread
– Looking for pthread_getspecific in pthread - found
– Looking for pthread_rwlock_init in pthread
– Looking for pthread_rwlock_init in pthread - found
– Looking for pthread_mutex_lock in pthread
– Looking for pthread_mutex_lock in pthread - found
– Looking for dlopen in dl
– Looking for dlopen in dl - found
– Looking for clock_gettime in rt
– Looking for clock_gettime in rt - found
– Looking for compress2 in z
– Looking for compress2 in z - found
– Looking for el_init in edit
– Looking for el_init in edit - found
– Looking for setupterm in tinfo
– Looking for setupterm in tinfo - found
– Looking for arc4random
– Looking for arc4random - not found
– Looking for backtrace
– Looking for backtrace - found
– Looking for getpagesize
– Looking for getpagesize - found
– Looking for getrusage
– Looking for getrusage - found
– Looking for setrlimit
– Looking for setrlimit - found
– Looking for isatty
– Looking for isatty - found
– Looking for isinf
– Looking for isinf - not found
– Looking for isinf
– Looking for isinf - found
– Looking for finite
– Looking for finite - not found
– Looking for isnan
– Looking for isnan - not found
– Looking for isnan
– Looking for isnan - found
– Looking for ceilf
– Looking for ceilf - found
– Looking for floorf
– Looking for floorf - found
– Looking for fmodf
– Looking for fmodf - found
– Looking for log
– Looking for log - found
– Looking for log2
– Looking for log2 - found
– Looking for log10
– Looking for log10 - found
– Looking for exp
– Looking for exp - found
– Looking for exp2
– Looking for exp2 - found
– Looking for exp10
– Looking for exp10 - not found
– Looking for futimens
– Looking for futimens - found
– Looking for futimes
– Looking for futimes - found
– Looking for writev
– Looking for writev - found
– Looking for nearbyintf
– Looking for nearbyintf - found
– Looking for mallinfo
– Looking for mallinfo - found
– Looking for malloc_zone_statistics
– Looking for malloc_zone_statistics - not found
– Looking for mkdtemp
– Looking for mkdtemp - found
– Looking for mkstemp
– Looking for mkstemp - found
– Looking for mktemp
– Looking for mktemp - found
– Looking for closedir
– Looking for closedir - found
– Looking for opendir
– Looking for opendir - found
– Looking for readdir
– Looking for readdir - found
– Looking for getcwd
– Looking for getcwd - found
– Looking for gettimeofday
– Looking for gettimeofday - found
– Looking for getrlimit
– Looking for getrlimit - found
– Looking for posix_spawn
– Looking for posix_spawn - found
– Looking for pread
– Looking for pread - found
– Looking for realpath
– Looking for realpath - found
– Looking for sbrk
– Looking for sbrk - found
– Looking for srand48
– Looking for srand48 - found
– Looking for lrand48
– Looking for lrand48 - found
– Looking for drand48
– Looking for drand48 - found
– Looking for strtoll
– Looking for strtoll - found
– Looking for strtoq
– Looking for strtoq - found
– Looking for strerror
– Looking for strerror - found
– Looking for strerror_r
– Looking for strerror_r - found
– Looking for strerror_s
– Looking for strerror_s - not found
– Looking for setenv
– Looking for setenv - found
– Looking for dlerror
– Looking for dlerror - found
– Looking for dlopen
– Looking for dlopen - found
– Looking for GLIBC
– Looking for GLIBC - found
– Looking for __dso_handle
– Looking for __dso_handle - found
– Performing Test HAVE_INT64_T
– Performing Test HAVE_INT64_T - Success
– Performing Test HAVE_UINT64_T
– Performing Test HAVE_UINT64_T - Success
– Performing Test HAVE_U_INT64_T
– Performing Test HAVE_U_INT64_T - Success
– Performing Test LLVM_HAS_ATOMICS
– Performing Test LLVM_HAS_ATOMICS - Success
– Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version “2.7.8”)
– Performing Test SUPPORTS_NO_VARIADIC_MACROS_FLAG
– Performing Test SUPPORTS_NO_VARIADIC_MACROS_FLAG - Success
– Target triple: x86_64-unknown-linux-gnu
– Native target architecture is X86
– Threads enabled.
– Doxygen disabled.
– Performing Test LLVM_NO_OLD_LIBSTDCXX
– Performing Test LLVM_NO_OLD_LIBSTDCXX - Success
– Performing Test C_SUPPORTS_FLAG
– Performing Test C_SUPPORTS_FLAG - Success
– Performing Test CXX_SUPPORTS_FLAG
– Performing Test CXX_SUPPORTS_FLAG - Success
– Building with -fPIC
– Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
– Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
– Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG
– Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG - Success
– Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
– Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success
– Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
– Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success
– Performing Test CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG
– Performing Test CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG - Success
– Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS
– Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS - Failed
– Performing Test C_SUPPORTS_FDATA_SECTIONS
– Performing Test C_SUPPORTS_FDATA_SECTIONS - Success
– Performing Test CXX_SUPPORTS_FDATA_SECTIONS
– Performing Test CXX_SUPPORTS_FDATA_SECTIONS - Success
– Found PythonInterp: /usr/bin/python (found version “2.7.3”)
– Constructing LLVMBuild project information
CMake Error at cmake/modules/AddLLVM.cmake:261 (set_output_directory):
set_output_directory Function invoked with incorrect arguments for function
named: set_output_directory
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:347 (llvm_add_library)
lib/Support/CMakeLists.txt:1 (add_llvm_library)

CMake Error at cmake/modules/AddLLVM.cmake:261 (set_output_directory):
set_output_directory Function invoked with incorrect arguments for function
named: set_output_directory
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:347 (llvm_add_library)
lib/TableGen/CMakeLists.txt:1 (add_llvm_library)

CMake Error at cmake/modules/AddLLVM.cmake:403 (set_output_directory):
set_output_directory Function invoked with incorrect arguments for function
named: set_output_directory
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:450 (add_llvm_executable)
cmake/modules/TableGen.cmake:96 (add_llvm_utility)
utils/TableGen/CMakeLists.txt:3 (add_tablegen)

CMake Error at cmake/modules/TableGen.cmake:13 (message):
LLVM_TABLEGEN_EXE not set
Call Stack (most recent call first):
include/llvm/IR/CMakeLists.txt:3 (tablegen)

– Configuring incomplete, errors occurred!
zperry@nb1:~/work/llvm/cling/src/build$
[/code]

cmake couldn’t even complete the configuration steps :frowning:

I hope these were sufficient? I like cling very much (it reminds me the pleasure of using Saber C/C++ interpreter in the early 90s :smiley: and would like to see it in wider use. But the above has been a hindrance so far.

Thanks!

– Zack

Hi,

Thanks! Lets start from the basic things:

HandleLLVMOptions.cmake is a verbatim copy of what’s in llvm rev 202469 - we have applied no changes to this file.

Cheers, Axel.

Hi Alex,

Thanks! So, I will try to resolve that first.

– Zack