2019-11-06 19:37:25 +00:00
{ stdenv , lib , llvmPackages , gnChromium , ninja , which , nodejs , fetchpatch , fetchurl
2014-04-01 05:36:26 +00:00
# default dependencies
2019-11-06 19:37:25 +00:00
, gnutar , bzip2 , flac , speex , libopus
2014-04-01 05:36:26 +00:00
, libevent , expat , libjpeg , snappy
2017-06-11 08:10:56 +00:00
, libpng , libcap
2021-02-01 08:05:09 +00:00
, xdg-utils , yasm , nasm , minizip , libwebp
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
, libusb1 , pciutils , nss , re2
2014-04-01 05:36:26 +00:00
2021-05-08 17:55:29 +00:00
, python2 , python3 , perl , pkg-config
2021-03-14 16:11:48 +00:00
, nspr , systemd , libkrb5
2021-06-10 02:57:09 +00:00
, util-linux , alsa-lib
2014-08-13 02:53:31 +00:00
, bison , gperf
2018-10-04 18:01:26 +00:00
, glib , gtk3 , dbus-glib
2019-01-30 22:55:20 +00:00
, glibc
2020-12-24 11:17:35 +00:00
, libXScrnSaver , libXcursor , libXtst , libxshmfence , libGLU , libGL
2014-12-07 13:52:36 +00:00
, protobuf , speechd , libXdamage , cups
2020-10-09 21:29:16 +00:00
, ffmpeg , libxslt , libxml2 , at-spi2-core
2020-09-19 11:41:44 +00:00
, jre8
2021-03-03 12:24:48 +00:00
, pipewire
2020-11-27 12:49:04 +00:00
, libva
2021-02-05 13:29:47 +00:00
, libdrm , wayland , mesa , libxkbcommon # Ozone
2021-05-07 14:09:57 +00:00
, curl
2014-04-01 05:36:26 +00:00
# optional dependencies
, libgcrypt ? null # gnomeSupport || cupsSupport
# package customization
2021-05-07 21:18:14 +00:00
, gnomeSupport ? false , gnome2 ? null
2018-02-25 02:23:58 +00:00
, gnomeKeyringSupport ? false , libgnome-keyring3 ? null
2014-04-01 05:36:26 +00:00
, proprietaryCodecs ? true
2014-12-07 13:52:36 +00:00
, cupsSupport ? true
2015-05-27 19:42:15 +00:00
, pulseSupport ? false , libpulseaudio ? null
2020-12-09 18:13:26 +00:00
, ungoogled ? false , ungoogled-chromium
2014-04-01 05:36:26 +00:00
2019-11-06 19:37:25 +00:00
, channel
2016-03-20 16:50:17 +00:00
, upstream-info
2014-04-01 05:36:26 +00:00
} :
buildFun :
2021-01-15 13:21:58 +00:00
with lib ;
2014-04-01 05:36:26 +00:00
let
2020-09-19 11:41:44 +00:00
jre = jre8 ; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
2021-05-08 17:55:29 +00:00
python2WithPackages = python2 . withPackages ( ps : with ps ; [
ply jinja2 setuptools
] ) ;
python3WithPackages = python3 . withPackages ( ps : with ps ; [
ply jinja2 setuptools
] ) ;
2020-09-19 11:41:44 +00:00
2014-04-01 05:36:26 +00:00
# The additional attributes for creating derivations based on the chromium
# source tree.
extraAttrs = buildFun base ;
2021-06-08 19:12:07 +00:00
githubPatch = { commit , sha256 , revert ? false }: fetchpatch {
2018-02-26 23:04:33 +00:00
url = " h t t p s : / / g i t h u b . c o m / c h r o m i u m / c h r o m i u m / c o m m i t / ${ commit } . p a t c h " ;
2021-06-08 19:12:07 +00:00
inherit sha256 revert ;
2018-02-26 23:04:33 +00:00
} ;
2018-01-09 01:11:02 +00:00
2016-10-29 02:05:53 +00:00
mkGnFlags =
2014-04-01 05:36:26 +00:00
let
2016-10-29 02:05:53 +00:00
# Serialize Nix types into GN types according to this document:
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
# https://source.chromium.org/gn/gn/+/master:docs/language.md
2016-10-29 02:05:53 +00:00
mkGnString = value : " \" ${ escape [ " \" " " $ " " \\ " ] value } \" " ;
2014-04-01 05:36:26 +00:00
sanitize = value :
2016-10-29 02:05:53 +00:00
if value == true then " t r u e "
else if value == false then " f a l s e "
else if isList value then " [ ${ concatMapStringsSep " , " sanitize value } ] "
else if isInt value then toString value
else if isString value then mkGnString value
else throw " U n s u p p o r t e d t y p e f o r G N v a l u e ` ${ value } ' . " ;
toFlag = key : value : " ${ key } = ${ sanitize value } " ;
2014-04-01 05:36:26 +00:00
in attrs : concatStringsSep " " ( attrValues ( mapAttrs toFlag attrs ) ) ;
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
# https://source.chromium.org/chromium/chromium/src/+/master:build/linux/unbundle/replace_gn_files.py
2016-10-29 02:05:53 +00:00
gnSystemLibraries = [
2020-10-09 21:29:16 +00:00
" f f m p e g "
" f l a c "
" l i b j p e g "
" l i b p n g "
" l i b w e b p "
" l i b x s l t "
" o p u s "
" s n a p p y "
" z l i b "
2020-07-14 20:52:15 +00:00
] ;
2014-04-01 05:36:26 +00:00
opusWithCustomModes = libopus . override {
2014-07-28 03:05:01 +00:00
withCustomModes = true ;
2014-04-01 05:36:26 +00:00
} ;
defaultDependencies = [
2021-06-18 22:46:49 +00:00
( libpng . override { apngSupport = false ; } ) # https://bugs.chromium.org/p/chromium/issues/detail?id=752403
2015-06-11 16:23:58 +00:00
bzip2 flac speex opusWithCustomModes
2014-04-01 05:36:26 +00:00
libevent expat libjpeg snappy
2021-06-18 22:46:49 +00:00
libcap
2021-02-01 08:05:09 +00:00
xdg-utils minizip libwebp
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
libusb1 re2
2020-10-09 21:29:16 +00:00
ffmpeg libxslt libxml2
2020-07-14 20:52:15 +00:00
nasm
] ;
2014-04-01 05:36:26 +00:00
# build paths and release info
2014-04-20 06:39:40 +00:00
packageName = extraAttrs . packageName or extraAttrs . name ;
2014-04-01 05:36:26 +00:00
buildType = " R e l e a s e " ;
buildPath = " o u t / ${ buildType } " ;
libExecPath = " $ o u t / l i b e x e c / ${ packageName } " ;
2021-04-24 10:45:55 +00:00
warnObsoleteVersionConditional = min-version : result :
let ungoogled-version = ( importJSON ./upstream-info.json ) . ungoogled-chromium . version ;
2021-04-27 13:52:15 +00:00
in warnIf ( versionAtLeast ungoogled-version min-version ) " c h r o m i u m : u n g o o g l e d v e r s i o n ${ ungoogled-version } i s n e w e r t h a n a c o n d i t i o n a l b o u n d e d a t ${ min-version } . Y o u c a n s a f e l y d e l e t e i t . "
result ;
2021-01-28 21:06:23 +00:00
chromiumVersionAtLeast = min-version :
2021-04-24 10:45:55 +00:00
let result = versionAtLeast upstream-info . version min-version ;
in warnObsoleteVersionConditional min-version result ;
2019-10-11 20:55:11 +00:00
versionRange = min-version : upto-version :
let inherit ( upstream-info ) version ;
result = versionAtLeast version min-version && versionOlder version upto-version ;
2021-04-24 10:45:55 +00:00
in warnObsoleteVersionConditional upto-version result ;
2019-10-11 20:55:11 +00:00
2020-12-09 18:29:31 +00:00
ungoogler = ungoogled-chromium {
inherit ( upstream-info . deps . ungoogled-patches ) rev sha256 ;
} ;
2014-04-01 05:36:26 +00:00
base = rec {
2018-11-18 00:51:12 +00:00
name = " ${ packageName } - u n w r a p p e d - ${ version } " ;
2019-11-06 19:37:25 +00:00
inherit ( upstream-info ) version ;
2021-01-22 11:19:27 +00:00
inherit packageName buildType buildPath ;
2016-03-20 16:50:17 +00:00
2019-11-06 19:37:25 +00:00
src = fetchurl {
url = " h t t p s : / / c o m m o n d a t a s t o r a g e . g o o g l e a p i s . c o m / c h r o m i u m - b r o w s e r - o f f i c i a l / c h r o m i u m - ${ version } . t a r . x z " ;
inherit ( upstream-info ) sha256 ;
} ;
2016-03-20 16:50:17 +00:00
2017-02-08 19:47:07 +00:00
nativeBuildInputs = [
2021-05-08 17:55:29 +00:00
ninja pkg-config
python2WithPackages perl nodejs
gnutar which
2021-05-01 03:03:19 +00:00
llvmPackages . bintools
2021-05-08 17:55:29 +00:00
] ++ lib . optionals ( chromiumVersionAtLeast " 9 2 " ) [
python3WithPackages
2020-07-14 20:52:15 +00:00
] ;
2017-02-08 19:47:07 +00:00
2014-04-01 05:36:26 +00:00
buildInputs = defaultDependencies ++ [
2016-09-05 16:59:00 +00:00
nspr nss systemd
2021-06-10 02:57:09 +00:00
util-linux alsa-lib
2021-03-14 16:11:48 +00:00
bison gperf libkrb5
2018-10-04 18:01:26 +00:00
glib gtk3 dbus-glib
2020-12-24 11:17:35 +00:00
libXScrnSaver libXcursor libXtst libxshmfence libGLU libGL
2021-04-04 17:17:49 +00:00
mesa # required for libgbm
2018-12-09 03:00:42 +00:00
pciutils protobuf speechd libXdamage at-spi2-core
2019-12-10 12:12:58 +00:00
jre
2021-03-03 12:24:48 +00:00
pipewire
2020-11-27 12:49:04 +00:00
libva
2021-02-05 13:29:47 +00:00
libdrm wayland mesa . drivers libxkbcommon
2021-05-07 14:09:57 +00:00
curl
2020-11-27 12:49:04 +00:00
] ++ optional gnomeKeyringSupport libgnome-keyring3
2021-05-07 21:18:14 +00:00
++ optionals gnomeSupport [ gnome2 . GConf libgcrypt ]
2014-12-07 13:52:36 +00:00
++ optionals cupsSupport [ libgcrypt cups ]
2021-02-05 13:29:47 +00:00
++ optional pulseSupport libpulseaudio ;
2014-04-01 05:36:26 +00:00
2020-10-07 11:39:57 +00:00
patches = [
2020-10-20 10:59:55 +00:00
./patches/no-build-timestamps.patch # Optional patch to use SOURCE_DATE_EPOCH in compute_build_timestamp.py (should be upstreamed)
./patches/widevine-79.patch # For bundling Widevine (DRM), might be replaceable via bundle_widevine_cdm=true in gnFlags
2021-04-24 10:45:55 +00:00
# Fix the build by adding a missing dependency (s. https://crbug.com/1197837):
2021-04-11 16:08:56 +00:00
./patches/fix-missing-atspi2-dependency.patch
./patches/closure_compiler-Use-the-Java-binary-from-the-system.patch
2021-06-08 19:12:07 +00:00
] ++ lib . optionals ( chromiumVersionAtLeast " 9 3 " ) [
# We need to revert this patch to build M93 with LLVM 12.
( githubPatch {
# Reland "Replace 'blacklist' with 'ignorelist' in ./tools/msan/."
commit = " 9 d 0 8 0 c 0 9 3 4 b 8 4 8 e e 4 a 0 5 0 1 3 c 7 8 6 4 1 e 6 1 2 f c c 1 e 0 3 " ;
sha256 = " 1 b x d h x m i y 6 h 4 a c q 2 6 l q 4 3 x 2 m x x 6 r a w m f m l g s h 5 j 7 w 8 k y h k w 5 a f 0 c " ;
revert = true ;
} )
chromiumDev: Fix build errors due to the older system FFmpeg
The final linking still fails though, even with llvm-git.
We might have to diable use_thin_lto for now:
ld.lld: error: undefined symbol: snappy::Compress(char const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)
>>> referenced by compression_module.cc
>>> thinlto-cache/Thin-ed5ed5.tmp.o:(reporting::CompressionModule::CompressRecord(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, base::OnceCallback<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, absl::optional<reporting::CompressionInformation>)>) const)
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
2021-06-28 10:43:37 +00:00
# To fix build errors with the older system FFmpeg:
( githubPatch {
# unbundle: add libavcodec/packet.h to shim headers
commit = " e 4 d 2 2 8 e c 3 0 6 0 7 b 0 6 b f 3 f e d 7 7 4 9 7 a b e f 8 9 c 2 9 9 6 6 a " ;
sha256 = " 0 2 j g 2 b d m g j c p m k 6 a l b 7 2 j c 9 3 w y 3 n f 2 f p a 7 2 h b 4 a a r q 3 3 7 i 2 m w n 4 v " ;
} )
( githubPatch {
# Roll src/third_party/ffmpeg/ 7e1d53a09..cf7ee6598 (1000 commits)
commit = " 3 e c 3 b 2 9 9 2 2 3 8 d 4 b 4 7 6 4 f 9 9 f 0 4 6 0 5 e 1 5 4 6 8 8 c 7 9 9 0 " ;
sha256 = " 1 f w b 1 5 4 s 5 q c i s 4 9 0 r v c v m 1 4 z r m a j 5 9 g 5 l g 9 z g 8 a d a 3 6 v w 9 h y c b r f " ;
revert = true ;
} )
2021-04-13 08:17:35 +00:00
] ;
2018-10-24 21:25:36 +00:00
2021-05-30 13:10:00 +00:00
postPatch = ''
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
# remove unused third-party
for lib in $ { toString gnSystemLibraries } ; do
if [ - d " t h i r d _ p a r t y / $ l i b " ] ; then
find " t h i r d _ p a r t y / $ l i b " - type f \
\ ! - path " t h i r d _ p a r t y / $ l i b / c h r o m i u m / * " \
\ ! - path " t h i r d _ p a r t y / $ l i b / g o o g l e / * " \
\ ! - path " t h i r d _ p a r t y / h a r f b u z z - n g / u t i l s / h b _ s c o p e d . h " \
\ ! - regex ' . * \ . \ ( gn \ | gni \ | isolate \ ) ' \
- delete
fi
done
2020-08-26 12:22:31 +00:00
# Required for patchShebangs (unsupported interpreter directive, basename: invalid option -- '*', etc.):
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
substituteInPlace native_client/SConstruct - - replace " # ! - * - p y t h o n - * - " " "
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 " / u s r / b i n / e n v - S m a k e - f " " / u s r / b i n / m a k e - f "
fi
2021-05-30 13:10:00 +00:00
chmod - x third_party/webgpu-cts/src/tools/deno
2020-10-07 11:39:57 +00:00
2016-08-04 19:26:05 +00:00
# We want to be able to specify where the sandbox is via CHROME_DEVEL_SANDBOX
substituteInPlace sandbox/linux/suid/client/setuid_sandbox_host.cc \
- - replace \
2016-08-05 09:55:48 +00:00
' return sandbox_binary ; ' \
' return base::FilePath ( GetDevelSandboxPath ( ) ) ; '
2016-08-04 19:26:05 +00:00
2019-01-30 22:55:20 +00:00
substituteInPlace services/audio/audio_sandbox_hook_linux.cc \
- - replace \
' /usr/share/alsa / ' \
2021-06-10 02:57:09 +00:00
' $ { alsa-lib } /share/alsa / ' \
2019-01-30 22:55:20 +00:00
- - replace \
' /usr/lib/x86_64-linux-gnu/gconv / ' \
' $ { glibc } /lib/gconv / ' \
- - replace \
' /usr/share/locale / ' \
' $ { glibc } /share/locale / '
2021-02-01 08:05:09 +00:00
sed - i - e ' s @ " \( # ! \) \? . * x d g - @ " \ 1 $ { xdg-utils } /bin/xdg- @ ' \
2017-03-07 10:10:58 +00:00
chrome/browser/shell_integration_linux.cc
2020-08-12 18:12:16 +00:00
sed - i - e ' /lib_loader. * Load/s ! " \( l i b u d e v \. s o \) ! " $ { lib . getLib systemd } /lib / \ 1 ! ' \
2015-01-23 00:48:56 +00:00
device/udev_linux/udev ? _loader . cc
sed - i - e ' /libpci_loader. * Load/s ! " \( l i b p c i \. s o \) ! " $ { pciutils } /lib / \ 1 ! ' \
gpu/config/gpu_info_collector_linux.cc
2016-05-28 17:04:22 +00:00
2017-06-18 02:29:22 +00:00
# Allow to put extensions into the system-path.
sed - i - e ' s , /usr , /run/current-system/sw , ' chrome/common/chrome_paths.cc
2016-10-29 02:05:53 +00:00
patchShebangs .
2017-05-14 13:03:21 +00:00
# use our own nodejs
mkdir - p third_party/node/linux/node-linux-x64/bin
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
ln - s " $ ( c o m m a n d - v n o d e ) " 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
2017-07-06 22:54:10 +00:00
2018-01-21 13:31:54 +00:00
'' + o p t i o n a l S t r i n g s t d e n v . i s A a r c h 6 4 ''
substituteInPlace build/toolchain/linux/BUILD.gn \
- - replace ' toolprefix = " a a r c h 6 4 - l i n u x - g n u - " ' ' toolprefix = " " '
2020-12-09 18:13:26 +00:00
'' + o p t i o n a l S t r i n g u n g o o g l e d ''
$ { ungoogler } /utils/prune_binaries.py . $ { ungoogler } /pruning.list || echo " s o m e e r r o r s "
$ { ungoogler } /utils/patches.py . $ { ungoogler } /patches
$ { ungoogler } /utils/domain_substitution.py apply - r $ { ungoogler } /domain_regex.list - f $ { ungoogler } /domain_substitution.list - c ./ungoogled-domsubcache.tar.gz .
2014-04-01 05:36:26 +00:00
'' ;
2020-07-14 20:52:15 +00:00
gnFlags = mkGnFlags ( {
2021-02-05 13:29:47 +00:00
is_official_build = true ;
chromium: use official build settings (#101467)
LLD: https://lld.llvm.org/
When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though.
Link-time optimization (LTO) is supported by default.
Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security.
LTO & ThinLTO: https://clang.llvm.org/docs/ThinLTO.html
LTO (Link Time Optimization) achieves better runtime performance through whole-program analysis and cross-module optimization. However, monolithic LTO implements this by merging all input into a single module, which is not scalable in time or memory, and also prevents fast incremental compiles. ThinLTO is a new approach that is designed to scale like a non-LTO build, while retaining most of the performance achievement of full LTO.
PGO: https://llvm.org/docs/HowToBuildWithPGO.html https://blog.chromium.org/2020/08/chrome-just-got-faster-with-profile.html
Allows your compiler to better optimize code for how it actually runs. Users report that applying this to Clang and LLVM can decrease overall compile time by 20%.
Because PGO uses real usage scenarios that match the workflows of Chrome users around the world, the most common tasks get prioritized and made faster. Delivers up to 10% faster page loads.
CFI: https://clang.llvm.org/docs/ControlFlowIntegrity.html https://www.chromium.org/developers/testing/control-flow-integrity
Aborts the program upon detecting certain forms of undefined behavior that can potentially allow attackers to subvert the program’s control flow. These schemes have been optimized for performance, allowing developers to enable them in release builds.
By default, a program compiled with CFI will crash with SIGILL if it detects a CFI violation.
Additionally:
Use minizip instead of zlib. Chromium says zlib but actually uses minizip.
Remove old unused workarounds.
Make shell scripts POSIX compliant.
Update documentation URLs.
Prepare for using system libraries.
2020-10-24 10:27:40 +00:00
custom_toolchain = " / / b u i l d / t o o l c h a i n / l i n u x / u n b u n d l e : d e f a u l t " ;
host_toolchain = " / / b u i l d / t o o l c h a i n / l i n u x / u n b u n d l e : d e f a u l t " ;
2021-02-05 13:29:47 +00:00
system_wayland_scanner_path = " ${ wayland } / b i n / w a y l a n d - s c a n n e r " ;
2016-03-28 09:31:21 +00:00
2015-12-29 18:32:30 +00:00
use_sysroot = false ;
2014-04-01 05:36:26 +00:00
use_gnome_keyring = gnomeKeyringSupport ;
use_gio = gnomeSupport ;
2019-12-14 18:07:28 +00:00
# ninja: error: '../../native_client/toolchain/linux_x86/pnacl_newlib/bin/x86_64-nacl-objcopy',
# needed by 'nacl_irt_x86_64.nexe', missing and no known rule to make it
enable_nacl = false ;
2019-12-14 18:52:43 +00:00
# Enabling the Widevine component here doesn't affect whether we can
# redistribute the chromium package; the Widevine component is either
# added later in the wrapped -wv build or downloaded from Google.
2019-08-10 23:09:55 +00:00
enable_widevine = true ;
2014-04-01 05:36:26 +00:00
use_cups = cupsSupport ;
2020-06-05 19:52:41 +00:00
# Provides the enable-webrtc-pipewire-capturer flag to support Wayland screen capture.
rtc_use_pipewire = true ;
2017-07-31 08:01:15 +00:00
2016-10-29 02:05:53 +00:00
treat_warnings_as_errors = false ;
2017-07-31 08:01:15 +00:00
clang_use_chrome_plugins = false ;
2019-06-05 09:06:03 +00:00
blink_symbol_level = 0 ;
2020-10-09 21:24:20 +00:00
symbol_level = 0 ;
2017-07-31 08:01:15 +00:00
fieldtrial_testing_like_official_build = true ;
2014-04-01 05:36:26 +00:00
2021-03-03 12:02:48 +00:00
# Google API key, see: https://www.chromium.org/developers/how-tos/api-keys
# Note: The API key is for NixOS/nixpkgs use ONLY.
# For your own distribution, please get your own set of keys.
2014-04-01 05:36:26 +00:00
google_api_key = " A I z a S y D G i 1 5 Z w l 1 1 U N e 6 Y - 5 X W _ u p s f y w 3 1 q w Z P I " ;
} // optionalAttrs proprietaryCodecs {
# enable support for the H.264 codec
proprietary_codecs = true ;
2015-10-07 16:42:24 +00:00
enable_hangout_services_extension = true ;
2014-04-01 05:36:26 +00:00
ffmpeg_branding = " C h r o m e " ;
2016-10-29 02:05:53 +00:00
} // optionalAttrs pulseSupport {
use_pulseaudio = true ;
link_pulseaudio = true ;
2021-01-28 21:06:23 +00:00
# Disable PGO (defaults to 2 since M89) because it fails without additional changes:
# error: Could not read profile ../../chrome/build/pgo_profiles/chrome-linux-master-1610647094-405a32bcf15e5a84949640f99f84a5b9f61e2f2e.profdata: Unsupported instrumentation profile format version
chrome_pgo_phase = 0 ;
2021-02-01 00:25:53 +00:00
# Disable build with TFLite library because it fails without additional changes:
# ninja: error: '../../chrome/test/data/simple_test.tflite', needed by 'test_data/simple_test.tflite', missing and no known rule to make it
# Note: chrome/test/data/simple_test.tflite is in the Git repository but not in chromium-90.0.4400.8.tar.xz
# See also chrome/services/machine_learning/README.md
build_with_tflite_lib = false ;
2020-12-09 18:13:26 +00:00
} // optionalAttrs ungoogled {
chrome_pgo_phase = 0 ;
enable_hangout_services_extension = false ;
enable_js_type_check = false ;
enable_mdns = false ;
enable_nacl_nonsfi = false ;
enable_one_click_signin = false ;
enable_reading_list = false ;
enable_remoting = false ;
enable_reporting = false ;
enable_service_discovery = false ;
exclude_unwind_tables = true ;
google_api_key = " " ;
google_default_client_id = " " ;
google_default_client_secret = " " ;
safe_browsing_mode = 0 ;
use_official_google_api_keys = false ;
use_unofficial_version_number = false ;
2016-10-29 02:05:53 +00:00
} // ( extraAttrs . gnFlags or { } ) ) ;
2014-04-01 05:36:26 +00:00
configurePhase = ''
2017-02-08 19:48:05 +00:00
runHook preConfigure
2014-04-01 05:36:26 +00:00
# This is to ensure expansion of $out.
libExecPath = " ${ libExecPath } "
2021-05-08 17:55:29 +00:00
$ { python2 } /bin/python2 build/linux/unbundle/replace_gn_files.py - - system-libraries $ { toString gnSystemLibraries }
2020-04-03 17:17:57 +00:00
$ { gnChromium } /bin/gn gen - - args = $ { escapeShellArg gnFlags } out/Release | tee gn-gen-outputs . txt
2018-06-19 00:48:42 +00:00
# Fail if `gn gen` contains a WARNING.
grep - o WARNING gn-gen-outputs . txt && echo " F o u n d g n W A R N I N G , e x i t i n g n i x b u i l d " && exit 1
2017-02-08 19:48:05 +00:00
runHook postConfigure
2014-04-01 05:36:26 +00:00
'' ;
2020-04-02 22:02:23 +00:00
# Don't spam warnings about unknown warning options. This is useful because
# our Clang is always older than Chromium's and the build logs have a size
# of approx. 25 MB without this option (and this saves e.g. 66 %).
NIX_CFLAGS_COMPILE = " - W n o - u n k n o w n - w a r n i n g - o p t i o n " ;
2014-04-01 05:36:26 +00:00
buildPhase = let
2014-08-13 02:49:53 +00:00
buildCommand = target : ''
2020-10-16 12:54:34 +00:00
ninja - C " ${ buildPath } " - j $ NIX_BUILD_CORES - l $ NIX_BUILD_CORES " ${ target } "
2017-11-08 22:44:20 +00:00
(
source chrome/installer/linux/common/installer.include
PACKAGE = $ packageName
MENUNAME = " C h r o m i u m "
process_template chrome/app/resources/manpage.1.in " ${ buildPath } / c h r o m e . 1 "
)
2014-04-25 01:58:33 +00:00
'' ;
targets = extraAttrs . buildTargets or [ ] ;
commands = map buildCommand targets ;
in concatStringsSep " \n " commands ;
2019-07-15 06:35:03 +00:00
postFixup = ''
# Make sure that libGLESv2 is found by dlopen (if using EGL).
chromiumBinary = " $ l i b E x e c P a t h / $ p a c k a g e N a m e "
origRpath = " $ ( p a t c h e l f - - p r i n t - r p a t h " $ chromiumBinary " ) "
patchelf - - set-rpath " ${ libGL } / l i b : $ o r i g R p a t h " " $ c h r o m i u m B i n a r y "
'' ;
2019-11-06 19:37:25 +00:00
2020-11-03 12:08:09 +00:00
passthru = {
updateScript = ./update.py ;
chromiumDeps = {
gn = gnChromium ;
} ;
} ;
2014-04-01 05:36:26 +00:00
} ;
# Remove some extraAttrs we supplied to the base attributes already.
in stdenv . mkDerivation ( base // removeAttrs extraAttrs [
2016-10-29 02:05:53 +00:00
" n a m e " " g n F l a g s " " b u i l d T a r g e t s "
2019-11-06 19:37:25 +00:00
] // { passthru = base . passthru // ( extraAttrs . passthru or { } ) ; } )