Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable LTO for chromium #127

Open
Hello71 opened this issue Jun 23, 2018 · 92 comments
Open

enable LTO for chromium #127

Hello71 opened this issue Jun 23, 2018 · 92 comments

Comments

@Hello71
Copy link
Contributor

Hello71 commented Jun 23, 2018

it is enabled for official builds upstream since 2016, but Gentoo does not use it, even if -flto is specified.

@wolfwood
Copy link
Contributor

wolfwood commented Jun 25, 2018

I've been building successfully with USE custom-cflags, which should disable the flag stripping, although I haven't verified that LTO is being enabled

@InBetweenNames
Copy link
Owner

Anyone willing to do a PR? I don't use Chromium myself and I remember it took forever to compile.

@wolfwood
Copy link
Contributor

@InBetweenNames is there a way to confirm a binary has been LTO'd or do you look at the build logs?

@InBetweenNames
Copy link
Owner

InBetweenNames commented Jun 27, 2018

I just look at the build logs, however if there are any static libraries, you can objdump them to see if there are any GIMPLE symbols in the output. Example from sys-devel/flex:

>qfile /usr/lib64/libfl.a
...
libyywrap.o:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    d  .text  0000000000000000 .text
0000000000000000 l    d  .data  0000000000000000 .data
0000000000000000 l    d  .bss   0000000000000000 .bss
0000000000000000 l    d  .gnu.lto_.profile.2caf6e470d364625     0000000000000000 .gnu.lto_.profile.2caf6e470d364625
0000000000000000 l    d  .gnu.lto_.icf.2caf6e470d364625 0000000000000000 .gnu.lto_.icf.2caf6e470d364625
0000000000000000 l    d  .gnu.lto_.jmpfuncs.2caf6e470d364625    0000000000000000 .gnu.lto_.jmpfuncs.2caf6e470d364625
...
...

The .gnu.lto_. part is the GIMPLE from GCC. However, shared objects won't have any GIMPLE associated with them, so executables and .so files won't look any different.

@Hello71
Copy link
Contributor Author

Hello71 commented Jun 27, 2018

but if they're unstripped and you're lucky you can find LTO function fragments.

@Hello71
Copy link
Contributor Author

Hello71 commented Sep 23, 2018

  1. install sys-devel/lld
  2. set EXTRA_GN="thin_lto_enable_optimizations=true use_lld=true use_thin_lto=true"

alternatively, simply:

  1. set sys-devel/chromium USE=custom-cflags

@Hello71
Copy link
Contributor Author

Hello71 commented Oct 12, 2018

OK, I finally built it successfully. this does work. note that it significantly increases CPU, RAM, and disk usage during build. it (very very approximately) doubles each of these.

@InBetweenNames
Copy link
Owner

@Hello71, were you able to just use custom-cflags or did it require more in-depth workarounds?

@Hello71
Copy link
Contributor Author

Hello71 commented Oct 14, 2018

I didn't use custom-cflags, I used the gn options. I assume this is better supported upstream.

@funghetto
Copy link
Contributor

Ye I opened a bug report about that sever months ago because I noticed that in benchmark Chromium compiled in gentoo was slower than binary Chrome or Arch linux Chromium.
The problems are that you should use latest clang, LLD and do an official_build or enable the LTO flags, also with LTO it takes much longer and you'll probably need a very strong/server machine, at least 16GB of ram.

I also tried to compile Chromium with GCC using fedora's patches but it was even slower in benchmarks.

@sjnewbury
Copy link

@funghetto How much slower, and what was slower, JS? I only compile Chromium with GCC and have had no issue with performance with custom cflags.

@funghetto
Copy link
Contributor

I've used mainly Speedometer (https://browserbench.org/Speedometer2.0/) and there was like a 15%-20% performance drop there.

@mateuszmandera
Copy link

USE=custom-cflags compilation works for me by changing the compiler to clang, linker to lld and changing -flto=n (which isn't a valid option in clang) to -flto. Is that something to make a PR for, or do we avoid replacing gcc with clang (since I haven't seen this as something suggested anywhere nor noticed such workarounds)? @InBetweenNames

@ms178
Copy link

ms178 commented Dec 23, 2018

While it is not about Chromium but Firefox, there is a great blog post of a GCC developer with some interesting data points on the Clang vs. GCC debate: http://hubicka.blogspot.com/2018/12/firefox-64-built-with-gcc-and-clang.html

@ionenwks
Copy link

While it is not about Chromium but Firefox, there is a great blog post of a GCC developer with some interesting data points on the Clang vs. GCC debate: http://hubicka.blogspot.com/2018/12/firefox-64-built-with-gcc-and-clang.html

For Firefox at this point I've given up and switched to clang+lto+pgo mostly because it's more tested (being default). Firefox source code has a decent amount of ambiguous code that easily breaks with many optimizations from one version to the next and it's often subtle issues rather than a segfault, and most are long-standing known issues that aren't getting fixed anytime soon, only gcc 6 is officially supported too.

