2021-05-28 09:39:13 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, pkgsBuildBuild, cmake, python3, ncurses }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
stdenv.mkDerivation {
|
2020-11-12 09:05:59 +00:00
|
|
|
pname = "libtapi";
|
2021-01-15 22:18:51 +00:00
|
|
|
version = "1100.0.11"; # determined by looking at VERSION.txt
|
2020-11-12 09:05:59 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "tpoechtrager";
|
|
|
|
repo = "apple-libtapi";
|
2021-01-15 22:18:51 +00:00
|
|
|
rev = "664b8414f89612f2dfd35a9b679c345aa5389026";
|
|
|
|
sha256 = "1y1yl46msabfy14z0rln333a06087bk14f5h7q1cdawn8nmvbdbr";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
sourceRoot = "source/src/llvm";
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
# 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
|
2022-10-30 15:09:59 +00:00
|
|
|
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
2021-05-28 09:39:13 +00:00
|
|
|
# TODO: make unconditional and rebuild the world
|
|
|
|
# TODO: send upstream
|
|
|
|
./native-clang-tblgen.patch
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ cmake python3 ];
|
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
# ncurses is required here to avoid a reference to bootstrap-tools, which is
|
|
|
|
# not allowed for the stdenv.
|
|
|
|
buildInputs = [ ncurses ];
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ]
|
2022-10-30 15:09:59 +00:00
|
|
|
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
|
2021-05-28 09:39:13 +00:00
|
|
|
"-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;
|
2022-10-21 18:38:19 +00:00
|
|
|
nativeLibcxxabi = lib.getLib pkgsBuildBuild.libcxxabi;
|
2021-05-28 09:39:13 +00:00
|
|
|
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"
|
2022-10-21 18:38:19 +00:00
|
|
|
"-DCMAKE_EXE_LINKER_FLAGS=-L${nativeLibcxxabi}/lib"
|
|
|
|
"-DCMAKE_SHARED_LINKER_FLAGS=-L${nativeLibcxxabi}/lib"
|
2021-05-28 09:39:13 +00:00
|
|
|
];
|
|
|
|
in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}"
|
|
|
|
)
|
|
|
|
];
|
2020-10-16 20:44:37 +00:00
|
|
|
|
|
|
|
# fixes: fatal error: 'clang/Basic/Diagnostic.h' file not found
|
|
|
|
# adapted from upstream
|
|
|
|
# https://github.com/tpoechtrager/apple-libtapi/blob/3cb307764cc5f1856c8a23bbdf3eb49dfc6bea48/build.sh#L58-L60
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
2020-10-16 20:44:37 +00:00
|
|
|
INCLUDE_FIX="-I $PWD/projects/clang/include"
|
|
|
|
INCLUDE_FIX+=" -I $PWD/build/projects/clang/include"
|
|
|
|
|
|
|
|
cmakeFlagsArray+=(-DCMAKE_CXX_FLAGS="$INCLUDE_FIX")
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
buildFlags = [ "clangBasic" "libtapi" "tapi" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
installTargets = [ "install-libtapi" "install-tapi-headers" "install-tapi" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2020-11-12 09:05:59 +00:00
|
|
|
description = "Replaces the Mach-O Dynamic Library Stub files in Apple's SDKs to reduce the size";
|
|
|
|
homepage = "https://github.com/tpoechtrager/apple-libtapi";
|
2023-07-15 17:15:38 +00:00
|
|
|
license = licenses.ncsa;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ matthewbauer ];
|
|
|
|
};
|
|
|
|
}
|