update cmake, update readme, in response to the dynamic linking fiasco

This commit is contained in:
Andrew Kelley 2020-04-17 18:41:21 -04:00
parent c026a9f6d2
commit 986aa42d3e
3 changed files with 199 additions and 186 deletions

View file

@ -58,10 +58,16 @@ brew install cmake llvm
brew outdated llvm || brew upgrade llvm
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) -DZIG_PREFER_CLANG_CPP_DYLIB=ON
cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm)
make install
```
You will now run into this issue:
[homebrew and llvm 10 packages in apt.llvm.org are broken with undefined reference to getPollyPluginInfo](https://github.com/ziglang/zig/issues/4799)
Please help upstream LLVM and Homebrew solve this issue, there is nothing Zig
can do about it. See that issue for a workaround you can do in the meantime.
##### Windows
See https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows

View file

@ -18,7 +18,7 @@ find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h
)
if(ZIG_PREFER_CLANG_CPP_DYLIB)
find_library(CLANG_CPP_DYLIB
find_library(CLANG_LIBRARIES
NAMES
clang-cpp-10.0
clang-cpp100
@ -31,9 +31,7 @@ if(ZIG_PREFER_CLANG_CPP_DYLIB)
)
endif()
if(CLANG_CPP_DYLIB)
set(CLANG_LIBRARIES ${CLANG_CPP_DYLIB})
else()
if(NOT CLANG_LIBRARIES)
macro(FIND_AND_ADD_CLANG_LIB _libname_)
string(TOUPPER ${_libname_} _prettylibname_)
find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_}

View file

@ -7,7 +7,30 @@
# LLVM_LIBRARIES
# LLVM_LIBDIRS
if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
find_path(LLVM_INCLUDE_DIRS NAMES llvm/IR/IRBuilder.h
PATHS
/usr/lib/llvm/10/include
/usr/lib/llvm-10/include
/usr/lib/llvm-10.0/include
/usr/local/llvm10/include
/usr/local/llvm100/include
/mingw64/include
)
if(ZIG_PREFER_CLANG_CPP_DYLIB)
find_library(LLVM_LIBRARIES
NAMES
LLVM-10.0
LLVM-10
LLVM-100
LLVM
PATHS
${LLVM_LIBDIRS}
/usr/lib/llvm-10/lib
/usr/local/llvm10/lib
/usr/local/llvm100/lib
)
elseif("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
find_program(LLVM_CONFIG_EXE
NAMES llvm-config-10 llvm-config-10.0 llvm-config100 llvm-config10 llvm-config
PATHS
@ -106,11 +129,6 @@ if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
endif()
execute_process(
COMMAND ${LLVM_CONFIG_EXE} --includedir
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS})
if(NOT LLVM_LIBRARIES)
@ -124,15 +142,6 @@ else()
# to support more complicated setups. We also assume the experimental target
# AVR is enabled.
find_path(LLVM_INCLUDE_DIRS NAMES llvm/IR/IRBuilder.h
PATHS
/usr/lib/llvm/10/include
/usr/lib/llvm-10/include
/usr/lib/llvm-10.0/include
/usr/local/llvm100/include
/usr/local/llvm10/include
/mingw64/include)
macro(FIND_AND_ADD_LLVM_LIB _libname_)
string(TOUPPER ${_libname_} _prettylibname_)
find_library(LLVM_${_prettylibname_}_LIB NAMES ${_libname_}