Shame the ebuild doesn't have a flag for pgo right now though, but it's just about setting MOZ_PGO=1.

Even if gcc+lto+pgo performs better, I'm not sure I want to deal with this anymore unless it gets some official support effort.

@ms178
Copy link

ms178 commented Dec 24, 2018

In the short term, you can use his binary instead. :)

I have uploaded a binary build with GCC 8, with link-time optimization and profile feedback. If your curiosity exceeds the fear of running random binaries from the net, you are welcome to try it out. It is built from Firefox 64 release. You can compare it to the official build and build provided by your favourite distro.

@perfect7gentleman
Copy link

I've managed to builf Chromium with LTO

www-client/chromium-76.0.3809.100::gentoo was built with the following:
USE="cups custom-cflags jumbo-build (pic) proprietary-codecs pulseaudio suid system-ffmpeg system-icu system-libvpx tcmalloc -closure-compile -component-build -gnome-keyring -hangouts -kerberos (-selinux) -widevine" L10N="ru -am -ar -bg -bn -ca -cs -da -de -el -en-GB -es -es-419 -et -fa -fi -fil -fr -gu -he -hi -hr -hu -id -it -ja -kn -ko -lt -lv -ml -mr -ms -nb -nl -pl -pt-BR -pt-PT -ro -sk -sl -sr -sv -sw -ta -te -th -tr -uk -vi -zh-CN -zh-TW"
CFLAGS="-march=native -mtune=native -O2 -pipe -fomit-frame-pointer -fno-plt -fno-stack-protector -ftree-vectorize -s"
CXXFLAGS="-march=native -mtune=native -O2 -pipe -fomit-frame-pointer -fno-plt -fno-stack-protector -ftree-vectorize -s -Wno-pedantic -Wno-unused-result -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-deprecated-declarations -Wno-return-type -Wno-parentheses -Wno-misleading-indentation -Wno-attributes -Wno-subobject-linkage -Wno-ignored-attributes -Wno-ignored-attributes -Wno-address -Wno-dangling-else -Wno-class-memaccess -Wno-invalid-offsetof -Wno-packed-not-aligned"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs ccache config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
LDFLAGS="-Wl,-O2 -Wl,--as-needed -Wl,--sort-common -Wl,--strip-debug -flto"

@javashin
Copy link

with clang? or gcc ? @perfect7gentleman

@perfect7gentleman
Copy link

perfect7gentleman commented Aug 20, 2019

GCC.
I can't build properly working Chromium with Clang.

@javashin
Copy link

good thanks @perfect7gentleman for the info

@perfect7gentleman
Copy link

I've used some Dedian and OpenSUSE patches

@perfect7gentleman
Copy link

perfect7gentleman commented Aug 20, 2019

EXTRA_GN="\
is_debug=false \
use_goma=false \
use_ozone=false \
use_sysroot=false \
use_openh264=false \
use_libjpeg_turbo=true \
use_custom_libcxx=false \
use_gnome_keyring=false \
use_unofficial_version_number=false \
enable_vr=false \
enable_nacl=false \
enable_nacl_nonsfi=false \
enable_swiftshader=false \
enable_reading_list=false \
enable_one_click_signin=false \
enable_iterator_debugging=false \
enable_hangout_services_extension=false \
optimize_webui=true \
treat_warnings_as_errors=false \
linux_use_bundled_binutils=false \
\
use_gio=false \
link_pulseaudio=true \
enable_widevine=false \
v8_enable_backtrace=true \
use_system_zlib=true \
use_system_lcms2=true \
use_system_libjpeg=true \
use_system_freetype=true \
use_system_harfbuzz=true \
use_system_libopenjpeg2=true \
use_jumbo_build=true \
proprietary_codecs=true \
ffmpeg_branding=\"Chrome\" \
fieldtrial_testing_like_official_build=true \
\
\
use_aura=true \
symbol_level=0 \
use_kerberos=false \
fatal_linker_warnings=false \
use_gnome_keyring=false \
use_vaapi=true \
use_dbus=true \
enable_hevc_demuxing=true \
enable_mus=true \
gcc_lto=true"
CCACHE_SLOPPINESS="time_macros"
~ $ ls /etc/portage/patches/www-client/chromium
001-libcxx.patch            013-inspector._patch_      021-widevine-locations.patch  029-openh264.patch      036-google-api-warning.patch    044-deprecated.patch        051-null-destination.patch     058-nspr.patch        102-chromium-dma-buf.patch        125-chromium-vaapi.patch
002-parallel.patch          014-gpu-timeout.patch      023-connection-message.patch  030-chromeos.patch      037-third-party-cookies.patch   045-bool-compare.patch      052-int-in-bool-context.patch  059-zlib.patch        103-chromium-buildname.patch
003-gcc_skcms_ice.patch     015-empty-array.patch      024-unrar.patch               031-perfetto.patch      038-device-notifications.patch  046-enum-compare.patch      053-vpx.patch                  060-event._patch_     104-chromium-drm.patch
004-pffffft-buildfix.patch  016-safebrowsing.patch     025-signin.patch              032-installer.patch     040-friend.patch                047-sign-compare.patch      054-icu.patch                  061-ffmpeg.patch      105-chromium-sandbox-pie.patch
009-mojo.patch              017-sequence-point.patch   026-android.patch             033-font-tests.patch    041-printf.patch                048-initialization.patch    055-gtk2.patch                 062-jsoncpp._patch_   107-chromium-system-libusb.patch
011-ps-print.patch          018-jumbo-namespace.patch  027-fuzzers.patch             034-swiftshader.patch   042-attribute.patch             049-unused-typedefs.patch   056-jpeg.patch                 063-openjpeg.patch    109-gcc-lto-rsp-clobber.patch
012-as-needed.patch         019-template-export.patch  028-tracing.patch             035-welcome-page.patch  043-multichar.patch             050-unused-functions.patch  057-lcms.patch                 064-convertutf.patch  110-gcc-enable-lto.patch

