libtapi: cross compilation

+68 -7
+33 -7
pkgs/os-specific/darwin/libtapi/default.nix
··· 1 - { lib, stdenv, fetchFromGitHub, cmake, python3, ncurses }: 1 + { lib, stdenv, fetchFromGitHub, pkgsBuildBuild, cmake, python3, ncurses }: 2 2 3 - stdenv.mkDerivation rec { 3 + stdenv.mkDerivation { 4 4 pname = "libtapi"; 5 5 version = "1100.0.11"; # determined by looking at VERSION.txt 6 6 ··· 13 13 14 14 sourceRoot = "source/src/llvm"; 15 15 16 + # Backported from newer llvm, fixes configure error when cross compiling. 17 + # Also means we don't have to manually fix the result with install_name_tool. 18 + patches = [ 19 + ./disable-rpath.patch 20 + ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ 21 + # TODO: make unconditional and rebuild the world 22 + # TODO: send upstream 23 + ./native-clang-tblgen.patch 24 + ]; 25 + 16 26 nativeBuildInputs = [ cmake python3 ]; 17 27 18 28 # ncurses is required here to avoid a reference to bootstrap-tools, which is 19 29 # not allowed for the stdenv. 20 30 buildInputs = [ ncurses ]; 21 31 22 - cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ]; 32 + cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ] 33 + ++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) [ 34 + "-DCMAKE_CROSSCOMPILING=True" 35 + # This package could probably have a llvm_6 llvm-tblgen and clang-tblgen 36 + # provided to reduce some building. This package seems intended to 37 + # include all of its dependencies, including enough of LLVM to build the 38 + # required tablegens. 39 + ( 40 + let 41 + nativeCC = pkgsBuildBuild.stdenv.cc; 42 + nativeBintools = nativeCC.bintools.bintools; 43 + nativeToolchainFlags = [ 44 + "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc" 45 + "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++" 46 + "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar" 47 + "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip" 48 + "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib" 49 + ]; 50 + in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}" 51 + ) 52 + ]; 23 53 24 54 # fixes: fatal error: 'clang/Basic/Diagnostic.h' file not found 25 55 # adapted from upstream ··· 34 64 buildFlags = [ "clangBasic" "libtapi" "tapi" ]; 35 65 36 66 installTargets = [ "install-libtapi" "install-tapi-headers" "install-tapi" ]; 37 - 38 - postInstall = lib.optionalString stdenv.isDarwin '' 39 - install_name_tool -id $out/lib/libtapi.dylib $out/lib/libtapi.dylib 40 - ''; 41 67 42 68 meta = with lib; { 43 69 description = "Replaces the Mach-O Dynamic Library Stub files in Apple's SDKs to reduce the size";
+14
pkgs/os-specific/darwin/libtapi/disable-rpath.patch
··· 1 + diff --git a/src/llvm/cmake/modules/AddLLVM.cmake b/src/llvm/cmake/modules/AddLLVM.cmake 2 + index a53016eb0..b65e608a4 100644 3 + --- a/cmake/modules/AddLLVM.cmake 4 + +++ b/cmake/modules/AddLLVM.cmake 5 + @@ -1683,8 +1683,7 @@ function(llvm_setup_rpath name) 6 + endif() 7 + 8 + if (APPLE) 9 + - set(_install_name_dir INSTALL_NAME_DIR "@rpath") 10 + - set(_install_rpath "@loader_path/../lib" ${extra_libdir}) 11 + + set(_install_name_dir) 12 + elseif(UNIX) 13 + set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) 14 + if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
+21
pkgs/os-specific/darwin/libtapi/native-clang-tblgen.patch
··· 1 + diffprojects/libtapi/CMakeLists.txt b/src/llvm/projects/libtapi/CMakeLists.txt 2 + index 8ee6d8138..8277be147 100644 3 + --- a/projects/libtapi/CMakeLists.txt 4 + +++ b/projects/libtapi/CMakeLists.txt 5 + @@ -193,7 +193,15 @@ if (NOT DEFINED CLANG_VERSION) 6 + set(CLANG_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}") 7 + endif () 8 + if (NOT DEFINED CLANG_TABLEGEN_EXE) 9 + - set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen") 10 + + if(LLVM_USE_HOST_TOOLS) 11 + + if (NOT CMAKE_CONFIGURATION_TYPES) 12 + + set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/bin/clang-tblgen") 13 + + else() 14 + + set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/Release/bin/clang-tblgen") 15 + + endif() 16 + + else() 17 + + set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen") 18 + + endif () 19 + endif () 20 + 21 + # Include must go first.