1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
{ lib, stdenv, fetchFromGitHub, symlinkJoin, xcbuildHook, tcsh, libobjc, libtapi, libunwind, llvm, memstreamHook, xar }:
let
cctools = stdenv.mkDerivation rec {
pname = "cctools";
version = "973.0.1";
src = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "cctools";
rev = "${pname}-${version}";
hash = "sha256-0NlDqy3zeg4D0MbDipx0sMYDfzYa63Jxfsckzz/928o=";
};
patches = [
./cctools-add-missing-vtool-libstuff-dep.patch
];
postPatch = ''
for file in libstuff/writeout.c misc/libtool.c misc/lipo.c; do
substituteInPlace "$file" \
--replace '__builtin_available(macOS 10.12, *)' '0'
done
substituteInPlace libmacho/swap.c \
--replace '#ifndef RLD' '#if 1'
'';
nativeBuildInputs = [ xcbuildHook memstreamHook ];
buildInputs = [ libobjc llvm ];
xcbuildFlags = [
"MACOSX_DEPLOYMENT_TARGET=10.12"
];
doCheck = true;
checkPhase = ''
runHook preCheck
Products/Release/libstuff_test
rm Products/Release/libstuff_test
runHook postCheck
'';
installPhase = ''
runHook preInstall
rm -rf "$out/usr"
mkdir -p "$out/bin"
find Products/Release -maxdepth 1 -type f -perm 755 -exec cp {} "$out/bin/" \;
cp -r include "$out/"
ln -s ./nm-classic "$out"/bin/nm
ln -s ./otool-classic "$out"/bin/otool
runHook postInstall
'';
};
ld64 = stdenv.mkDerivation rec {
pname = "ld64";
version = "609";
src = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "ld64";
rev = "${pname}-${version}";
hash = "sha256-WAaphem6NS4eCHL/pISlDXnO1CDYTgSrVGzcothh4/Q=";
};
postPatch = ''
substituteInPlace ld64.xcodeproj/project.pbxproj \
--replace "/bin/csh" "${tcsh}/bin/tcsh" \
--replace 'F9E8D4BE07FCAF2A00FD5801 /* PBXBuildRule */,' "" \
--replace 'F9E8D4BD07FCAF2000FD5801 /* PBXBuildRule */,' ""
sed -i src/ld/Options.cpp -e '1iconst char ldVersionString[] = "${version}";'
'';
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [
libtapi
libunwind
llvm
xar
];
installPhase = ''
runHook preInstall
mkdir -p "$out/bin"
find Products/Release-assert -maxdepth 1 -type f -perm 755 -exec cp {} "$out/bin/" \;
runHook postInstall
'';
};
in
symlinkJoin rec {
name = "cctools-${version}";
version = "${cctools.version}-${ld64.version}";
paths = [
cctools
ld64
];
# workaround for the fetch-tarballs script
passthru = {
inherit (cctools) src;
ld64_src = ld64.src;
};
meta = with lib; {
description = "MacOS Compiler Tools";
homepage = "http://www.opensource.apple.com/source/cctools/";
license = licenses.apple-psl20;
platforms = platforms.darwin;
};
}
|