@ElDavoo
Copy link
Contributor

ElDavoo commented Nov 15, 2019

On the other hand, I can't compile chromium with gcc 9 and lto:

[4259/19949] rm -f obj/third_party/blink/public/mojom/libweb_feature_mojo_bindings_mojom.a && "x86_64-pc-linux-gnu-ar" -T -r -c -s -D obj/third_party/blink/public/mojom/libweb_feature_mojo_bindings_mojom.a @"obj/third_party/blink/public/mojom/libweb_feature_mojo_bindings_mojom.a.rsp"
[4260/19949] x86_64-pc-linux-gnu-g++ -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,--as-needed -rdynamic -pie -Wl,--disable-new-dtags -Wl,-O1 -Wl,--as-needed -O2 -march=native -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=1 -fuse-linker-plugin -o "./character_data_generator" -Wl,--start-group @"./character_data_generator.rsp"  -Wl,--end-group  -latomic -ldl -lpthread -lrt -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -licui18n -licuuc -licudata
FAILED: character_data_generator 
x86_64-pc-linux-gnu-g++ -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,--as-needed -rdynamic -pie -Wl,--disable-new-dtags -Wl,-O1 -Wl,--as-needed -O2 -march=native -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=1 -fuse-linker-plugin -o "./character_data_generator" -Wl,--start-group @"./character_data_generator.rsp"  -Wl,--end-group  -latomic -ldl -lpthread -lrt -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -licui18n -licuuc -licudata
during IPA pass: pta
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.gentoo.org/> for instructions.
lto-wrapper: fatal error: x86_64-pc-linux-gnu-g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
 * ERROR: www-client/chromium-79.0.3945.29::gentoo failed (compile phase):
 *   ninja -v -j1 -l1 -C out/Release v8_context_snapshot_generator failed

@ElDavoo
Copy link
Contributor

ElDavoo commented Nov 16, 2019

the problem was actually -fipa-pta so I disabled and tried to compile without it.
ICE (maybe on the same file too) in the Graphite stage.
I'm now trying to build it without Graphite...

@elsandosgrande
Copy link
Contributor

Hmm... That's interesting. I have never built Chrome(ium) though, since LibreOffice and QtWebengine take long enough already and my primary browser is Firefox Nightly.

@ElDavoo
Copy link
Contributor

ElDavoo commented Nov 17, 2019

Thing is tests are more difficult due to the big nature of this package. A single test can take 1-2 days if you compile with a low powered machine.
Anyway, no graphite allowed me to get further, but then I got this error.

[7522/19949] python ../../tools/protoc_wrapper/protoc_wrapper.py crx3.proto --protoc ./protoc --proto-in-dir ../../components/crx_file --cc-out-dir gen/components/crx_file --py-out-dir pyproto/components/crx_file
FAILED: pyproto/components/crx_file/crx3_pb2.py gen/components/crx_file/crx3.pb.h gen/components/crx_file/crx3.pb.cc 
python ../../tools/protoc_wrapper/protoc_wrapper.py crx3.proto --protoc ./protoc --proto-in-dir ../../components/crx_file --cc-out-dir gen/components/crx_file --py-out-dir pyproto/components/crx_file
terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1
Protoc has returned non-zero status: -6

Since this error does not give any clue on what is going wrong, I'm now trying to compile with USE="-custom-cflags".

@barolo
Copy link

barolo commented Nov 17, 2019

Thing is tests are more difficult due to the big nature of this package. A single test can take 1-2 days if you compile with a low powered machine.
Anyway, no graphite allowed me to get further, but then I got this error.

