[cfe-dev] clang++ invoking custom built gold

Giulio Eulisse Giulio.Eulisse at cern.ch
Mon Mar 21 04:08:27 PDT 2011


Dear all,

I'm trying to compile our software (a quite large C++ codebase) using clang. 

We usually build it with an own-built version of gcc 4.5.1 + gold since we do not want / cannot use the system compiler. For the record the linux distribution we use is SLC5 (https://www.scientificlinux.org/) which itself is a variant of RHEL5.

To do the port I used the same environment to build the clang suite and then changed g++ to clang++ in our build files.

While we still have some compilation issue to fix, the main problem is that any linking fails because gold, which is invoked via clang++, is not able to get the correct runtime stuff:

	/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/bin/ld: error: cannot open crtbeginS.o: No such file or directory
	/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/bin/ld: error: cannot open crtendS.o: No such file or directory
	/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/bin/ld: error: cannot find -lstdc++
	/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/bin/ld: error: cannot find -lgcc_s
	/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/bin/ld: error: cannot find -lgcc_s

Googling around I found some hints on how to workaround the problem and actually managed to hammer it to a working state (see attached patch), however this is clearly a kludge and I was wondering if you had any better solution.

Ciao,
Giulio
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 127872)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -3674,7 +3674,9 @@

  Args.AddAllArgs(CmdArgs, options::OPT_L);

-  const ToolChain::path_list Paths = ToolChain.getFilePaths();
+  ToolChain::path_list Paths = ToolChain.getFilePaths();
+  Paths.push_back("/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1");
+  Paths.push_back("/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/lib64");

  for (ToolChain::path_list::const_iterator i = Paths.begin(), e = Paths.end();
       i != e; ++i)
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp	(revision 127872)
+++ lib/Driver/ToolChains.cpp	(working copy)
@@ -1531,6 +1531,7 @@
  Paths.push_back(Base + "/../../..");
  if (Arch == getArch() && IsUbuntu(Distro))
    Paths.push_back("/usr/lib/" + GccTriple);
+  Paths.push_back("/afs/cern.ch/cms/slc5_amd64_gcc451/external/gcc/4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1");
}

bool Linux::HasNativeLLVMSupport() const {





More information about the cfe-dev mailing list