clang++ invoking custom built gold

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

clang++ invoking custom built gold

Giulio Eulisse
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 {


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang++ invoking custom built gold

Rafael Espíndola
On 11-03-21 07:08 AM, Giulio Eulisse wrote:

> 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.

You have to detect your distro and then pass the correct search path to
gold.

Cheers,
Rafael
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang++ invoking custom built gold

Giulio Eulisse
Ciao,

> You have to detect your distro and then pass the correct search path to
> gold.

I think I did not express myself well. We do not use the linker / compiler which comes from the distribution, but we have our own which can be even be user installed and which can be installed on a large variety of distributions (albeit we do have a reference one).

Are you saying I should detect the location of the gold binary and work the needed paths from there? Would you accept in upstream a patch which does so?

Ciao,
Giulio


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang++ invoking custom built gold

Rafael Espíndola
On 11-03-21 04:05 PM, Giulio Eulisse wrote:

> Ciao,
>
>> You have to detect your distro and then pass the correct search
>> path to gold.
>
> I think I did not express myself well. We do not use the linker /
> compiler which comes from the distribution, but we have our own which
> can be even be user installed and which can be installed on a large
> variety of distributions (albeit we do have a reference one).
>
> Are you saying I should detect the location of the gold binary and
> work the needed paths from there? Would you accept in upstream a
> patch which does so?

Finding gold itself should not be a problem, we search the path
(starting with where clang is).

The problem you are having with crtbeginS.o not being found is because
the library path being passed to the linker being wrong, not the linker
not being found.

> Ciao, Giulio
>

Cheers,
Rafael
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev