tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
build2: use lld from llvm 16 to link on darwin
Theodore Ni
2 years ago
ee4f1fe1
a3b43106
+26
3 changed files
expand all
collapse all
unified
split
pkgs
development
tools
build-managers
build2
bootstrap.nix
default.nix
setup-hook.sh
+10
pkgs/development/tools/build-managers/build2/bootstrap.nix
···
1
1
{ lib, stdenv
2
2
, fetchurl
3
3
, pkgs
4
4
+
, buildPackages
4
5
, fixDarwinDylibNames
5
6
}:
6
7
stdenv.mkDerivation rec {
···
25
26
26
27
propagatedBuildInputs = lib.optionals stdenv.targetPlatform.isDarwin [
27
28
fixDarwinDylibNames
29
29
+
30
30
+
# Build2 needs to use lld on Darwin because it creates thin archives when it detects `llvm-ar`,
31
31
+
# which ld64 does not support.
32
32
+
(lib.getBin buildPackages.llvmPackages_16.lld)
28
33
];
29
34
30
35
doCheck = true;
···
38
43
runHook preInstall
39
44
install -D build2/b-boot $out/bin/b
40
45
runHook postInstall
46
46
+
'';
47
47
+
48
48
+
postFixup = ''
49
49
+
substituteInPlace $out/nix-support/setup-hook \
50
50
+
--subst-var-by isTargetDarwin '${toString stdenv.targetPlatform.isDarwin}'
41
51
'';
42
52
43
53
inherit (pkgs.build2) passthru;
+10
pkgs/development/tools/build-managers/build2/default.nix
···
4
4
, fixDarwinDylibNames
5
5
, libbutl
6
6
, libpkgconf
7
7
+
, buildPackages
7
8
, enableShared ? !stdenv.hostPlatform.isStatic
8
9
, enableStatic ? !enableShared
9
10
}:
···
57
58
# LC_LOAD_DYLIB entries containing @rpath, requiring manual fixup
58
59
propagatedBuildInputs = lib.optionals stdenv.targetPlatform.isDarwin [
59
60
fixDarwinDylibNames
61
61
+
62
62
+
# Build2 needs to use lld on Darwin because it creates thin archives when it detects `llvm-ar`,
63
63
+
# which ld64 does not support.
64
64
+
(lib.getBin buildPackages.llvmPackages_16.lld)
60
65
];
61
66
62
67
postPatch = ''
···
71
76
72
77
postInstall = lib.optionalString stdenv.isDarwin ''
73
78
install_name_tool -add_rpath "''${!outputLib}/lib" "''${!outputBin}/bin/b"
79
79
+
'';
80
80
+
81
81
+
postFixup = ''
82
82
+
substituteInPlace $dev/nix-support/setup-hook \
83
83
+
--subst-var-by isTargetDarwin '${toString stdenv.targetPlatform.isDarwin}'
74
84
'';
75
85
76
86
passthru = {
+6
pkgs/development/tools/build-managers/build2/setup-hook.sh
···
19
19
$build2ConfigureFlags "${build2ConfigureFlagsArray[@]}"
20
20
)
21
21
22
22
+
if [ -n "@isTargetDarwin@" ]; then
23
23
+
flagsArray+=("config.bin.ld=ld64-lld")
24
24
+
flagsArray+=("config.cc.loptions+=-fuse-ld=lld")
25
25
+
flagsArray+=("config.cc.loptions+=-headerpad_max_install_names")
26
26
+
fi
27
27
+
22
28
echo 'configure flags' "${flagsArray[@]}"
23
29
24
30
b configure "${flagsArray[@]}"