[7522/19949] python ../../tools/protoc_wrapper/protoc_wrapper.py crx3.proto --protoc ./protoc --proto-in-dir ../../components/crx_file --cc-out-dir gen/components/crx_file --py-out-dir pyproto/components/crx_file
FAILED: pyproto/components/crx_file/crx3_pb2.py gen/components/crx_file/crx3.pb.h gen/components/crx_file/crx3.pb.cc 
python ../../tools/protoc_wrapper/protoc_wrapper.py crx3.proto --protoc ./protoc --proto-in-dir ../../components/crx_file --cc-out-dir gen/components/crx_file --py-out-dir pyproto/components/crx_file
terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1
Protoc has returned non-zero status: -6

Since this error does not give any clue on what is going wrong, I'm now trying to compile with USE="-custom-cflags".

I could test it for you, it takes hour or so to build but I gave up on compiling with gcc. Chromium uses clang specific optimizations/patches which result in significant performance differences [ 20%~ ]

@ElDavoo
Copy link
Contributor

ElDavoo commented Nov 17, 2019

Chromium uses clang specific optimizations/patches which result in significant performance differences [ 20%~ ]

Can you demonstrate that? If that's true, we don't we force chromium to use clang as compiler?

@barolo
Copy link

barolo commented Nov 17, 2019

Chromium uses clang specific optimizations/patches which result in significant performance differences [ 20%~ ]

Can you demonstrate that? If that's true, we don't we force chromium to use clang as compiler?

Chrome/ium uses clangs -fwhole-program-vtables for performance boost amongst other things,
"Skia contains SSE and AVX optimized rendering routines which are written using Clang only vector extensions." From Honza Hubickas blog [ GCC dev ]
If you need more stuff I'll link it later

As to why it isn't used? Nobody cares about compiling chromium from source with the exception of niche Gentoo user. Gentoo isn't particularly bleeding edge at its core nor it cares about chromium, clang that much. There are talks but it moves at snail's pace

I've seen some ebuilds in overlays with clang as an option but most of them disappeared recently, chromium is a fast moving target and stuff around it adapts slowly

Firefox upstream is also compiled with clang, just FYI, and clang version had double rendering performance for some time [ which was fixed/patched ]

@automorphism88
Copy link
Contributor

Chrome/ium uses clangs -fwhole-program-vtables for performance boost amongst other things,
"Skia contains SSE and AVX optimized rendering routines which are written using Clang only vector extensions." From Honza Hubickas blog [ GCC dev ]

After reading about this I decided to give clang another try. I am able to build chromium fine with GCC 9.2 using LTO, but when I attempt to use clang, it fails very early in the build process, and I haven't been able to figure out why. Here is the error I get:

[80/808] clang++ -pie -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -flto=thin -Wl,--thinlto-jobs=8 -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy,cache_size=10\%:cache_size_bytes=10g:cache_size_files=100000 -Wl,--lto-O2 -fwhole-program-vtables -rdynamic -pie -Wl,--disable-new-dtags -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,-z,relro -Wl,-z,now -flto=thin -O3 -pipe -march=bdver4 -fstack-check -o "./bytecode_builtins_list_generator" -Wl,--start-group @"./bytecode_builtins_list_generator.rsp"  -Wl,--end-group  -latomic -ldl -lpthread -lrt
[81/808] clang++ -pie -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -flto=thin -Wl,--thinlto-jobs=8 -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy,cache_size=10\%:cache_size_bytes=10g:cache_size_files=100000 -Wl,--lto-O2 -fwhole-program-vtables -rdynamic -pie -Wl,--disable-new-dtags -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,-z,relro -Wl,-z,now -flto=thin -O3 -pipe -march=bdver4 -fstack-check -o "./gen-regexp-special-case" -Wl,--start-group @"./gen-regexp-special-case.rsp"  -Wl,--end-group  -latomic -ldl -lpthread -lrt -licui18n -licuuc -licudata
[82/808] python ../../v8/tools/run.py ./gen-regexp-special-case gen/v8/src/regexp/special-case.cc
[83/808] touch obj/v8/run_gen-regexp-special-case.stamp
[84/808] python ../../v8/tools/run.py ./bytecode_builtins_list_generator gen/v8/builtins-generated/bytecodes-builtins-list.h
FAILED: gen/v8/builtins-generated/bytecodes-builtins-list.h 
python ../../v8/tools/run.py ./bytecode_builtins_list_generator gen/v8/builtins-generated/bytecodes-builtins-list.h
ninja: build stopped: subcommand failed.

I tried enabling FEATURES=-fail-clean and then going into the build directory and running that command manually (python ../../v8/tools/run.py ./bytecode_builtins_list_generator gen/v8/builtins-generated/bytecodes-builtins-list.h), and it worked fine, or at least returned exit status 0 and produced a file with the expected name in the expected location. So, something is different somehow in the portage environment that is making it fail, and the error only affects running bytecode_builtins_list_generator, not building it. The step that fails doesn't actually invoke either gcc or clang, so it seems strange, since even though the binary that fails to run was compiled with clang and not gcc, it runs fine outside of the portage environment, and the only changes I made to the portage environment in between were related to the switch from gcc to clang.

