Cannot compile llvm/clang/cling on Mac OS X 10.7

Dear CLING developers,

I have tried to build llvm/clang/cling using the latest trunks for each project, without success. I have been trying for several weeks now, re-compiling after updating the repositories.

However, I keep getting the following compilation (actually linking) error, after running ‘./configure’ and ‘make’ from the llvm directory:

llvm[4]: Linking Debug+Asserts Shared Library libcling.dylib
Undefined symbols:
  "clang::Diagnostic::~Diagnostic()", referenced from:
     -exported_symbol[s_list] command line option
  "clang::BuiltinType::getName(clang::LangOptions const&) const", referenced from:
     -exported_symbol[s_list] command line option
  "clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, char const* const*, char const* const*, clang::Diagnostic&)", referenced from:
     -exported_symbol[s_list] command line option
  "clang::CreateLLVMCodeGen(clang::Diagnostic&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::CodeGenOptions const&, llvm::LLVMContext&)", referenced from:
     -exported_symbol[s_list] command line option
  "clang::ASTReader::getOriginalSourceFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::FileManager&, clang::Diagnostic&)", referenced from:
     -exported_symbol[s_list] command line option
ld: symbol(s) not found
collect2: ld returned 1 exit status

Could you please advise? Note that I am not trying to link it with ROOT (yet).

Let me know if you need more information. Below are the outputs of ‘svn info’ for the llvm directory, and its tools/clang and tools/cling subdirectories.

Thank you,
Karolos

@mbp llvm $ svn info
Path: .
URL: http://llvm.org/svn/llvm-project/llvm/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 142798
Node Kind: directory
Schedule: normal
Last Changed Author: d0k
Last Changed Rev: 142794
Last Changed Date: 2011-10-24 15:50:56 +0200 (Mon, 24 Oct 2011)

@mbp llvm $ svn info tools/clang/
Path: tools/clang
URL: http://llvm.org/svn/llvm-project/cfe/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 142798
Node Kind: directory
Schedule: normal
Last Changed Author: dgregor
Last Changed Rev: 142798
Last Changed Date: 2011-10-24 17:49:38 +0200 (Mon, 24 Oct 2011)

@mbp llvm $ svn info tools/cling/
Path: tools/cling
URL: http://root.cern.ch/svn/root/branches/dev/cling
Repository Root: http://root.cern.ch/svn/root
Repository UUID: 27541ba8-7e3a-0410-8455-c3a389f83636
Revision: 41555
Node Kind: directory
Schedule: normal
Last Changed Author: vvassilev
Last Changed Rev: 41377
Last Changed Date: 2011-10-12 22:18:48 +0200 (Wed, 12 Oct 2011)

Hi,
Cling is already in ROOT’s trunk:
root.cern.ch/svn/root/trunk/cint/cling
I assume that the branch is out of sync.
Cheers,
Vassil

Hi Vassil,

Thank you very much for your quick reply: I had forgotten that I had checked a dev branch out.
Everything works. However, the config script in ROOT v5.30.03 does not understand the ‘–with-llvm-config’ option. The trunk, however, does. Maybe this should be mentioned on

root.cern.ch/drupal/content/clin … structions

Best,
Karolos

[quote=“karolos”]Hi Vassil,

Thank you very much for your quick reply: I had forgotten that I had checked a dev branch out.
Everything works. However, the config script in ROOT v5.30.03 does not understand the ‘–with-llvm-config’ option. The trunk, however, does. Maybe this should be mentioned on

root.cern.ch/drupal/content/clin … structions

Best,
Karolos[/quote]

Hi Karolos,
You are welcome.
You are right --with-llvm-config doesn’t exist for ROOT v5.30.03 because cling is not in that release. Cling lives only in ROOT’s trunk and hopefully it will show up in the November release.
Cheers,
Vassil

Hi Vassil,

It seems like the current trunks of llvm/clang/cling (Revision: 142933, Revision: 142933, and Revision: 41579) are a non-working combination, for I get the following error:

llvm[4]: Linking Release+Asserts Shared Library libcling.dylib
Undefined symbols:
  "llvm::sys::DynamicLibrary::LoadLibraryPermanently(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)", referenced from:
     -exported_symbol[s_list] command line option
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[4]: *** [/Users/karolos/OpenSource/svn/llvm/Release+Asserts/lib/libcling.dylib] Error 1

Would you have an idea? I am not yet familiar enough with LLVM to be able to fix this, bit it looks like a library is not being linked.

In understand that since these are two (three?) independent projects, it is harder to get working combinations, especially if one re-shuffles content between libraries which another project links against.

Thanks,
Karolos

Hi Karolos,
Did you run make clean and rebuild from scratch after you had relocated?
Could you try with r41580 of the trunk?
Cheers,
Vassil

Hi Vassil,

Usually I don’t run make clean after my round of svn up, and didn’t in this case. In principle, the build system should be smart enough (i.e. the Makefiles properly written) to pick up the modifications and re-compile what has changed. Of course it is not always the case, as the projects are so big, and I’ve had to cleanup.

Your last patch fixed the issues. Thanks for your help.

Cheers,
Karolos

I just hit this issue with latest llvm/clang from yesterday. This fixed it:

Index: tools/libcling/libcling.exports
===================================================================
--- tools/libcling/libcling.exports	(revision 41794)
+++ tools/libcling/libcling.exports	(working copy)
@@ -67,7 +67,6 @@
 _ZN5cling13UserInterfaceD1Ev
 _ZN5cling7runtime8internal16local_cxa_atexitEPFvPvES2_S2_PNS_11InterpreterE
 _ZN5cling7runtime8internal21__trigger__cxa_atexitD1Ev
-_ZN5cling9CIFactory8createCIEPN4llvm12MemoryBufferEPN5clang15PragmaNamespaceEiPKPKcS8_
 _ZNK4llvm5APInt8toStringEjb
 _ZNK4llvm5Value7getNameEv
 _ZNK5clang10RecordDecl19isInjectedClassNameEv

Hi,
Fixed in r41846. (Soon we will have our new continuous integration tool up for cling as well and this won’t be happening so often. Until then it’s a bit painful)
Cheers,
Vassil