[LLVMdev] Building llvm from source with clang instead of gcc

Justin Holewinski justin.holewinski at gmail.com
Sun Jan 6 10:53:18 PST 2013


On Sun, Jan 6, 2013 at 1:36 PM, Óscar Fuentes <ofv at wanadoo.es> wrote:

> Edward Diener <eldlistmailingz at tropicsoft.com> writes:
>
> >> Clang will attempt to use your installed system libraries, usually
> >> libstdc++ and glibc on a Linux distribution.  We could probably maintain
> >> a libstdc++ compatibility table that says clang x.y is compatible with
> >> libstdc++ up to z.w.  In the vast majority of cases, this just works if
> >> you install a somewhat-newer version of clang.  The problems arise when
> >> you use an older clang with a newer libstdc++ (e.g. newer gcc and/or
> >> linux distribution).
> >
> > This is what evidently happens. A clang binary distribution gets
> > created for a particular Linux distro but there is no compatibility in
> > the package which states that it only works with some version of
> > libstdc++ or glibc or earlier. Then a later version of gcc gets
> > installed and with it a later version of libstdc++ and glibc as a
> > dependency. Now the binary version of clang no longer works on that
> > system because of the updates to the C/C++ standard library.
>
> Then, the package system of your Linux distribution is broken. Or the
> package containing the Clang binaries does not correctly state its
> dependencies.
>

This should only really be a problem for rolling-release distributions like
Arch.  For others, even if gcc is updated, the system libstdc++ probably
won't be for compatibility reasons.


>
> [snip]
>
> >> Generally, it is recommended to bootstrap clang:
> >>
> >> 1. Build llvm/clang with system gcc
> >> 2. Build llvm/clang with new clang
> >> 3. Install new clang somewhere (which will automatically use system
> >> libstdc++/glibc).
> >>
> >> This should solve your problem.
>
> [I think Justin's recipe is overkill, but whatever]
>

Sure, you can just build with system gcc and be done with it.  Though being
a C++ program itself, building clang successful should give you some
reassurance that it will work for other C++ programs.


>
> > OK, this sounds good. Can this process not be explained on the clang
> > Getting Started page for those who are building clang from source. I
> > am not sure how step 3) is supposed to go. Do I just copy the built
> > bin directory somewhere else and then put it first in my PATH, before
> > running llvm/configure ?
>
> You can install on a temporary directory or directly use the newly
> created clang binaries, setting the environment variables CC and CXX
> with full paths like this:
>
> CC=/path/to/clang CXX=/path/to/clang++ configure [configure options] &&
> make
>
> Changing the PATH should work, but remeber to undo the change
> afterwards.
>
> > Or is "Install new clang" more complicated than that ?
>
> It is simply `sudo make install' (which installs on system-level default
> directories.) You can also install on a custom directory, using the
> parameter `--prefix=' in the `configure' invocation.
>
> > Originally I thought I could have both an earlier binary version of
> > clang as well as the latest built version of clang in a Linux distro
> > so that I could test code on both for compatibility of my library for
> > end-users. But with the fairly common breakage of the binary version
> > package of clang when libstdc++/glibc gets updated, this has become
> > much less of a reality.
>
> See above. You can have as much Clang versions as you please. Just be
> sure to not uninstall the required gcc version for each Clang version.
>

Does clang still maintain a hard-coded list of search-paths for GCC
versions?


>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130106/4f65f23f/attachment.html>


More information about the llvm-dev mailing list