[PATCH] D43168: Don't use -ldl on BSD
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 12 09:39:22 PST 2018
MatzeB added a comment.
The CMAKE_DL_LIBS change LGTM.
> and while we are here, also use CMake's FindThreads module and CMAKE_THREAD_LIBS_INIT
Note that there are a bunch more places in the test-suite that just use -pthread instead of `$(CMAKE_THREAD_LIBS_INIT)` so now we are inconsistent...
In https://reviews.llvm.org/D43168#1004539, @dim wrote:
> It looks like test-suite has some sort of special handling for test executables, where it uses LDFLAGS instead of target_link_libraries():
>
> # Creates a new executable build target. Use this instead of `add_executable`.
> # It applies CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS. Creates a .test file if
> # necessary, registers the target with the TEST_SUITE_TARGETS list and makes
> # sure we build the required dependencies for compiletime measurements
> # and support the TEST_SUITE_PROFILE_USE mode.
> macro(llvm_test_executable target)
> add_executable(${target} ${ARGN})
> append_target_flags(COMPILE_FLAGS ${target} ${CFLAGS})
> append_target_flags(COMPILE_FLAGS ${target} ${CPPFLAGS})
> append_target_flags(COMPILE_FLAGS ${target} ${CXXFLAGS})
> # Note that we cannot use target_link_libraries() here because that one
> # only interprets inputs starting with '-' as flags.
> append_target_flags(LINK_LIBRARIES ${target} ${LDFLAGS})
>
>
> I am unsure what the reason is that `add_executable` and `target_link_libraries` cannot be used. So maybe there is an easy way in CMake to transform a list of libraries in the form of e.g. `CMAKE_DL_LIBS` to linker flags? Or must we do that manually with some sort of for loop?
I think I did this because annoyingly `target_link_libraries()` interprets everything not starting with a `-` as a library name so it failed for `-Xlinker -stack_size -Xlinker 0x800000` :-/
Repository:
rL LLVM
https://reviews.llvm.org/D43168
More information about the llvm-commits
mailing list