Tune CMakeLists for out-of-tree build. Adjust for API discrepancies between Apple clang-8.0.0 and upstream LLVM 5.0.1. Allow all clients to link against the library, not just ld. Main reason: Our ld is called ld64 when we link it. --- tapi-2.0.0/tools/tapi/CMakeLists.txt.orig 2017-12-25 22:36:06.620886714 +0100 +++ tapi-2.0.0/tools/tapi/CMakeLists.txt 2017-12-25 22:41:43.867893060 +0100 @@ -6,6 +6,12 @@ target_link_libraries(tapi tapiDriver + clangAST + clangFrontend + LLVMOption + LLVMDemangle + LLVMSupport + LLVMCore ) if (TAPI_BUILD_LIBIOSSDK) --- tapi-2.0.0/tools/libtapi/CMakeLists.txt.orig 2017-12-25 22:26:06.816905789 +0100 +++ tapi-2.0.0/tools/libtapi/CMakeLists.txt 2017-12-25 22:31:22.914862289 +0100 @@ -1,4 +1,7 @@ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libtapi.exports) +set(LLVM_LINK_COMPONENTS + Support + ) add_tapi_library(libtapi SHARED @@ -19,5 +22,5 @@ set_property(TARGET libtapi APPEND_STRING PROPERTY - LINK_FLAGS " -current_version ${TAPI_FULL_VERSION} -compatibility_version 1 -allowable_client ld" + LINK_FLAGS " -current_version ${TAPI_FULL_VERSION} -compatibility_version 1" ) --- tapi-2.0.0/tools/tapi-run/CMakeLists.txt.orig 2017-12-26 15:12:39.605057352 +0100 +++ tapi-2.0.0/tools/tapi-run/CMakeLists.txt 2017-12-26 15:15:53.304983942 +0100 @@ -5,6 +5,8 @@ target_link_libraries(tapi-run tapiCore libtapi + LLVMSupport + LLVMCore ) set_property(TARGET tapi-run APPEND_STRING --- tapi-2.0.0/CMakeLists.txt.orig 2017-12-24 15:27:56.000000000 +0100 +++ tapi-2.0.0/CMakeLists.txt 2017-12-26 15:50:01.199506782 +0100 @@ -4,6 +4,24 @@ message(FATAL_ERROR "Unsupported configuration.") endif() +project(tapi) +set(PACKAGE_VENDOR Apple CACHE STRING "") +add_definitions(-DTAPI_BUG_REPORT_URL="https://bugs.gentoo.org/") + +find_package(LLVM REQUIRED CONFIG) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) +include(AddLLVM) + +add_definitions(${LLVM_DEFINITIONS}) +include_directories(${LLVM_INCLUDE_DIRS} ${OBJCMETADATA_INCLUDE_DIRS}) +link_directories(${LLVM_LIBRARY_DIRS} ${OBJCMETADATA_LIBRARY_DIRS}) + +# make tblgen happy +include(TableGen) +foreach(IPATH ${LLVM_INCLUDE_DIRS}) + list(APPEND LLVM_TABLEGEN_FLAGS -I ${IPATH}) +endforeach(IPATH) + set(TAPI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(TAPI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) --- tapi-2.0.0/lib/Core/MachODylibReader.cpp.orig 2017-12-24 15:27:56.000000000 +0100 +++ tapi-2.0.0/lib/Core/MachODylibReader.cpp 2017-12-25 22:15:53.075478606 +0100 @@ -254,8 +254,7 @@ auto arch = getArchType(H.cputype, H.cpusubtype); assert(arch != Architecture::unknown && "unknown architecture slice"); - Error error = Error::success(); - for (const auto &symbol : object->exports(error)) { + for (const auto &symbol : object->exports()) { StringRef name; XPIKind kind; std::tie(name, kind) = parseSymbol(symbol.name()); @@ -272,7 +271,7 @@ file->addSymbol(kind, name, arch, flags); } - return error; + return Error::success(); } static Error readUndefinedSymbols(MachOObjectFile *object, @@ -309,10 +308,7 @@ auto H = object->getHeader(); auto arch = getArchType(H.cputype, H.cpusubtype); - auto error = Error::success(); - MachOMetadata metadata(object, error); - if (error) - return std::move(error); + MachOMetadata metadata(object); /// /// Classes --- tapi-2.0.0/lib/Driver/Snapshot.cpp.orig 2017-12-24 15:27:56.000000000 +0100 +++ tapi-2.0.0/lib/Driver/Snapshot.cpp 2017-12-26 15:49:09.864184826 +0100 @@ -14,7 +14,7 @@ #include "tapi/Defines.h" #include "clang/Frontend/FrontendOptions.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/Config/config.h" +#include "llvm/Config/llvm-config.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/xxhash.h" @@ -356,7 +356,7 @@ } if (isCrash) { - outs() << "PLEASE submit a bug report to " BUG_REPORT_URL + outs() << "PLEASE submit a bug report to " TAPI_BUG_REPORT_URL " and include the " "crash backtrace and snapshot.\n\n" "********************************************************\n\n" --- tapi-2.0.0/lib/Driver/Options.cpp.orig 2017-12-25 22:17:40.506874748 +0100 +++ tapi-2.0.0/lib/Driver/Options.cpp 2017-12-25 22:18:04.181989766 +0100 @@ -1023,7 +1023,7 @@ table->PrintHelp( outs(), (programName + " " + getNameFromTAPICommand(command)).str().c_str(), - toolName, /*FlagsToInclude=*/getIncludeOptionFlagMasks(command), + toolName, /*FlagsToInclude=*///getIncludeOptionFlagMasks(command), /*FlagsToExclude=*/0, /*ShowAllAliases=*/false); }