The changes I made to the portage environment since successfully building with gcc are as follows:

  1. Enable clang, using a file in /etc/portage/env that looks like this:
CC="clang"
CXX="clang++"
LD="ld.lld"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"
CFLAGS="${CFLAGS} -flto=thin"
CXXFLAGS="${CXXFLAGS} -flto=thin"
LDFLAGS="${LDFLAGS} -flto=thin"
  1. Created /etc/portage/env/www-client/chromium as follows:
EXTRA_GN="thin_lto_enable_optimizations=true use_lld=true use_thin_lto=true"
  1. Enabled the custom-cflags USE flag, although the only difference it seems to make is that it prevents -O3 from being replaced by -O2. Without this USE flag, the build fails in the exact same way.

@jonesmz
Copy link
Contributor

jonesmz commented May 14, 2020

Sorry to be a bother, but this isn't proving simple to debug, given Chromium takes several (seeeeeeveral) hours to build.

Does anyone else have this situation, or am I doing something unusual?

@wolfwood
Copy link
Contributor

wolfwood commented May 14, 2020

i can no longer build with USE=custom-cflags due to a failure with the bundled ANGLE third-party library. without I'm building/running chromium successfully, tho it's not my main browser. Hulu wasn't working with the previous release, but seems to have corrected itself with the latest.

@jonesmz
Copy link
Contributor

jonesmz commented May 25, 2020

I've reproduced this failure with Chromium 83.0.4103.61.

I'm beginning to suspect the problem is caused by a dependency of Chromium, but I'm not sure which.

@dallenwilson
Copy link

Building with stock gentooLTO settings and custom-flags fails for me as well, but I have successfully built chromium-85.0.4183.83 with custom-cflags and an overrides file in /etc/portage/env using the template provided by @perfect7gentleman #127 (comment)

I plan on putting together an ebuild to apply those changes to all my gentoo boxes, and I'd like to see if anyone else has success with them. @InBetweenNames, if we can get a consensus on what the bare minimum is for LTO to work and get it tested widely enough to be reliable, would a PR to update sys-config/ltoize with them be welcomed?

@jonesmz
Copy link
Contributor

jonesmz commented Sep 7, 2020

@dallenwilson If you could link me to a file that I can drop into /etc/portage/ somewhere, I'd be happy to test for you. Note, however, that I'm still using the most recently stabilized GCC, which is 9.3 as of today. I don't use unstable compilers.

@dallenwilson
Copy link

@jonesmz Sorry for the delayed response. I'll make it available once I'm satisfied that it is likely to work for someone else. I have three Gentoo boxes to work with, two different generations of AMD and one Intel, all with somewhat different USE flags and such. Once I get it the various options pruned down to a common set that build on all of them, I'll share it.

@jonesmz
Copy link
Contributor

jonesmz commented Sep 23, 2020

@dallenwilson Unexpectedly, chromium now launches... but of course there have to be problems. Clipboard doesn't work :-P

