A couple of llvm sub-projects have been failing to build for me for a while (compiler-rt asan and util/unittests, at least). It turns out to be due to the fact that some paths on my system include spaces and other special characters, but the the build.ninja file was not generated with correctly quoted strings. Specifically I'm on OS X and the command is setting -isysroot to a location inside the Xcode.app, but Xcode is installed at a path which includes spaces and parentheses. I see the problem in the build.ninja commands, where FLAGS includes the problematic setting of isysroot. The cause seems to come down to the line in the compiler-rt CMakeLists.txt:> set(DARWIN_iossim_CFLAGS > -mios-simulator-version-min=7.0 -isysroot ${IOSSIM_SDK_DIR})where IOSSIM_SDK_DIR is the path including spaces and parens. I'm not sure why these flags are finding their way into my build since I'm not doing anything with iOS or the iOS simulator, but DARWIN_iossim_CFLAGS is getting set based on "if(APPLE)", and for some reason the iOS CFLAGS are making their way into the build.ninja file. Simply deleting the cmake commands setting these iOS related variables fixes my build errors but since I don't know why these variables are used on OS X in the first place I can't say if removing them this way is the correct solution, or if maybe the CMakeLists.txt files just needs to properly quote these strings. Here's my shortened version of that whole `if(APPLE)` block:> if(APPLE) > set(SANITIZER_COMMON_SUPPORTED_DARWIN_OS osx) > > if(COMPILER_RT_USES_LIBCXX) > set(SANITIZER_MIN_OSX_VERSION 10.7) > else() > set(SANITIZER_MIN_OSX_VERSION 10.6) > endif() > set(DARWIN_osx_CFLAGS -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}) > set(DARWIN_osx_LINKFLAGS) > endif()So, can anyone who's familiar with CMakeLists.txt comment on the correct way to fix CMakeLists.txt and/or the generated build.ninja? Thanks, Seth
On 02/12/2014 02:04 AM, Seth Cantrell wrote:>> set(DARWIN_iossim_CFLAGS >> -mios-simulator-version-min=7.0 -isysroot ${IOSSIM_SDK_DIR}) > > where IOSSIM_SDK_DIR is the path including spaces and parens.It looks like the _CFLAGS values are used in the module cmake/Modules/CompilerRTUtils.cmake: function(set_target_compile_flags target) foreach(arg ${ARGN}) set(argstring "${argstring} ${arg}") endforeach() set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}") endfunction() but that makes no attempt to escape or quote anything. The COMPILE_FLAGS target property was a very early CMake feature and is treated as a raw string to put on the command line. That is why it needs manual escaping. CMake 2.8.12 added the COMPILE_OPTIONS property and supporting command: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:COMPILE_OPTIONS http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:target_compile_options The property holds a ;-list of options to be passed to the compiler. CMake handles conversion to a command-line string with all needed escaping. -Brad
Well, I updated to cmake 2.8.12.2 but the result of changing that COMPILE_FLAGS to COMPILE_OPTIONS is that quotes are applied incorrectly: quotes are added surrounding the entire set of flags rather than around each individual item in the list. Obviously the build doesn't work (with the compiler looking for files named " -m64 ... ") but checking the relevant build command in build.ninja at least shows me that the relevant path is indeed getting added via set_target_compile_flags: the path is now part of one of these quoted strings. On Feb 12, 2014, at 11:01 AM, Brad King <brad.king at kitware.com> wrote:> On 02/12/2014 02:04 AM, Seth Cantrell wrote: >>> set(DARWIN_iossim_CFLAGS >>> -mios-simulator-version-min=7.0 -isysroot ${IOSSIM_SDK_DIR}) >> >> where IOSSIM_SDK_DIR is the path including spaces and parens. > > It looks like the _CFLAGS values are used in the module > cmake/Modules/CompilerRTUtils.cmake: > > function(set_target_compile_flags target) > foreach(arg ${ARGN}) > set(argstring "${argstring} ${arg}") > endforeach() > set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}") > endfunction() > > but that makes no attempt to escape or quote anything. > > The COMPILE_FLAGS target property was a very early CMake feature > and is treated as a raw string to put on the command line. That > is why it needs manual escaping. > > CMake 2.8.12 added the COMPILE_OPTIONS property and supporting command: > > http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:COMPILE_OPTIONS > http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:target_compile_options > > The property holds a ;-list of options to be passed to the compiler. > CMake handles conversion to a command-line string with all needed > escaping. > > -Brad >
Maybe Matching Threads
- [LLVMdev] cmake/ninja build failing
- [LLVMdev] llvm trunk build failed in cmake_install.cmake on ARM platform
- [LLVMdev] [Compiler-rt] i386 is not supported in compiler-rt build
- Is it really valid to discard externally instantiated functions from a TU when marked inline?
- [LLVMdev] [RFC] Passing Options to Different Parts of the Compiler Using Attributes