diff --git a/pkgs/applications/networking/browsers/chromium/common.nix b/pkgs/applications/networking/browsers/chromium/common.nix index 16ddbbc8cf5..60aca90a95e 100644 --- a/pkgs/applications/networking/browsers/chromium/common.nix +++ b/pkgs/applications/networking/browsers/chromium/common.nix @@ -5,7 +5,7 @@ , libevent, expat, libjpeg, snappy , libpng, libcap , xdg_utils, yasm, nasm, minizip, libwebp -, libusb1, pciutils, nss, re2, zlib +, libusb1, pciutils, nss, re2 , python2Packages, perl, pkgconfig , nspr, systemd, kerberos @@ -46,8 +46,6 @@ buildFun: with stdenv.lib; -# see http://www.linuxfromscratch.org/blfs/view/cvs/xsoft/chromium.html - let jre = jre8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731 @@ -63,7 +61,7 @@ let mkGnFlags = let # Serialize Nix types into GN types according to this document: - # https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/language.md + # https://source.chromium.org/gn/gn/+/master:docs/language.md mkGnString = value: "\"${escape ["\"" "$" "\\"] value}\""; sanitize = value: if value == true then "true" @@ -75,6 +73,7 @@ let toFlag = key: value: "${key}=${sanitize value}"; in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs)); + # https://source.chromium.org/chromium/chromium/src/+/master:build/linux/unbundle/replace_gn_files.py gnSystemLibraries = [ "ffmpeg" "flac" @@ -85,9 +84,6 @@ let "opus" "snappy" "zlib" - # "re2" # fails with linker errors - # "harfbuzz-ng" # in versions over 63 harfbuzz and freetype are being built together - # so we can't build with one from system and other from source ]; opusWithCustomModes = libopus.override { @@ -99,11 +95,9 @@ let libevent expat libjpeg snappy libpng libcap xdg_utils minizip libwebp - libusb1 re2 zlib + libusb1 re2 ffmpeg libxslt libxml2 nasm - # harfbuzz # in versions over 63 harfbuzz and freetype are being built together - # so we can't build with one from system and other from source ]; # build paths and release info @@ -132,6 +126,7 @@ let }; nativeBuildInputs = [ + llvmPackages.lldClang.bintools ninja which python2Packages.python perl pkgconfig python2Packages.ply python2Packages.jinja2 nodejs gnutar python2Packages.setuptools @@ -163,11 +158,24 @@ let ]; postPatch = '' + # remove unused third-party + for lib in ${toString gnSystemLibraries}; do + if [ -d "third_party/$lib" ]; then + find "third_party/$lib" -type f \ + \! -path "third_party/$lib/chromium/*" \ + \! -path "third_party/$lib/google/*" \ + \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \ + \! -regex '.*\.\(gn\|gni\|isolate\)' \ + -delete + fi + done + # Required for patchShebangs (unsupported interpreter directive, basename: invalid option -- '*', etc.): - substituteInPlace native_client/SConstruct \ - --replace "#! -*- python -*-" "" - substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \ - --replace "/usr/bin/env -S make -f" "/usr/bin/make -f" + substituteInPlace native_client/SConstruct --replace "#! -*- python -*-" "" + if [ -e third_party/harfbuzz-ng/src/src/update-unicode-tables.make ]; then + substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \ + --replace "/usr/bin/env -S make -f" "/usr/bin/make -f" + fi # We want to be able to specify where the sandbox is via CHROME_DEVEL_SANDBOX substituteInPlace sandbox/linux/suid/client/setuid_sandbox_host.cc \ @@ -195,48 +203,26 @@ let sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \ gpu/config/gpu_info_collector_linux.cc - sed -i -re 's/([^:])\<(isnan *\()/\1std::\2/g' \ - chrome/browser/ui/webui/engagement/site_engagement_ui.cc - - sed -i -e '/#include/ { - i #include - :l; n; bl - }' gpu/config/gpu_control_list.cc - # Allow to put extensions into the system-path. sed -i -e 's,/usr,/run/current-system/sw,' chrome/common/chrome_paths.cc patchShebangs . # use our own nodejs mkdir -p third_party/node/linux/node-linux-x64/bin - ln -s $(which node) third_party/node/linux/node-linux-x64/bin/node + ln -s "$(command -v node)" third_party/node/linux/node-linux-x64/bin/node + + # Allow building against system libraries in official builds + sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' tools/generate_shim_headers/generate_shim_headers.py - # remove unused third-party - # in third_party/crashpad third_party/zlib contains just a header-adapter - for lib in ${toString gnSystemLibraries}; do - find -type f -path "*third_party/$lib/*" \ - \! -path "*third_party/crashpad/crashpad/third_party/zlib/*" \ - \! -path "*third_party/$lib/chromium/*" \ - \! -path "*third_party/$lib/google/*" \ - \! -path "*base/third_party/icu/*" \ - \! -path "*base/third_party/libevent/*" \ - \! -regex '.*\.\(gn\|gni\|isolate\|py\)' \ - -delete - done '' + optionalString stdenv.isAarch64 '' substituteInPlace build/toolchain/linux/BUILD.gn \ --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""' - '' + optionalString stdenv.cc.isClang '' - mkdir -p third_party/llvm-build/Release+Asserts/bin - ln -s ${stdenv.cc}/bin/clang third_party/llvm-build/Release+Asserts/bin/clang - ln -s ${stdenv.cc}/bin/clang++ third_party/llvm-build/Release+Asserts/bin/clang++ - ln -s ${llvmPackages.llvm}/bin/llvm-ar third_party/llvm-build/Release+Asserts/bin/llvm-ar ''; gnFlags = mkGnFlags ({ - use_lld = false; - use_gold = stdenv.buildPlatform.is64bit; # ld.gold outs-of-memory on i686 - gold_path = "${stdenv.cc}/bin"; + custom_toolchain = "//build/toolchain/linux/unbundle:default"; + host_toolchain = "//build/toolchain/linux/unbundle:default"; + is_official_build = true; is_debug = false; proprietary_codecs = false; @@ -295,8 +281,7 @@ let # This is to ensure expansion of $out. libExecPath="${libExecPath}" - python build/linux/unbundle/replace_gn_files.py \ - --system-libraries ${toString gnSystemLibraries} + python build/linux/unbundle/replace_gn_files.py --system-libraries ${toString gnSystemLibraries} ${gnChromium}/bin/gn gen --args=${escapeShellArg gnFlags} out/Release | tee gn-gen-outputs.txt # Fail if `gn gen` contains a WARNING.