jonesmz@ymir ~ $ emerge --info chromium
Portage 3.0.4 (python 3.7.8-final-0, default/linux/amd64/17.1, gcc-9.3.0, glibc-2.31-r6, 5.4.66-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.4.66-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E3-1240_V2_@_3.40GHz-with-gentoo-2.7
KiB Mem:    32855652 total,  28805300 free
KiB Swap:    8388604 total,   8388604 free
Timestamp of repository gentoo: Wed, 23 Sep 2020 15:35:33 +0000
Head commit of repository gentoo: b0e87952c202395c69a653455e92cac9f086e80b

Head commit of repository jonesmz-public-overlay: f2a4eeea473f94bf0045e49ca098cd36b44b2bf3

Head commit of repository lto-overlay: a7a574dafb9aac830901daf0f884083548e34939

Head commit of repository mv: 91e621b78b79a257303a0dcb31290b54e572fdcc

Head commit of repository wsdd: 116efbeabc8f68536c93d252dfbe0897bbdc0d3b

Head commit of repository steam-overlay: 9b344386364381390a2418299779ba7fea9225c3

sh bash 5.0_p18
ld GNU ld (Gentoo 2.33.1 p2) 2.33.1
distcc 3.3.3 x86_64-pc-linux-gnu [disabled]
ccache version 3.7.11 [disabled]
app-shells/bash:          5.0_p18::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18::gentoo, 3.7.8-r2::gentoo, 3.8.5::gentoo
dev-util/ccache:          3.7.11::gentoo
dev-util/cmake:           3.16.5::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/sandbox:         2.18::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.33.1-r1::gentoo, 2.34-r2::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r6::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: git
    sync-uri: git://anongit.gentoo.org/repo/sync/gentoo.git
    priority: -1000

jonesmz-public-overlay
    location: /usr/portage-overlays/jonesmz-public-overlay
    sync-type: git
    sync-uri: https://github.com/jonesmz/gentoo-overlay.git
    masters: gentoo

lto-overlay
    location: /usr/portage-overlays/lto-overlay
    sync-type: git
    sync-uri: https://github.com/InBetweenNames/gentooLTO.git
    masters: gentoo mv

mv
    location: /usr/portage-overlays/mv
    sync-type: git
    sync-uri: https://anongit.gentoo.org/git/user/mv.git
    masters: gentoo

wsdd
    location: /usr/portage-overlays/wsdd-gentoo
    sync-type: git
    sync-uri: https://github.com/christgau/wsdd-gentoo
    masters: gentoo

steam-overlay
    location: /usr/portage-overlays/steam-overlay
    sync-type: git
    sync-uri: https://github.com/anyc/steam-overlay.git
    masters: gentoo
    priority: 50

Installed sets: @archive, @creative, @desktop-applications, @lxqt, @pc-base-system, @portage, @vcs
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=1 -fuse-linker-plugin -march=x86-64 -mtune=generic -O2 -pipe -ffat-lto-objects"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe -O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=1 -fuse-linker-plugin -march=x86-64 -mtune=generic -O2 -pipe -ffat-lto-objects"
DISTDIR="/usr/portage-distfiles"
EMERGE_DEFAULT_OPTS=" --jobs --keep-going --newuse --changed-deps --deep --tree --backtrack=3000 --complete-graph --with-bdeps=y --binpkg-respect-use=y --binpkg-changed-deps=y --changed-slot=y --usepkg=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg clean-logs compress-build-logs compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles installsources ipc-sandbox merge-sync multilib-strict network-sandbox news nostrip parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms split-elog split-log strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en en_US"
MAKEOPTS="-j10"
PKGDIR="/usr/portage-packages"
PORTAGE_COMPRESS="xz"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa amd64 branding bzip2 cairo cdda cdr clang crypt dbus dri dts dvd dvdr egl emboss encode exif flac gif glamor gles2 gnome-keyring gpm gstreamer gtk gtk3 gui hardened iconv icu ipv6 jpeg lcms libglvnd libnotify libtirpc mad mp3 mp4 mpeg multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf pie png policykit ppds pulseaudio qt5 readline samba sdl seccomp sound spell split-usr ssl ssp startup-notification svg systemd theora threads tiff truetype udev udisks unicode upower usb vaapi vorbis wayland widevine x264 xattr xcb xinerama xml xtpax xv xvid zeroconf zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx sse sse2 mmxext" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="coreboot efi-64 emu qemu pc" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7" QEMU_SOFTMMU_TARGETS="arm aarch64 x86_64" QEMU_USER_TARGETS="arm aarch64 x86_64" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="vesa modesetting radeon radeonsi amdgpu" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

www-client/chromium-85.0.4183.121::gentoo was built with the following:
USE="hangouts js-type-check ozone (pic) proprietary-codecs pulseaudio system-ffmpeg system-icu tcmalloc widevine (-component-build) -cups -custom-cflags (-headless) -kerberos -ozone-wayland (-selinux) -suid (-system-libvpx)" ABI_X86="(64)" L10N="-am -ar -bg -bn -ca -cs -da -de -el -en-GB -es -es-419 -et -fa -fi -fil -fr -gu -he -hi -hr -hu -id -it -ja -kn -ko -lt -lv -ml -mr -ms -nb -nl -pl -pt-BR -pt-PT -ro -ru -sk -sl -sr -sv -sw -ta -te -th -tr -uk -vi -zh-CN -zh-TW"
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -Wl,-O1 -Wl,--as-needed"
CXXFLAGS="-O2 -pipe -march=x86-64 -mtune=generic -O2 -pipe -Wl,-O1 -Wl,--as-needed"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -march=x86-64 -mtune=generic -O2 -pipe"

@dallenwilson
Copy link

I ended up testing quite a few permutations of gentooLTO's default CFLAGS. I finally got chromium to build with custom-cflags set on all my machines without modifying anything at all, except for setting MAKEOPTS="-j1" and NTHREADS="1" in /etc/portage/make.conf and EXTRA_GN="gcc_lto=true" in /etc/portage/env/www-client/chromium. It launches and everything appears to work. Even the clipboard!

The error I'd been getting (terminate called after throwing an instance of 'std::system_error', always at different source files and different points in the build on every attempt) was due to the build process trying to use more threads than were available to userspace programs. I'll be investigating that next and hopefully increasing it, because building with makeopts -j1/nthreads=1 is a bit time-consuming.

@shelterx
Copy link

Always dies here for me when I try what @dallenwilson suggested (using gcc):

FAILED: pyproto/components/leveldb_proto/internal/proto/shared_db_metadata_pb2.py gen/components/leveldb_proto/internal/proto/shared_db_metadata.pb.h gen/components/leveldb_proto/internal/proto/shared_db_metadata.pb.cc
python ../../tools/protoc_wrapper/protoc_wrapper.py shared_db_metadata.proto --protoc ./protoc --proto-in-dir ../../compon          ents/leveldb_proto/internal/proto --cc-out-dir gen/components/leveldb_proto/internal/proto --py-out-dir pyproto/components          /leveldb_proto/internal/proto
terminate called after throwing an instance of 'std::system_error'

What's also weird is that it doesn't compile with clang anymore for me either, so something's changed in chromium-86.0.

@Hello71
Copy link
Contributor Author

Hello71 commented Oct 12, 2020

Always dies here for me when I try what @dallenwilson suggested (using gcc):

FAILED: pyproto/components/leveldb_proto/internal/proto/shared_db_metadata_pb2.py gen/components/leveldb_proto/internal/proto/shared_db_metadata.pb.h gen/components/leveldb_proto/internal/proto/shared_db_metadata.pb.cc
python ../../tools/protoc_wrapper/protoc_wrapper.py shared_db_metadata.proto --protoc ./protoc --proto-in-dir ../../compon          ents/leveldb_proto/internal/proto --cc-out-dir gen/components/leveldb_proto/internal/proto --py-out-dir pyproto/components          /leveldb_proto/internal/proto
terminate called after throwing an instance of 'std::system_error'

What's also weird is that it doesn't compile with clang anymore for me either, so something's changed in chromium-86.0.

you cropped out the important line of this error, but you might fix it by disabling --as-needed.

@shelterx
Copy link

Mhh I never got the lto build to work without errors, so I went with default flags now, it seems like the requirements for a standard build is higher now than before. I ran out of memory with -j4 on a a system with 8Gb of RAM,
Out of memory: Killed process 16359 (cc1plus) total-vm:3588800kB, anon-rss:2030944kB, file-rss:956kB, shmem-rss:0kB, UID:250 pgtables:4412kB oom_score_adj:0

So I suspect an lto build will require even more.

@fcsager
Copy link

fcsager commented Nov 4, 2020

I was able to get chrome to build once with gcc and this repository's lto configuration. All other attempts ended with errors like @shelterx and @dallenwilson. I don't know how I got it to build, I think it was by sheer dumb luck. However, that build was extremely buggy. It would pass Browser Speedometer 2.0 tests at an average of 12 runs per minute.

I was able to get www-client/chromium-87.0.4280.40::gentoo to build with the following env set up.

/etc/portage/package.env/chromium.conf:

CC="clang"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"
EXTRA_GN="chrome_pgo_phase=2 is_clang=true use_lld=true thin_lto_enable_optimizations=true use_thin_lto=true"

This build is greatly out preforming the stock gcc builds I had which averaged 75-80 runs/min on Browser Speedometer 2.0. Build 87.0.4280.40 is currently posting 125+ runs/min consistently.

@fufler
Copy link

fufler commented Nov 15, 2020

I'll be investigating that next and hopefully increasing it, because building with makeopts -j1/nthreads=1 is a bit time-consuming.

@dallenwilson Do you have any update on this? I'm facing the same problem.

The error I'd been getting (terminate called after throwing an instance of 'std::system_error', always at different source files and different points in the build on every attempt) was due to the build process trying to use more threads than were available to userspace programs.

Are you sure about the fail reason? I've tried to increase number of allowed user processes via ulimit -u unlimited but with no luck. Morever it doesn't seem to be an issue according to the number of threads in use being reported by htop during build process.

@shelterx
Copy link

I have to build with -j2 if I use gcc, I gave up on clang but I might try the settings @fcsager posted.

It's weird tho', jumbo builds when they were supported used quite a lot of more memory but I never ran OOM.
Now, a bit in the compile process some "files" eats all memory, I checked the code and they are not big at all. The compile process must be doing something extra but I have no idea what that might be.

@fufler
Copy link

fufler commented Nov 16, 2020

I have to build with -j2 if I use gcc

Is it just -j2 or something else? I'm not able to build it even with MAKEOPTS="-j1" FEATURES="-distcc",

@shelterx
Copy link

shelterx commented Nov 16, 2020

Is it just -j2 or something else? I'm not able to build it even with MAKEOPTS="-j1" FEATURES="-distcc",

chromium.conf env file:

NTHREADS="auto" # Not sure if this is needed
MAKEOPTS="-j2"
EXTRA_GN="gcc_lto=true enable_nacl=false blink_symbol_level=0 symbol_level=0" # I don't think gcc_lto is an actual flag?

package.use:

www-client/chromium widevine jumbo-build -hangouts L10N: sv -am -ar -bg -bn -ca -cs -da -de -el -en-GB -es -es-419 -et -fa -fi -fil -fr -gu -he -hi -hr -hu -id -it -ja -kn -ko -lt -lv -ml -mr -ms -nb -nl -pl -pt-BR -pt-PT -CN -zh-TW -ro -ru -sk -sl -sr -sw -ta -te -th -tr -uk -vi -zh-CN
# jumbo-build is obsolete now.

I also use ccache for chromium but it doesn't seem to help much.

@dallenwilson
Copy link

@fufler I went to NTHREADS="1"; MAKEOPTS="-j18" on my main system without problems. My other two systems failed to merge the last update, chromium-86.0.4240.198, but I haven't made time to investigate again. As to the fail reason: No, I am not sure. I based the guess on information available here, but I won't call it conclusive and did not verify it on my end.

@shelterx
Copy link

shelterx commented Nov 17, 2020

CC="clang"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"
EXTRA_GN="chrome_pgo_phase=2 is_clang=true use_lld=true thin_lto_enable_optimizations=true use_thin_lto=true"

I had to remove chrome_pgo_phase=2 but it seems to be compiling now, running -j4 and no signs of OOM or other errors yet.

EDIT:
Successful compile! No where near OOM I think like I had when I used gcc.

@barolo
Copy link

barolo commented Jan 22, 2021

Just a reminder, emerge --info will not show you what real flags were used.
Current chromium doesn't allow for flag changes the usual way, no matter what you'll do as they build different parts with different optimizations.
To build it with --march-native you need to pass EXTRA_GN="x64_arch=\"native\""
There's no way to force -O3 and forcing so would break everything.
It's pretty heavily optimized anyway, with pgo, thinlto and whole-vtables

@shelterx
Copy link

shelterx commented Jan 31, 2021

To build it with --march-native you need to pass EXTRA_GN="x64_arch=\"native\""

Not sure what I've done apart from using the above settings but Chromium compiles with -march=native for me. (I don't use EXTRA_GN="x64_arch="native""`)

@barolo
Copy link

barolo commented Feb 1, 2021

@shelterx How do you know? emerge --info told you?
emerge --info just tells you that it compiled with --march-native passed to build system, not that chromium build system used it. It's the same story for many bigger packages which do own custom stuff during build.
You can just watch the compilation log for what it actually does.

@shelterx
Copy link

shelterx commented Feb 1, 2021

@barolo i see the -march=native being used flag on the source files when i compile chromium...
You can also probably use something like ps auxwww|grep native in another terminal when you compile chromium.

@sarnold
Copy link

sarnold commented Jun 11, 2021

Is there a consensus on how to properly build chromium with lto-overlay in place? What appears to be working correctly (albeit build is still in-progress) is the following with no changes to default lto-overlay flags and without enabling custom-cflags:

$ cat /etc/portage/package.env/chromium 
www-client/chromium plain-native.conf clang-bins.conf chromium.conf j3-bare.conf

$ cat /etc/portage/env/plain-native.conf 
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
LDFLAGS="${CFLAGS} -Wl,-O1 -Wl,--as-needed"

$ cat /etc/portage/env/clang-bins.conf 
CC="clang"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"

$ cat /etc/portage/env/chromium.conf 
# chrome_pgo_phase=2 may be dicey
EXTRA_GN="is_clang=true use_lld=true thin_lto_enable_optimizations=true use_thin_lto=true"

@sarnold
Copy link

sarnold commented Jun 11, 2021

Note the -j3 is due to only <6 GB ram with about the same amount of swap.

@barolo
Copy link

barolo commented Jun 12, 2021

Note the -j3 is due to only <6 GB ram with about the same amount of swap.

I have 16 GB and I'm tired of compiling chromium, it is till swapping...
I would just use bin version at this point.
There's ungoogled build from pf4public with all of your settings in use flags. For now I cannot get hw video accell to work, so I gave up [it works, enabling vulkan broke it] [ver. 91]

@sarnold
Copy link

sarnold commented Jun 20, 2021

Actually that ^^ did work, but i had to set gcc 10.x for the right cxx libs.

@barolo
Copy link

barolo commented Jun 21, 2021

Updated ungoogled to latest, it took 8h~ to compile, entirelly in RAM on 4 core 4Ghz CPU with clang and full set of optimizations.
I don't remember it taking so much time, or am I misremembering things?

@barolo
Copy link

barolo commented Jun 22, 2021

Also, chrome-bin is quite a bit faster than my chromium build with all optimizations turned on, at least in rendering benches, with identical gpu info in both. 640 points for chrome and 500 for chromium in Motionmark 1.2 for example.
No clue as to why.

@KrissN
Copy link

KrissN commented Jan 10, 2022

Also, chrome-bin is quite a bit faster than my chromium build with all optimizations turned on, at least in rendering benches, with identical gpu info in both. 640 points for chrome and 500 for chromium in Motionmark 1.2 for example. No clue as to why.

Maybe it's because chrome-bin uses PGO?

@barolo
Copy link

barolo commented Jan 25, 2022

Yes it does, but as I said, my build had all optimizations—including PGO—turned on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests