<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div>I'm working on cross-compiling llvm and sub-projects to dynamically build Clang toolchain and associated libraries for an embedded project.</div><div><br></div><div>I'm starting with this mailing list, as I see the pattern using "config-ix.cmake" a common one; it's found in all the sub-projects.</div><div></div><div><br></div><div>For those that are not aware, in CMake the standard approach for dealing with unique toolchains, system roots, etc is through the use of  a CMAKE_TOOLCHAIN_FILE variable.  This toolchain file is used to define the compiler, system type, architecture, sysroot, etc.  It enables a simpler, and more versatile build script.<br></div><div><br></div><div>With tip of the tree on llvm and sub-projects now, when I use a toolchain file, I'm finding I have to make edits to the config-ix.cmake files.  The issue is related to re-defining CMAKE_SYSROOT and the use of; among others:</div><div><br></div><div>    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")</div></div><div dir="ltr"><br></div><div>When this flag is used in stand-alone cross-compiled builds (using toolchain file to set the CMAKE_SYSROOT), it causes all the subsequent flag checks to fail.<br></div><div><br></div><div>I think leveraging an implied CMake toolchain file for sub-projects should be the preferred solution for "projects", and it's a fairly minor change to accommodate.<br></div><div></div></div><div dir="ltr"><br><div>Stand-alone cross-compiled example for libunwind, compiler-rt, libcxxabi, and libcxx here (This config requires edits to the associated config-ix.cmake files for this to work):</div><div><br></div><div>    <a href="https://github.com/jwinarske/flutter_embedded">https://github.com/jwinarske/flutter_embedded</a></div><div><br></div><br></div><div dir="ltr">Perhaps there is already a working solution to cross-compile the sub-projects from a single build invocation now?  I found when cross-compiling compiler-rt as part of the Clang build, it fails due to sysroot issues.  Something which the CMake toolchain file scenario would cleanly solve.  The end goal being, when I set the list LLVM_TARGETS_TO_BUILD to desired targets, one could expect cross-compiled bits (as applicable) for each sub-project.  This would greatly simplify building a toolchain config.<br><div><br></div><div>Perhaps I'm not clear on the current solution, and this already does what is needed for stand-alone cross-compiling?  Until convinced otherwise, I think there is room for improvement here, and am willing to donate time to address it.</div><div><br></div><div><br></div>Cheers,<br></div><div dir="ltr"><div>Joel Winarske<br></div></div></div></div>