[llvm-dev] (Thin)LTO llvm build

Teresa Johnson via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 27 11:37:32 PDT 2016


On Tue, Sep 27, 2016 at 11:27 AM, Carsten Mattner <carstenmattner at gmail.com>
wrote:

> On Tue, Sep 27, 2016 at 6:33 PM, Teresa Johnson <tejohnson at google.com>
> wrote:
> >
> > I can't reproduce the failure. I am building with a clang built
> >    Release from recent source as my stage-1 bootstrap compiler:
> >    clang version 4.0.0 (trunk 282322) (llvm/trunk 282341)
>
> The clang I use was built from the 3.9 release branch:
> clang version 3.9.1 (branches/release_39 281767)
>
> Is that too old for it to build itself with ThinLTO?
>

I wonder if there is a bug that was fixed. I have bootstrapped with ThinLTO
with the 3.9 compiler, but not with LLDB and not with SHARED_LIBS=ON. I can
try with an older 3.9 version.

>
> > I am configuring the stage-2 bootstrap compiler with the following
> > command, which largely is copied from your earlier email with your
> > cmake command (changes noted below):
> >
> >   lto=Thin
> >   type=Release
> >   cflgs=-w
> >   INSTALL_PREFIX=$HOME/llvm/${build_dir_name}/clang-install
> >   BUILD_COMPILER=$HOME/llvm/llvm_10_release_build
> >   SRC=$HOME/llvm/llvm_head
> >   BINUTILS=$HOME/binutils/binutils
> >   env DYLD_LIBRARY_PATH=$BUILD_COMPILER/lib/ \
> >   cmake \
> >     -G Ninja \
> >     -DCMAKE_BUILD_TYPE=${type} \
> >     -DLLVM_BINUTILS_INCDIR=$BINUTILS/include \
> [...]
> >     -DCMAKE_C_FLAGS=${cflgs} \
> >     -DCMAKE_CXX_FLAGS=${cflgs} \
> >     -DCMAKE_EXE_LINKER_FLAGS=${linkflgs} \
> >     $SRC
>
> Is BUILD_COMPILER/bin the result of a previous non-LTO build of trunk?
>

Yes. The version mentioned at the top: clang version 3.9.1
(branches/release_39 281767)


>
> If any of you have suggestions what to omit from the above flags, I'm
> open to suggestions. This is the culmination of trying to replicate
> the previous autoconf flags. It's not an exact mapping, but almost.
>
> > The changes from your config:
> > 1) Used llvm-ar and llvm-nm from the build compiler. I noticed that
> > you are specifying those as coming from the same directory used for
> > CMAKE_INSTALL_PREFIX, which seems wrong - that is where the compiler
> > built here will be installed.
>
> That's because I'm reusing the previous built 3.9_release (without
> LTO) and I move it away after the build before running ninja install
> to the same location after extending PATH with the locally moved tree
> of the previously installed PREFIX for llvm.
>
> Is that a problem?
>

Not sure I followed that, but in essence you just want to make sure that
llvm-ranlib and llvm-ar match the build compiler.


>
> > 2) Used my own binutils checkout as I don't have plugin-api.h
> > installed in /usr/include
>
> Curious, is your host binutils too old for that to exist in
> /usr/include?
>

I guess - I always use my own version of binutils.


>
> > 3) Set BUILD_SHARED_LIBS=ON (which I don't see in your earlier
> > config, did you add that later?)
>
> What I emailed earlier was the full set of flags passed to cmake, and
> I had just added SHARED_LIBS=OFF as suggested for the next rebuild.
>
> Should I use ON or OFF?
>

I used ON to try to reproduce your issue, the OFF was a suggestion to avoid
it as a workaround. I'm surprised your build defaults this to ON, according
to http://llvm.org/docs/CMake.html it defaults to OFF.


>
> > 4) Set LLVM_PARALLEL_LINK_JOBS=1 (probably not needed)
>
> I'll try this next time, just to see how much of a difference it makes
> when I run with with -j4.
>
> > 5) Build with -w, to avoid occasional issues with warnings only
> > emitted by clang (probably not needed)
> > 6) Specified CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly (you
> > might have had the right versions in your path?)
>
> I've exported CXX and CC to clang++ and clang, which happen to be the
> locally build 3.9 release branch versions (non-LTO variant).
>

Ok


>
> > I did an nm on the .so libraries to see where __morestack was
> > referenced and its linkage. No surprise, it is coming from
> > libLLVMRuntimeDyld.so, and I do see it as weak as expected:
> >
> > $ nm lib/libLLVMRuntimeDyld.so | grep morestack
> >                  w __morestack
> >
> > Can you do the above nm on your lib/libLLVMRuntimeDyld.so and send
> > me the output?
>
> In the unfinished build dir I only have lib/libLLVMRuntimedyld.a.
>

This is from your SHARED_LIBS=OFF build I assume? With the build containing
the DSO error I'm assuming BUILD_SHARED_LIBS=ON, which would mean this
should be a .so.

If this archive is from the build getting the DSO error then I'm confused
about which DSO is giving the error. In that case what does the link line
look like?

Teresa




-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160927/cffca6ea/attachment.html>


More information about the llvm-dev mailing list