This is an archive of the discontinued LLVM Phabricator instance.

[cmake] [libcxx] Fix find_path() problems when cross compiling.
ClosedPublic

Authored by hintonda on Dec 28 2017, 9:33 PM.

Details

Summary

When CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, cmake
recommends setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
globally which means find_path() always prepends CMAKE_SYSROOT or
CMAKE_FIND_ROOT_PATH to all paths used in the search.

However, this find_path() invocation is looking for a path in the
libcxxabi project on the host system, not the target system,
which can be done by passing NO_CMAKE_FIND_ROOT_PATH.

Diff Detail

Repository
rL LLVM

Event Timeline

hintonda created this revision.Dec 28 2017, 9:33 PM
hintonda retitled this revision from [cmake] Fix path and flag problems when cross compiling. to [cmake] [libcxxabi] Fix path and flag problems when cross compiling..Dec 28 2017, 9:36 PM
hintonda retitled this revision from [cmake] [libcxxabi] Fix path and flag problems when cross compiling. to [cmake] [libcxx] Fix path and flag problems when cross compiling..

Similar to the libc++abi wrt find_path. The CMAKE_REQUIRED_FLAGS handling LGTM.

compnerd requested changes to this revision.Dec 29 2017, 3:34 PM
This revision now requires changes to proceed.Dec 29 2017, 3:34 PM

Would it be possible to split the CMAKE_REQUIRED_FLAGS fix into a separate change since it's unrelated to the CMAKE_FIND_ROOT_PATH bit?

Would it be possible to split the CMAKE_REQUIRED_FLAGS fix into a separate change since it's unrelated to the CMAKE_FIND_ROOT_PATH bit?

Sure, but both are needed to actually work. This fixes cross compiling across systems, e.g., from Darwin to Linux. Without both, configuration will fail.

Please note, cross system compiling also requires a pending patch to cmake: https://gitlab.kitware.com/cmake/cmake/merge_requests/1620

hintonda added a comment.EditedDec 29 2017, 4:20 PM

Btw, here's the WIP toolchain file I"m using, which might help clear up why these changes is necessary:

https://github.com/donhinton/misc/blob/master/cmake/linux-toolchain.cmake

hintonda updated this revision to Diff 130820.Jan 21 2018, 11:57 AM
  • Save CMAKE_REQUIRED_FLAGS for another patch.
hintonda retitled this revision from [cmake] [libcxx] Fix path and flag problems when cross compiling. to [cmake] [libcxx] Fix find_path() problems when cross compiling..Jan 22 2018, 10:45 AM
hintonda edited the summary of this revision. (Show Details)
hintonda edited the summary of this revision. (Show Details)Jan 22 2018, 10:50 AM
This revision was not accepted when it landed; it landed in state Needs Review.Jan 22 2018, 11:28 AM
This revision was automatically updated to reflect the committed changes.