Page MenuHomePhabricator

Fix lld detection in standalone compiler-rt.

Authored by eugenis on Oct 18 2019, 2:33 PM.



Right now all hwasan tests on Android are silently disabled because they
require "has_lld" and standalone compiler-rt can not (and AFAIK was
never able to) set it.

Diff Detail

Event Timeline

eugenis created this revision.Oct 18 2019, 2:33 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 18 2019, 2:33 PM
Herald added subscribers: Restricted Project, mgorny, dberris. · View Herald Transcript
eugenis marked an inline comment as done.Oct 18 2019, 2:37 PM

As it turns out, hwasan has not been tested on Android for the past two months.
It was broken by this change (which went in without code review, btw, not cool):

The change may look trivial, but nothing in CMake ever is.

Now, this can not go in right now, because, naturally, most of the stuff we have committed over the past two months does not pass on Android.
It looks like it is almost all Peter.
One thing that I've noticed is that __hwasan_personality_wrapper has neither extern"C" or public visibility, so it is not exported from the shared runtime library.


I believe all the stuff above this line is necessary for non-standalone case, when the linker flag check would run before the linker itself is built.

pcc added inline comments.Oct 18 2019, 3:17 PM

Shouldn't this be ${COMPILER_RT_HAS_FUSE_LD_LLD_FLAG}?

dyung added a comment.Oct 18 2019, 3:22 PM

Sorry for breaking this, I thought the change would be trivial, guess it was not. From what I can remember, Peter's change was causing our internal testing to break because we don't build/use LLD for our platform.

eugenis updated this revision to Diff 225704.Oct 18 2019, 3:23 PM
eugenis marked an inline comment as done.

Add missing ${}


It definitely should!

pcc accepted this revision.Oct 18 2019, 3:30 PM


This revision is now accepted and ready to land.Oct 18 2019, 3:30 PM
dyung accepted this revision.Oct 21 2019, 10:59 AM

I tried applying this to our internal sources and it worked, so LGTM as well.

I've applied a workaround for the last remaining regression in r375471.
Time to land this change.

This revision was automatically updated to reflect the committed changes.

This appears to have broken the standalone compiler-rt build:

CMake Error at /b/sanitizer-x86_64-linux/build/llvm_build64/lib/cmake/llvm/AddLLVM.cmake:1422 (add_dependencies):
  The dependency target "lld" of target "check-compiler-rt" does not exist.
Call Stack (most recent call first):
  test/CMakeLists.txt:86 (add_lit_target)

CMake Error at /b/sanitizer-x86_64-linux/build/llvm_build64/lib/cmake/llvm/AddLLVM.cmake:1422 (add_dependencies):
  The dependency target "lld" of target "check-ubsan" does not exist.
Call Stack (most recent call first):
  /b/sanitizer-x86_64-linux/build/llvm_build64/lib/cmake/llvm/AddLLVM.cmake:1443 (add_lit_target)
  test/ubsan/CMakeLists.txt:131 (add_lit_testsuite)

CMake Error at /b/sanitizer-x86_64-linux/build/llvm_build64/lib/cmake/llvm/AddLLVM.cmake:1422 (add_dependencies):
  The dependency target "lld" of target "check-msan" does not exist.
Call Stack (most recent call first):
  /b/sanitizer-x86_64-linux/build/llvm_build64/lib/cmake/llvm/AddLLVM.cmake:1443 (add_lit_target)
  test/msan/CMakeLists.txt:56 (add_lit_testsuite)

I've just taken over buildbot monitoring duty and it looks like our is still failing even with the latest fix.

I can reproduce on an x86_64 machine. It looks like specific problem is when the compiler has -fuse-ld=lld, but lld is not in the LLVM_ENABLE_PROJECTS list. If I add it then the cmake step will complete.

CC=/path/to/clang CXX=/path/to/clang++ \
  cmake -GNinja ../../llvm \
      -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \

Can you take a look?

Hi Peter, it appears that I've missed some of the compiler-rt subprojects. This commit should fix it: