[LLVMdev] cmake/ninja build failing
Seth Cantrell
seth.cantrell at gmail.com
Sat Feb 15 04:47:13 PST 2014
Okay, so after setting COMPILE_OPTIONS properly there was a similar problem with set_target_link_flags. There didn't seem to be a LINK_OPTIONS available so I just manually added quotes when concatenating link flags. Then it turned out that at one point one of the items in the ARGN list of link flags gets added as a single string but is really two items, so I hacked around that by inserting quotes into the string where it's added. With these changes building is successful.
> diff --git cmake/Modules/CompilerRTUtils.cmake cmake/Modules/CompilerRTUtils.cmake
> index fce37e3..a36096a 100644
> --- cmake/Modules/CompilerRTUtils.cmake
> +++ cmake/Modules/CompilerRTUtils.cmake
> @@ -2,15 +2,12 @@
> # define a handy helper function for it. The compile flags setting in CMake
> # has serious issues that make its syntax challenging at best.
> function(set_target_compile_flags target)
> - foreach(arg ${ARGN})
> - set(argstring "${argstring} ${arg}")
> - endforeach()
> - set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
> + set_property(TARGET ${target} PROPERTY COMPILE_OPTIONS "${ARGN}")
> endfunction()
>
> function(set_target_link_flags target)
> foreach(arg ${ARGN})
> - set(argstring "${argstring} ${arg}")
> + set(argstring "${argstring} \"${arg}\"")
> endforeach()
> set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
> endfunction()
> diff --git lib/asan/CMakeLists.txt lib/asan/CMakeLists.txt
> index 64239fe..2c8d385 100644
> --- lib/asan/CMakeLists.txt
> +++ lib/asan/CMakeLists.txt
> @@ -75,7 +75,7 @@ if(APPLE)
> # Dynamic lookup is needed because shadow scale and offset are
> # provided by the instrumented modules.
> set(ASAN_RUNTIME_LDFLAGS
> - "-undefined dynamic_lookup")
> + "-undefined\" \"dynamic_lookup")
> add_compiler_rt_darwin_dynamic_runtime(clang_rt.asan_${os}_dynamic ${os}
> ARCH ${ASAN_SUPPORTED_ARCH}
> SOURCES $<TARGET_OBJECTS:RTAsan.${os}>
Thanks,
Seth
On Feb 13, 2014, at 9:08 AM, Brad King <brad.king at kitware.com> wrote:
> On 2/12/2014 11:15 PM, Seth Cantrell wrote:
>> 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
>
> That's because the set_target_compile_flags function in LLVM is
> creating the space-separated command-line string that the old
> COMPILE_FLAGS option wants:
>
>>> function(set_target_compile_flags target)
>>> foreach(arg ${ARGN})
>>> set(argstring "${argstring} ${arg}")
>>> endforeach()
>>> set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
>>> endfunction()
>
> Try changing the function to just:
>
> function(set_target_compile_flags target)
> set_property(TARGET ${target} PROPERTY COMPILE_OPTIONS "${ARGN}")
> endfunction()
>
> Of course an upstream version of this change would be simpler
> if it just dropped set_target_compile_flags and set the property
> directly at the call sites. One could even use the APPEND option
> of set_property to add options incrementally.
>
> -Brad
More information about the llvm-dev
mailing list