<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 14, 2015, at 12:28 AM, Justin Bogner <<a href="mailto:mail@justinbogner.com" class="">mail@justinbogner.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Chris Bieneman via llvm-commits <</span><a href="mailto:llvm-commits@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">llvm-commits@lists.llvm.org</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> writes:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">beanz created this revision.<br class="">beanz added a reviewer: Bigcheese.<br class="">beanz added a subscriber: llvm-commits.<br class=""><br class="">Sometimes you want to install a custom compiler and use it like the<br class="">system compiler without overriding the system compiler. This patch<br class="">lets you create xctoolchains that the darwin command line tools can<br class="">use.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">This is really useful. A couple of comments below, but this basically</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">LGTM.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">To use this patch set LLVM_CREATE_XCODE_TOOLCHAIN=On in your CMake<br class="">invocation and build the `install-code-toolchain` target.<br class=""><br class="">After installation you can set the envar EXTERNAL_TOOLCHAINS_DIR to<br class="">your installed Toolchains directory, and the TOOLCHAINS envar to the<br class="">toolchain identifier (ex org.llvm.3.8.0svn). This will then cause<br class="">/usr/bin/clang to call your newly installed clang.<br class=""><br class=""><a href="http://reviews.llvm.org/D13605" class="">http://reviews.llvm.org/D13605</a><br class=""><br class="">Files:<br class=""> tools/xcode-toolchain/CMakeLists.txt<br class=""><br class="">Index: tools/xcode-toolchain/CMakeLists.txt<br class="">===================================================================<br class="">--- /dev/null<br class="">+++ tools/xcode-toolchain/CMakeLists.txt<br class="">@@ -0,0 +1,62 @@<br class="">+# OS X 10.11 El Capitan has just been released. One of the new features, System<br class="">+# Integrity Protection, prevents modifying the base OS install, even with sudo.<br class="">+# This prevents LLVM developers on OS X from being able to easily install new<br class="">+# system compilers. The feature can be disabled, but to make it easier for<br class="">+# developers to work without disabling SIP, this file can generate an Xcode<br class="">+# toolchain. Xcode toolchains are a mostly-undocumented feature that allows<br class="">+# multiple copies of low level tools to be installed to different locations, and<br class="">+# users can easily switch between them.<br class="">+<br class="">+# Setting an environment variable TOOLCHAINS to the toolchain's identifier will<br class="">+# result in /usr/bin/<tool> or xcrun <tool> to find the tool in the toolchain.<br class="">+<br class="">+# To make this work with Xcode 7.1 and later you can install the toolchain this<br class="">+# file generates anywhere on your system and set EXTERNAL_TOOLCHAINS_DIR to the<br class="">+# path specified by $CMAKE_INSTALL_PREFIX/Toolchains<br class="">+<br class="">+# This file generates a custom install-xcode-toolchain target which constructs<br class="">+# and installs a toolchain with the identifier in the pattern:<br class="">+# org.llvm.${PACKAGE_VERSION}. This toolchain can then be used to override the<br class="">+# system compiler by setting TOOLCHAINS=org.llvm.${PACKAGE_VERSION} in the<br class="">+# in the environment.<br class="">+<br class="">+if(NOT APPLE)<br class="">+  return()<br class="">+endif()<br class="">+<br class="">+option(LLVM_CREATE_XCODE_TOOLCHAIN "Create a target to install LLVM into an Xcode toolchain" Off)<br class="">+<br class="">+if(NOT LLVM_CREATE_XCODE_TOOLCHAIN)<br class="">+  return()<br class="">+endif()<br class="">+<br class="">+execute_process(<br class="">+  COMMAND xcodebuild -find clang<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I'd probably use `xcrun -find` rather than `xcodebuild -find`. Not that</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">it makes much of a difference.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>Sure. It doesn’t make any functional difference. If I understand correctly xcrun just calls xcodebuild.</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">+  OUTPUT_VARIABLE clang_path<br class="">+  OUTPUT_STRIP_TRAILING_WHITESPACE<br class="">+  ERROR_FILE /dev/null<br class="">+)<br class="">+string(REGEX MATCH "(.*Toolchains).*" toolchains_match ${clang_path})<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Seems slightly safer/clearer to match "(.*/Toolchains)/.*”</span></div></blockquote><div><br class=""></div><div>Will update.</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">+if(NOT toolchains_match)<br class="">+  message(FATAL_ERROR "Could not identify toolchain dir")<br class="">+endif()<br class="">+set(toolchains_dir ${CMAKE_MATCH_1})<br class="">+<br class="">+set(XcodeDefaultInfo "${toolchains_dir}/XcodeDefault.xctoolchain/ToolchainInfo.plist")<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">What happens if you've already installed the custom toolchain? I guess</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">$toolchains_dir will point to $EXTERNAL_TOOLCHAINS_DIR and this will</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">fail.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>True. I can work around that by changing the xcrun line to look for a tool that won’t reasonably exist in the external toolchain (like otool). Then even if TOOLCHAINS and EXTERNAL_TOOLCHAINS_DIR are set it will find the tool in the XcodeDefault toolchain.</div><div><br class=""></div><div>-Chris</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">+set(LLVMToolchainDir "${CMAKE_INSTALL_PREFIX}/Toolchains/LLVM${PACKAGE_VERSION}.xctoolchain/")<br class="">+<br class="">+add_custom_command(OUTPUT ${LLVMToolchainDir}<br class="">+                    COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVMToolchainDir})<br class="">+<br class="">+add_custom_command(OUTPUT ${LLVMToolchainDir}/ToolchainInfo.plist<br class="">+                  DEPENDS ${LLVMToolchainDir}<br class="">+                  COMMAND ${CMAKE_COMMAND} -E copy "${XcodeDefaultInfo}" "${LLVMToolchainDir}/ToolchainInfo.plist"<br class="">+                  COMMAND /usr/libexec/PlistBuddy -c "Set:Identifier org.llvm.${PACKAGE_VERSION}" "${LLVMToolchainDir}/ToolchainInfo.plist")<br class="">+<br class="">+add_custom_target(install-xcode-toolchain<br class="">+                  DEPENDS ${LLVMToolchainDir}/ToolchainInfo.plist<br class="">+                  COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target all<br class="">+                  COMMAND "${CMAKE_COMMAND}"<br class="">+                          -DCMAKE_INSTALL_PREFIX=${LLVMToolchainDir}/usr/<br class="">+                          -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"<br class="">+                  ${cmake_3_2_USES_TERMINAL})</blockquote></div></blockquote></div><br class=""></body></html>