beanz added a comment.

In D62215#1512543 <https://reviews.llvm.org/D62215#1512543>, @winksaville wrote:

> With this error I guessed that I needed to build `LLVMgold.so`, but then I 
> also determined
>  I needed to link everything with `ld.gold` to complete the build process, 
> which is why I
>  uploaded this patch.


The issue is actually that your system linker isn't compatible with LLVM/master 
for LTO, and the LLVM build system doesn't know how to setup linux system 
linkers automatically. We do properly configure ld64, and lld on Linux and 
Windows if you configure to tell LLVM to use LLD.

> Anyway, since you don't seem to like using `ld.gold`

It isn't that I don't "like" gold, it is that gold isn't installed by default 
on most systems, and I'm pretty sure it doesn't exist for Darwin or Win32.

> So I've found a couple hacks that partially work:
> 
> 1. Build `LLVMgold.so` and use `ld.gold`

This is a viable configuration, but cannot be part of the example because it 
isn't portable.

> 2. Don't use LTO

The real underlying issue is that LLVM's build system isn't producing 
reasonable errors for when the system linker doesn't support LTO, and it 
doesn't seem to know how to configure a gold-based LTO bootstrap.

> CMake Warning at 
> /home/wink/prgs/llvm/llvm-project/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake:51
>  (message):
> 
>   Host compiler must support std::atomic!

This is caused by the issue that I'm trying to address in D62155 
<https://reviews.llvm.org/D62155>, and will impact the correctness of the 
runtime libraries you build.

> ninja: error: 
> '/home/wink/prgs/llvm/llvm-project/build-dist-a/tools/clang/stage2-bins/lib/libgtest.a',
>  needed by 
> 'compiler-rt/lib/asan/tests/ASAN_INST_TEST_OBJECTS.gtest-all.cc.x86_64-calls.o',
>  missing and no known rule to make it

This looks like a missing build dependency between the runtime `check` target 
and gtest, which should be easy enough to fix. I'll put up a patch.

I actually really appreciate you trying this out and reporting back with such 
detailed feedback on your experience. Thank you for your patience, and I'm 
sorry if I'm being a bit of a pain.

I think the correct fix for this is to use lld on non-Darwin platforms, and 
that can be done by adding the following code to DistributionExample.cmake:

  if (NOT APPLE)
    set(BOOTSTRAP_LLVM_ENABLE_LLD On CACHE BOOL "")
  endif()

This will force using LLD on non-Darwin builds. This combined with adding 
"libcxxabi" to `LLVM_ENABLE_RUNTIMES` should actually get your build working 
without any further changes (none of the gold stuff should be needed).

Additionally we should probably consider adding better error checking to the 
bootstrap configurations to error out during configuration on some of these 
problems. For example we should be able to verify that when 
`BOOTSTRAP_LLVM_ENABLE_LTO=On` the following things should be true.

- If your host is Windows, in stage 1 you must be building `lld`, and in stage 
2 you must be linking with it
- If your host is Linux, in stage 1 you must be building `lld`, and in stage 2 
you must be linking with it -or- you must build the Gold plugin in stage1 and 
link with `ld.gold` in stage 2.
- If your host is Darwin, you must not be using `lld`




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62215/new/

https://reviews.llvm.org/D62215



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to