This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Allow finding LLVMConfig if CMAKE_FIND_ROOT_PATH_MODE_PACKAGE is set to ONLY
AcceptedPublic

Authored by kongyi on Mar 18 2023, 1:18 AM.

Details

Summary

MAKE_FIND_ROOT_PATH_MODE_PACKAGE can be set to ONLY for cross compilation. However we need to find LLVMConfig from the host compiler, which is outside of the root path.

Set CMAKE_FIND_ROOT_PATH_BOTH when finding the LLVMConfig package.

Diff Detail

Event Timeline

kongyi created this revision.Mar 18 2023, 1:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2023, 1:18 AM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
kongyi requested review of this revision.Mar 18 2023, 1:18 AM

Do you have a doc link or some precedent? Something to help us understand the implications of this.

Do you have a doc link or some precedent? Something to help us understand the implications of this.

We cross compile compiler-rt for Android, and we set CMAKE_FIND_ROOT_PATH_MODE_* to ONLY to force using the correct sysroots.

https://android.googlesource.com/toolchain/llvm_android/+/cd342d2891d684a29cef85378069ddd5d4bc5ea8/base_builders.py#410

srhines accepted this revision.Mar 20 2023, 12:04 PM

LGTM, but @phosek should also be able to confirm this is ok.

This revision is now accepted and ready to land.Mar 20 2023, 12:04 PM

I still don't understand the motivation behind this change. You already explicitly set CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to ONLY for Android so why do we need to change the default?

I still don't understand the motivation behind this change. You already explicitly set CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to ONLY for Android so why do we need to change the default?

We need to pull the build dependencies from the target root path, thus setting CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to ONLY. However LLVMConfig is different that we need the host version instead, as it records the configs of the host toolchain.

pirama added a subscriber: pirama.May 3 2023, 1:33 PM