[libcxx-commits] [PATCH] D68343: [libc++] Move the linker script generation step to CMake

Petr Hosek via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 7 17:35:49 PDT 2019


phosek added a comment.

In D68343#1697634 <https://reviews.llvm.org/D68343#1697634>, @ldionne wrote:

> It turns out that @EricWF was the one to originally write the script, so maybe he knows why the output is
>
>   INPUT(libc++.so.1 -lunwind -lc++abi)
>
>
> instead of
>
>   INPUT(libc++.so.1 -lpthread -lc <etc...> -lunwind -lc++abi)
>


In case of shared libraries, the libpthread and libc dependency is already encoded in the shared library itself (e.g. in case of ELF it'd be as `DT_NEEDED` entries), specifying them in the linker script is not necessary and in many cases undesirable (e.g. if your application doesn't use any threading API, you probably don't want to get implicit `DT_NEEDED` dependency on libpthread just because you're linking libc++). Where it'd make sense is for static libraries, but we don't currently generate linker script for those.



================
Comment at: libcxx/cmake/Modules/DefineLinkerScript.cmake:46
+    COMMAND "${CMAKE_COMMAND}" -E remove "${symlink}"
+    COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script}" > "${symlink}"
+    COMMENT "Generating linker script: '${linker_script}' as file ${symlink}"
----------------
Would the file redirect (`>`) work on Windows as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68343





More information about the libcxx-commits mailing list