build: link against libLLVM.so if available

readme: better instructions for finding native libc headers
This commit is contained in:
Andrew Kelley 2016-04-30 17:17:59 -07:00
parent d908afe105
commit 037283c3b3
2 changed files with 10 additions and 4 deletions

View File

@ -75,14 +75,14 @@ compromises backward compatibility.
### Debug / Development Build
If you have gcc or clang installed, you can find out what `ZIG_LIBC_LIB_DIR`
and `ZIG_LIBC_STATIC_LIB_DIR` should be set to (example below).
`ZIG_LIBC_INCLUDE_DIR` likely can be set to `/usr/include`.
If you have gcc or clang installed, you can find out what `ZIG_LIBC_LIB_DIR`,
`ZIG_LIBC_STATIC_LIB_DIR`, and `ZIG_LIBC_INCLUDE_DIR` should be set to
(example below).
```
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd) -DZIG_LIBC_LIB_DIR=$(dirname $(cc -print-file-name=crt1.o)) -DZIG_LIBC_INCLUDE_DIR=/usr/include -DZIG_LIBC_STATIC_LIB_DIR=$(dirname $(cc -print-file-name=crtbegin.o))
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd) -DZIG_LIBC_LIB_DIR=$(dirname $(cc -print-file-name=crt1.o)) -DZIG_LIBC_INCLUDE_DIR=$(echo -n | cc -E -x c - -v 2>&1 | grep -B1 "End of search list." | head -n1 | cut -c 2-) -DZIG_LIBC_STATIC_LIB_DIR=$(dirname $(cc -print-file-name=crtbegin.o))
make
make install
./run_tests

View File

@ -29,6 +29,12 @@ execute_process(
OUTPUT_VARIABLE LLVM_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_library(LLVM_LIBRARY NAMES LLVM)
if(LLVM_LIBRARY)
set(LLVM_LIBRARIES ${LLVM_LIBRARY})
endif()
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS})