@@ -5,7 +5,7 @@
55, libevent, expat, libjpeg, snappy
66, libpng, libcap
77, xdg_utils, yasm, nasm, minizip, libwebp
8−, libusb1, pciutils, nss, re2, zlib
8+, libusb1, pciutils, nss, re2
99
1010, python2Packages, perl, pkgconfig
1111, nspr, systemd, kerberos
@@ -46,8 +46,6 @@ buildFun:
4646
4747with stdenv.lib;
4848
49−# see http://www.linuxfromscratch.org/blfs/view/cvs/xsoft/chromium.html
50−
5149let
5250 jre = jre8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
5351
@@ -63,7 +61,7 @@ let
6361 mkGnFlags =
6462 let
6563 # Serialize Nix types into GN types according to this document:
66− # https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/language.md
64+ # https://source.chromium.org/gn/gn/+/master:docs/language.md
6765 mkGnString = value: "\"${escape ["\"" "$" "\\"] value}\"";
6866 sanitize = value:
6967 if value == true then "true"
@@ -75,6 +73,7 @@ let
7573 toFlag = key: value: "${key}=${sanitize value}";
7674 in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs));
7775
76+ # https://source.chromium.org/chromium/chromium/src/+/master:build/linux/unbundle/replace_gn_files.py
7877 gnSystemLibraries = [
7978 "ffmpeg"
8079 "flac"
@@ -85,9 +84,6 @@ let
8584 "opus"
8685 "snappy"
8786 "zlib"
88− # "re2" # fails with linker errors
89− # "harfbuzz-ng" # in versions over 63 harfbuzz and freetype are being built together
90− # so we can't build with one from system and other from source
9187 ];
9288
9389 opusWithCustomModes = libopus.override {
@@ -99,11 +95,9 @@ let
9995 libevent expat libjpeg snappy
10096 libpng libcap
10197 xdg_utils minizip libwebp
102− libusb1 re2 zlib
98+ libusb1 re2
10399 ffmpeg libxslt libxml2
104100 nasm
105− # harfbuzz # in versions over 63 harfbuzz and freetype are being built together
106− # so we can't build with one from system and other from source
107101 ];
108102
109103 # build paths and release info
@@ -132,6 +126,7 @@ let
132126 };
133127
134128 nativeBuildInputs = [
129+ llvmPackages.lldClang.bintools
135130 ninja which python2Packages.python perl pkgconfig
136131 python2Packages.ply python2Packages.jinja2 nodejs
137132 gnutar python2Packages.setuptools
@@ -163,11 +158,24 @@ let
163158 ];
164159
165160 postPatch = ''
161+ # remove unused third-party
162+ for lib in ${toString gnSystemLibraries}; do
163+ if [ -d "third_party/$lib" ]; then
164+ find "third_party/$lib" -type f \
165+ \! -path "third_party/$lib/chromium/*" \
166+ \! -path "third_party/$lib/google/*" \
167+ \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
168+ \! -regex '.*\.\(gn\|gni\|isolate\)' \
169+ -delete
170+ fi
171+ done
172+
166173 # Required for patchShebangs (unsupported interpreter directive, basename: invalid option -- '*', etc.):
167− substituteInPlace native_client/SConstruct \
168− --replace "#! -*- python -*-" ""
169− substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
170− --replace "/usr/bin/env -S make -f" "/usr/bin/make -f"
174+ substituteInPlace native_client/SConstruct --replace "#! -*- python -*-" ""
175+ if [ -e third_party/harfbuzz-ng/src/src/update-unicode-tables.make ]; then
176+ substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
177+ --replace "/usr/bin/env -S make -f" "/usr/bin/make -f"
178+ fi
171179
172180 # We want to be able to specify where the sandbox is via CHROME_DEVEL_SANDBOX
173181 substituteInPlace sandbox/linux/suid/client/setuid_sandbox_host.cc \
@@ -195,48 +203,26 @@ let
195203 sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
196204 gpu/config/gpu_info_collector_linux.cc
197205
198− sed -i -re 's/([^:])\<(isnan *\()/\1std::\2/g' \
199− chrome/browser/ui/webui/engagement/site_engagement_ui.cc
200−
201− sed -i -e '/#include/ {
202− i #include <algorithm>
203− :l; n; bl
204− }' gpu/config/gpu_control_list.cc
205−
206206 # Allow to put extensions into the system-path.
207207 sed -i -e 's,/usr,/run/current-system/sw,' chrome/common/chrome_paths.cc
208208
209209 patchShebangs .
210210 # use our own nodejs
211211 mkdir -p third_party/node/linux/node-linux-x64/bin
212− ln -s $(which node) third_party/node/linux/node-linux-x64/bin/node
212+ ln -s "$(command -v node)" third_party/node/linux/node-linux-x64/bin/node
213+
214+ # Allow building against system libraries in official builds
215+ sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' tools/generate_shim_headers/generate_shim_headers.py
213216
214− # remove unused third-party
215− # in third_party/crashpad third_party/zlib contains just a header-adapter
216− for lib in ${toString gnSystemLibraries}; do
217− find -type f -path "*third_party/$lib/*" \
218− \! -path "*third_party/crashpad/crashpad/third_party/zlib/*" \
219− \! -path "*third_party/$lib/chromium/*" \
220− \! -path "*third_party/$lib/google/*" \
221− \! -path "*base/third_party/icu/*" \
222− \! -path "*base/third_party/libevent/*" \
223− \! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
224− -delete
225− done
226217 '' + optionalString stdenv.isAarch64 ''
227218 substituteInPlace build/toolchain/linux/BUILD.gn \
228219 --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
229− '' + optionalString stdenv.cc.isClang ''
230− mkdir -p third_party/llvm-build/Release+Asserts/bin
231− ln -s ${stdenv.cc}/bin/clang third_party/llvm-build/Release+Asserts/bin/clang
232− ln -s ${stdenv.cc}/bin/clang++ third_party/llvm-build/Release+Asserts/bin/clang++
233− ln -s ${llvmPackages.llvm}/bin/llvm-ar third_party/llvm-build/Release+Asserts/bin/llvm-ar
234220 '';
235221
236222 gnFlags = mkGnFlags ({
237− use_lld = false;
238− use_gold = stdenv.buildPlatform.is64bit; # ld.gold outs-of-memory on i686
239− gold_path = "${stdenv.cc}/bin";
223+ custom_toolchain = "//build/toolchain/linux/unbundle:default";
224+ host_toolchain = "//build/toolchain/linux/unbundle:default";
225+ is_official_build = true;
240226 is_debug = false;
241227
242228 proprietary_codecs = false;
@@ -295,8 +281,7 @@ let
295281
296282 # This is to ensure expansion of $out.
297283 libExecPath="${libExecPath}"
298− python build/linux/unbundle/replace_gn_files.py \
299− --system-libraries ${toString gnSystemLibraries}
284+ python build/linux/unbundle/replace_gn_files.py --system-libraries ${toString gnSystemLibraries}
300285 ${gnChromium}/bin/gn gen --args=${escapeShellArg gnFlags} out/Release | tee gn-gen-outputs.txt
301286
302287 # Fail if `gn gen` contains a WARNING.