@@ -22,7 +22,7 @@
2222, ffmpegSupport ? true
2323, gtk3Support ? true, gtk2, gtk3, wrapGAppsHook
2424, waylandSupport ? true, libxkbcommon
25−, ltoSupport ? true, overrideCC, buildPackages
25+, ltoSupport ? stdenv.isLinux, overrideCC, buildPackages
2626, gssSupport ? true, kerberos
2727, pipewireSupport ? waylandSupport && webrtcSupport, pipewire
2828
@@ -72,6 +72,7 @@
7272
7373assert stdenv.cc.libc or null != null;
7474assert pipewireSupport -> !waylandSupport || !webrtcSupport -> throw "pipewireSupport requires both wayland and webrtc support.";
75+assert ltoSupport -> stdenv.isDarwin -> throw "LTO is broken on Darwin (see PR#19312).";
7576
7677let
7778 flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")];
@@ -88,8 +89,14 @@ let
8889 then "/Applications/${binaryNameCapitalized}.app/Contents/MacOS"
8990 else "/bin";
9091
91− llvmPackages = buildPackages.llvmPackages_10;
92+ # Darwin's stdenv provides the default llvmPackages version, match that since
93+ # clang LTO on Darwin is broken so the stdenv is not being changed.
94+ llvmPackages = if stdenv.isDarwin
95+ then buildPackages.llvmPackages
96+ else buildPackages.llvmPackages_10;
9297
98+ # When LTO for Darwin is fixed, the following will need updating as lld
99+ # doesn't work on it. For now it is fine since ltoSupport implies no Darwin.
93100 buildStdenv = if ltoSupport
94101 then overrideCC stdenv llvmPackages.lldClang
95102 else stdenv;
@@ -256,7 +263,7 @@ buildStdenv.mkDerivation ({
256263 # LTO is done using clang and lld on Linux.
257264 # Darwin needs to use the default linker as lld is not supported (yet?):
258265 # https://bugzilla.mozilla.org/show_bug.cgi?id=1538724
259− # elf-hack is broken when using clang:
266+ # elf-hack is broken when using clang+lld:
260267 # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204
261268 ++ lib.optionals ltoSupport [
262269 "--enable-lto"