[PATCH] D21478: [build] Link main executable with libpthread

Guilherme Amadio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 23 09:10:39 PST 2017


amadio added inline comments.


================
Comment at: llvm/trunk/tools/llvm-config/CMakeLists.txt:22
+      # Otherwise assume it's a library name we need to link with.
+      set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
+    endif()
----------------
When building against system ZLIB, `${l}` here resolves to `/usr/lib/libz.so`, which then causes the error below:

```
/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -l/usr/lib/libz.so
collect2: error: ld returned 1 exit status
```
The symptom is visible in `tools/llvm-config/BuildVariables.inc`, where I see the following line:
```
#define LLVM_SYSTEM_LIBS "-lrt -ldl -lcurses -lpthread -l/usr/lib/libz.so -lm"
```
The correct way to link against zlib since CMake 3.1 is to use the target `ZLIB::ZLIB` defined in [FindZLIB.cmake](https://cmake.org/cmake/help/v3.1/module/FindZLIB.html) that comes with CMake.


Repository:
  rL LLVM

https://reviews.llvm.org/D21478





More information about the llvm-commits mailing list