3
0
Fork 0
forked from mirrors/nixpkgs

libtapi: cross compilation

This commit is contained in:
Andrew Childs 2020-11-19 16:50:49 +09:00
parent b7abec31d4
commit eb8f8afac7
3 changed files with 68 additions and 7 deletions

View file

@ -1,6 +1,6 @@
{ lib, stdenv, fetchFromGitHub, cmake, python3, ncurses }:
{ lib, stdenv, fetchFromGitHub, pkgsBuildBuild, cmake, python3, ncurses }:
stdenv.mkDerivation rec {
stdenv.mkDerivation {
pname = "libtapi";
version = "1100.0.11"; # determined by looking at VERSION.txt
@ -13,13 +13,43 @@ stdenv.mkDerivation rec {
sourceRoot = "source/src/llvm";
# Backported from newer llvm, fixes configure error when cross compiling.
# Also means we don't have to manually fix the result with install_name_tool.
patches = [
./disable-rpath.patch
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
# TODO: make unconditional and rebuild the world
# TODO: send upstream
./native-clang-tblgen.patch
];
nativeBuildInputs = [ cmake python3 ];
# ncurses is required here to avoid a reference to bootstrap-tools, which is
# not allowed for the stdenv.
buildInputs = [ ncurses ];
cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ];
cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ]
++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
# This package could probably have a llvm_6 llvm-tblgen and clang-tblgen
# provided to reduce some building. This package seems intended to
# include all of its dependencies, including enough of LLVM to build the
# required tablegens.
(
let
nativeCC = pkgsBuildBuild.stdenv.cc;
nativeBintools = nativeCC.bintools.bintools;
nativeToolchainFlags = [
"-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
"-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
"-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
"-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
"-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
];
in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}"
)
];
# fixes: fatal error: 'clang/Basic/Diagnostic.h' file not found
# adapted from upstream
@ -35,10 +65,6 @@ stdenv.mkDerivation rec {
installTargets = [ "install-libtapi" "install-tapi-headers" "install-tapi" ];
postInstall = lib.optionalString stdenv.isDarwin ''
install_name_tool -id $out/lib/libtapi.dylib $out/lib/libtapi.dylib
'';
meta = with lib; {
description = "Replaces the Mach-O Dynamic Library Stub files in Apple's SDKs to reduce the size";
homepage = "https://github.com/tpoechtrager/apple-libtapi";

View file

@ -0,0 +1,14 @@
diff --git a/src/llvm/cmake/modules/AddLLVM.cmake b/src/llvm/cmake/modules/AddLLVM.cmake
index a53016eb0..b65e608a4 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -1683,8 +1683,7 @@ function(llvm_setup_rpath name)
endif()
if (APPLE)
- set(_install_name_dir INSTALL_NAME_DIR "@rpath")
- set(_install_rpath "@loader_path/../lib" ${extra_libdir})
+ set(_install_name_dir)
elseif(UNIX)
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")

View file

@ -0,0 +1,21 @@
diffprojects/libtapi/CMakeLists.txt b/src/llvm/projects/libtapi/CMakeLists.txt
index 8ee6d8138..8277be147 100644
--- a/projects/libtapi/CMakeLists.txt
+++ b/projects/libtapi/CMakeLists.txt
@@ -193,7 +193,15 @@ if (NOT DEFINED CLANG_VERSION)
set(CLANG_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
endif ()
if (NOT DEFINED CLANG_TABLEGEN_EXE)
- set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen")
+ if(LLVM_USE_HOST_TOOLS)
+ if (NOT CMAKE_CONFIGURATION_TYPES)
+ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/bin/clang-tblgen")
+ else()
+ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/Release/bin/clang-tblgen")
+ endif()
+ else()
+ set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen")
+ endif ()
endif ()
# Include must go first.