[PATCH] D56836: [mips] Include whole lpthread when using both -pthread and -static

Simon Atanasyan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 17 14:16:56 PST 2019


atanasyan added a comment.

In D56836#1361528 <https://reviews.llvm.org/D56836#1361528>, @abeserminji wrote:

> I am not sure if -static option passed as --cflag to lnt runtest enters the LDFLAGS. I guess it doesn't. 
>  But if there is a way to check which options are passed as --cflags, we might be able to add -Wl, -whole-archive -lpthread -Wl -no-whole-archive only in case when static is used.
>  That would be my preferable option in this situation, but I couldn't find any clues on how to do that.


You are right, LDFLAGS does not contain the `-static`. But if you pass linker options to the CMake by the `CMAKE_EXE_LINKER_FLAGS` variable, the following code should help.

  --- a/SingleSource/UnitTests/C++11/CMakeLists.txt
  +++ b/SingleSource/UnitTests/C++11/CMakeLists.txt
  @@ -1,3 +1,9 @@
   list(APPEND CXXFLAGS -std=c++11 -pthread)
   list(APPEND LDFLAGS -lstdc++ -pthread)
  +
  +file(GLOB Source RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c *.cpp)
  +if(${CMAKE_EXE_LINKER_FLAGS} MATCHES "-static")
  +  list(REMOVE_ITEM Source stdthreadbug.cpp)
  +endif()
  +
   llvm_singlesource()


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56836/new/

https://reviews.llvm.org/D56836





More information about the cfe-commits mailing list