@ldionne, after reading the comments in libcxx/cmake/Modules/DefineLinkerScript.cmake
and IF Generator expression evaluates both branches eagerly (#21045) · Issues · CMake / CMake · GitLab, I still think there might be some issue in the creation of the libc++.so
linker script. In the sense that it sometimes emits an “empty” library, so the script becomes INPUT(libc++.so.1 -l)
and linking fails.
I put some debug messages in libcxx/cmake/Modules/DefineLinkerScript.cmake
, and these show:
DBG: interface_libs="cxx-headers;libcxx-abi-shared"
DBG: considering lib="cxx-headers"
DBG: considering lib="libcxx-abi-shared"
DBG: appending libname=="$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,$<TARGET_PROPERTY:$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,libcxx-abi-shared,cxx_shared>,OUTPUT_NAME>,libcxx-abi-shared>"
DBG: link_libraries="-l$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,$<TARGET_PROPERTY:$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,libcxx-abi-shared,cxx_shared>,OUTPUT_NAME>,libcxx-abi-shared>"
DBG: linker_script="INPUT($<TARGET_SONAME_FILE_NAME:cxx_shared> -l$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,$<TARGET_PROPERTY:$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,libcxx-abi-shared,cxx_shared>,OUTPUT_NAME>,libcxx-abi-shared>)"
so for some reason, the expression $<TARGET_SONAME_FILE_NAME:cxx_shared>
is correctly evaluated to libc++.so.1
, but the more complicated expression $<IF:$<TARGET_EXISTS:libcxx-abi-shared>,$<TARGET_PROPERTY:$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,libcxx-abi-shared,cxx_shared>,OUTPUT_NAME>,libcxx-abi-shared>
evaluates to an empty string…