This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][cmake] Use HandleOutOfTreeLLVM like libcxx and friends
ClosedPublic

Authored by Ericson2314 on Jan 20 2022, 11:07 AM.

Details

Summary

This gives us the option of using CMake modules from LLVM, and other
things. We will use that to deduplicate code later.

Diff Detail

Event Timeline

Ericson2314 created this revision.Jan 20 2022, 11:07 AM
Ericson2314 requested review of this revision.Jan 20 2022, 11:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2022, 11:07 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
phosek accepted this revision.Jan 20 2022, 12:32 PM

LGTM

This revision is now accepted and ready to land.Jan 20 2022, 12:32 PM

This (according to some bisecting) seems to be breaking the unified tree bots' compiler-rt builds on multiple platforms:

https://lab.llvm.org/buildbot/#/builders/57/builds/14145
https://lab.llvm.org/staging/#/builders/202/builds/483

A copy of the compiler-rt libs is no longer placed in the main build dir, though it seems to still be build in the runtimes subdir:

ld: 0706-005 Cannot find or open file: /scratch/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/lib/clang/14.0.0/lib/aix/libclang_rt.profile-powerpc.a
	ld:open(): No such file or directory
daltenty added a comment.EditedJan 21 2022, 9:01 AM

From the CMake trace, seems this is causing a difference in the setting of COMPILER_RT_OUTPUT_DIR

-/home/daltenty/llvm/dev/llvm-project/compiler-rt/cmake/base-config-ix.cmake(45):  set(COMPILER_RT_OUTPUT_DIR /home/daltenty/llvm/dev/build/runtimes/runtimes-bins/compiler-rt/lib/clang/14.0.0 )
+/home/daltenty/llvm/dev/llvm-project/compiler-rt/cmake/base-config-ix.cmake(45):  set(COMPILER_RT_OUTPUT_DIR /home/daltenty/llvm/dev/build/./lib/clang/14.0.0 )

Seems this is because the new include of HandleOutOfTreeLLVM clobbers LLVM_LIBRARY_OUTPUT_INTDIR which is set explicit by the runtimes CMakeLists.txt:

./runtimes/CMakeLists.txt:80:set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})

The fix direction isn't immediate obvious, if we fix this in HandleOutOfTreeLLVM out of tree it'll potentially affect the rest of the runtimes that were already using HandleOutOfTreeLLVM successfully and hacking compiler-rt only doesn't seem quite right either, so I think a revert is in order until HandleOutOfTreeLLVM can be reworked to avoid this issue.

Thanks @dalteny for investigating. @phosek if you remember https://reviews.llvm.org/rG6e3946c9f558adfddfd98a51721baccd8b17bb85 the TODO you put in there about the compiler-rt build having to be standalone seems related.