From ee81ef8a578736eca2e5d24e6c7ad0ccfd75ca1d Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Tue, 30 Mar 2021 00:43:37 +0300 Subject: [PATCH] Fix memory usage when linking with is_official_build=true, initial support of building with debuginfo, but debugsource subpackage is still empty --- chromium-browser-stable.spec | 54 ++++++++++++++++++++++++++++++------ fix-debugsource.patch | 16 +++++++++++ rpmlint-wrapper.sh | 27 ++++++++++++++++++ 3 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 fix-debugsource.patch create mode 100755 rpmlint-wrapper.sh diff --git a/chromium-browser-stable.spec b/chromium-browser-stable.spec index 08316dd..fdeaa0e 100644 --- a/chromium-browser-stable.spec +++ b/chromium-browser-stable.spec @@ -10,21 +10,31 @@ # Get the version number of latest stable version # $ curl -s 'https://omahaproxy.appspot.com/all?os=linux&channel=stable' | sed 1d | cut -d , -f 3 -%define debug_package %{nil} - %ifarch %{x86_64} %ix86 %bcond_without gost %else %bcond_with gost %endif +# Gold linker +# http://a3f.at/lists/linkers +%bcond_with gold + +# Linker is out of memory on 32 bit with -g2 +# XXX debugsource package is empty, probably there are odd compiler flags +# TODO: fix building with debuginfo +%bcond_with debug + +%if %{without debug} +%define debug_package %{nil} +%endif + # eol 'fix' corrupts some .bin %define dont_fix_eol 1 %define _disable_lto 1 %define crname chromium-browser %define _crdir %{_libdir}/%{crname} -%define _src %{_topdir}/SOURCES %define ffmpeg 1 %define icu 0 @@ -61,10 +71,13 @@ # Chromium build scripts are not compatible with Python 3 yet %define __python %{__python2} +# workaround rpmlint bugs (?) +%global _build_pkgcheck_set /bin/sh %{_sourcedir}/rpmlint-wrapper.sh %{_build_pkgcheck_set} + Summary: A fast web browser based on the Blink engine Name: chromium-browser-stable Version: 89.0.4389.90 -Release: 1 +Release: 3 License: BSD, LGPL Group: Networking/WWW Url: https://www.chromium.org/Home @@ -72,6 +85,7 @@ Source0: https://commondatastorage.googleapis.com/chromium-browser-official/chro Source1: chromium-wrapper Source2: %{crname}.desktop Source10: %{name}.rpmlintrc +Source11: rpmlint-wrapper.sh # Bring xcb-proto with us (might need more than python on EPEL?) Source20: https://www.x.org/releases/individual/proto/xcb-proto-%{xcb_version}.tar.xz Source30: master_preferences @@ -139,6 +153,8 @@ Patch644: enable-vaapi-on-linux.diff # https://github.com/saiarcot895/chromium-ubuntu-build/blob/master/debian/patches/vdpau-support.patch Patch645: vdpau-support.patch Patch646: ALT-allow-to-override-clang-through-env-variables.patch +# XXX This patch is not enough to fully fix debuginfo and debugsource subpackages +Patch647: fix-debugsource.patch BuildRequires: bison BuildRequires: llvm11 @@ -360,6 +376,7 @@ cp -f %{_gostsourcedir}/src/msspi/third_party/cprocsp/include/* third_party/bori %patch644 -p1 %patch645 -p1 %patch646 -p1 +%patch647 -p1 # fatal error: 'fuzzer/FuzzedDataProvider.h' file not found # (Available in Clang10) @@ -425,11 +442,16 @@ export PYTHONPATH="../../third_party/pyjson5/src:../../xcb-proto-%{xcb_version}" %define is_widevine false %endif -%define lld 1 -%if 0%{lld} -%define linker_params use_gold=false use_lld=true -%else +%if %{with gold} %define linker_params use_gold=true use_lld=false +%else +%define linker_params use_gold=false use_lld=true +%endif + +%if %{with debug} +%define symbol_level 2 +%else +%define symbol_level 0 %endif %if %{without bundled_llvm} @@ -460,6 +482,8 @@ export PYTHONPATH="../../third_party/pyjson5/src:../../xcb-proto-%{xcb_version}" %define gn_config use_sysroot=false \ %{target_cpu} \ is_official_build=true \ + symbol_level=%{symbol_level} \ + strip_debug_info=false \ system_libdir="%{_lib}" \ icu_use_data_file=true \ enable_nacl=false \ @@ -550,6 +574,20 @@ CXXFLAGS="-nostdinc++ \ " \ %{__python} tools/gn/bootstrap/bootstrap.py --gn-gen-args='%{gn_config}' unset LDFLAGS CXXFLAGS + +# Reduce memory usage by linker +%ifarch %{ix86} +%if %{with gold} +# https://lwn.net/Articles/797303/ +export LDFLAGS="-Wl,--no-map-whole-files -Wl,--no-keep-memory -Wl,--no-keep-files-mapped -Wl,--no-mmap-output-file" +sed -i -e 's/--threads/--no-threads/' -e '/--thread-count=4/d' build/config/compiler/BUILD.gn +%else +# Try to reduce memory usage by ld.lld. Multi threads are enabled by default. +# XXX Will it reduce it? It is not really needed, lld does not get out of memory without it, at least without debuginfo. +export LDFLAGS="-Wl,--threads=1" +%endif +%endif + out/Release/gn gen --script-executable=%{__python} --args='%{gn_config}' out/Release pushd out/Release diff --git a/fix-debugsource.patch b/fix-debugsource.patch new file mode 100644 index 0000000..b5b09ed --- /dev/null +++ b/fix-debugsource.patch @@ -0,0 +1,16 @@ +Off -fdebug-compilation-dir to generate debugsource RPM package + +Make the condition which adds those flags always false for us. + +// mikhailnov, 23.03.2021 +--- a/build/config/compiler/BUILD.gn.orig 2021-03-14 05:19:49.661818000 +0300 ++++ b/build/config/compiler/BUILD.gn 2021-03-22 21:23:36.664972000 +0300 +@@ -1134,7 +1134,7 @@ + } + + # Makes builds independent of absolute file path. +- if (is_clang && strip_absolute_paths_from_debug_symbols) { ++ if (is_clang && is_win) { + # If debug option is given, clang includes $cwd in debug info by default. + # For such build, this flag generates reproducible obj files even we use + # different build directory like "out/feature_a" and "out/feature_b" if diff --git a/rpmlint-wrapper.sh b/rpmlint-wrapper.sh new file mode 100755 index 0000000..485f62e --- /dev/null +++ b/rpmlint-wrapper.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# rpmlint crashes when checking debuginfo/debugsource subpackages of chromium: + +# 3 packages and 0 specfiles checked; 43 errors, 67 warnings. +# Traceback (most recent call last): +# File "/usr/bin/rpmlint", line 380, in +# main() +# File "/usr/bin/rpmlint", line 172, in main +# runChecks(pkg) +# File "/usr/bin/rpmlint", line 228, in runChecks +# check.check(pkg) +# File "/usr/share/rpmlint/AbstractCheck.py", line 51, in check +# return self.check_binary(pkg) +# File "/usr/share/rpmlint/DistributionCheck.py", line 40, in check_binary +# for fname in pkg.files(): +# File "/usr/share/rpmlint/Pkg.py", line 633, in files +# self._gatherFilesInfo() +# File "/usr/share/rpmlint/Pkg.py", line 718, in _gatherFilesInfo +# pkgfile.size = sizes[idx] +# IndexError: list index out of range + +# For now workaround it by skipping debugsource and debuginfo packages + +# DEBUG: Executing "/usr/bin/rpmlint -f /builddir/build/SOURCES/chromium-browser-stable.rpmlintrc /builddir/build/RPMS/chromium-browser-stable-89.0.4389.90-3-rosa2019.1.aarch64.rpm /builddir/build/RPMS/chromedriver-89.0.4389.90-3-rosa2019.1.aarch64.rpm /builddir/build/RPMS/chromium-browser-stable-debugsource-89.0.4389.90-3-rosa2019.1.aarch64.rpm /builddir/build/RPMS/chromium-browser-stable-debuginfo-89.0.4389.90-3-rosa2019.1.aarch64.rpm /builddir/build/RPMS/chromedriver-debuginfo-89.0.4389.90-3-rosa2019.1.aarch64.rpm ": + +eval $(echo "$*" | tr ' ' '\n' | grep -vE '\-debugsource\-|\-debuginfo\-' | tr '\n' ' ')