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

A bit help in building Ungoogled-Chromium #1256

Closed
TCH68k opened this issue Nov 18, 2020 · 100 comments
Closed

A bit help in building Ungoogled-Chromium #1256

TCH68k opened this issue Nov 18, 2020 · 100 comments

Comments

@TCH68k
Copy link

TCH68k commented Nov 18, 2020

Hello,

I would like to build Ungoogled-Chromium, but i stucked, because there is no description how i connect the sources here to the official Chromium sources.

I've read the building.md here: https://github.com/Eloston/ungoogled-chromium/blob/master/docs/building.md
It says it will assume that i can build Chromium on my own. I can, but what after? Or before? I do not understand, i should put Chromium sources into a directory inside Ungoogled-Chromium or copy the files of Ungoogled-Chromium into the directory of Chromium? The description does not cover this part...

@Luka-Filipovic
Copy link

Open repo for platform you want to build for. (link)
First part of the build process is downloading of chromium source and all necessary dependencies and it's all automated as long as you follow instractions on platform repo you chose.

@TCH68k
Copy link
Author

TCH68k commented Nov 18, 2020

I have already checked these.

I use Debian, but i cannot use that description as they only support latest Debian (10.0 Buster) and i have an older one (9.0 Stretch).

As for the portable Linux, i tried that, but after

wget https://github.com/ungoogled-software/ungoogled-chromium-portablelinux/archive/86.0.4240.183-1.1.tar.gz
untgz 86.0.4240.183-1.1.tar.gz
rm 86.0.4240.183-1.1.tar.gz
cd ungoogled-chromium-portablelinux-86.0.4240.183-1.1/
./build.sh

I only get the message

/build.sh: sor: 16: /media/WORKDISK/r/downloads/ungoogled-chromium-portablelinux-86.0.4240.183-1.1/ungoogled-chromium/utils/downloads.py: No such file or directory

@Luka-Filipovic
Copy link

Luka-Filipovic commented Nov 18, 2020

It seems like you are missing the core submodule. Try git update submodule --init, if its not working try to manually download and extract ungoogled-chromium.

EDIT:
git submodule update --init is the right command

@TCH68k
Copy link
Author

TCH68k commented Nov 18, 2020

There is no git involved, i tried to use a source package, because if i follow the git instructions on the portable Linux page

git clone --recurse-submodules https://github.com/ungoogled-software/ungoogled-chromium-portablelinux.git
cd ungoogled-chromium-portablelinux
git checkout --recurse-submodules 86.0.4240.183-1.1
error: unknown option `recurse-submodules'

If i try to do

git checkout 86.0.4240.183-1.1

then it works, but still miss the utils dir. If i try your command

git update submodule --init

Then

git: 'update' is not a git command. See 'git --help'.

Did you mean this?
        update-ref

I've already downloaded and extracted the package from that repo, but as i asked in the OP: what then? It has no "build.sh" like the portable Linux repo. What should i do with those files? No manual or guide covers this part.

@Luka-Filipovic
Copy link

Luka-Filipovic commented Nov 18, 2020

Sorry, I swapped two commands. It should be git submodule update --init
So inside of ungoogled-chromium-portablelinux folder you should extract ungoogled-chromium. Command above should do it automatically.

@TCH68k
Copy link
Author

TCH68k commented Nov 19, 2020

Ah, i see, now it started to build with these commands:

git clone --recurse-submodules https://github.com/ungoogled-software/ungoogled-chromium-portablelinux.git
cd ungoogled-chromium-portablelinux
git checkout 86.0.4240.183-1.1
git submodule update --init
./build.sh

Please update the building instructions, because the command you've just suggested is missing from it and also

git checkout --recurse-submodules TAG_OR_BRANCH_HERE

should be just

git checkout TAG_OR_BRANCH_HERE

Also, the information about manually extracting ungoogled-chromium into ungoogled-chromium-portablelinux is missing from the manual.

Now i am facing a different problem: it needs GTK3 by default. I've checked if i can tweak this by editing ungoogled-chromium-portablelinux/build/src/build/config/linux/gtk/gtk.gni, but the answer was negative.
It's strange as i have normal Chromium 73.0.3683.75 here, built on GTK2 and that particular file was the same...
How can i force building on GTK2? Or it is fully abandoned, no chance? In that case, can you please tell me what was the last Chromium which was able to build on GTK2?

@TCH68k
Copy link
Author

TCH68k commented Nov 25, 2020

Okay, i've tried to build with 72.0.3626.122-4.1 which is the earliest ungoogled-chromium i found. But this also have failed to build:

ERROR at //build/config/linux/pkg_config.gni:103:17: Script returned non-zero exit code.
    pkgresult = exec_script(pkg_config_script, args, "value")
                ^----------
Current dir: /media/WORKDISK/r/downloads/ungoogled-chromium-portablelinux/build/src/out/Default/
Command: python /media/WORKDISK/r/downloads/ungoogled-chromium-portablelinux/build/src/build/config/linux/pkg-config.py gmodule-2.0 gtk+-3.0 gthread-2.0
Returned 1.
stderr:

Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-3.0' found
Could not run pkg-config.

See //build/config/linux/gtk/BUILD.gn:13:1: whence it was called.
pkg_config("gtk_internal_config") {
^----------------------------------
See //chrome/test/BUILD.gn:3915:15: which caused the file to be included.
    deps += [ "//build/config/linux/gtk" ]
              ^-------------------------

And this is clearly not possible. I have Chromium 73 here which were built upon GTK2 successfully and this was earlier than that. Unfortunately i do not remember how can i force GTK2 build. Can you help me please?

@TCH68k
Copy link
Author

TCH68k commented Dec 9, 2020

Hello? A bit of help please? Or can you tell me where can i get help about this?

@wchen342
Copy link
Contributor

Try add use_gtk3=false in gn flags.

@TCH68k
Copy link
Author

TCH68k commented Dec 12, 2020

I've tried that, but it has yielded the very same results: no gtk3 found. This was Chromium 72.0.3626.122-4.1 and here is a Chromium 73.0.3683.75 which uses GTK2: https://debian.pkgs.org/9/debian-main-amd64/chromium_73.0.3683.75-1~deb9u1_amd64.deb.html
It must be possible somehow.

@TCH68k
Copy link
Author

TCH68k commented Dec 12, 2020

I cannot edit my last post and i forgot to post what files i've modified:

echo "use_gtk3=false" >> flags.portable.gn
echo "use_pulseaudio=false" >> flags.portable.gn
echo "use_gtk3=false" >> ungoogled-chromium/flags.gn
echo "use_pulseaudio=false" >> ungoogled-chromium/flags.gn

@TCH68k
Copy link
Author

TCH68k commented Dec 20, 2020

Okay, it turned out, that the Debian team has patched their Chrome 73. Here are the patches: http://deb.debian.org/debian/pool/main/c/chromium/chromium_73.0.3683.75-1~deb9u1.debian.tar.xz
Inside there is a GTK2 patch. However, this patch is for Chromium 73 and there is no Ungoogled-Chromium 73 package in the repo you've suggested. I've tried to build the v75, but that failed.

How can i make the buildscript fetch Chromium 73?

@wchen342
Copy link
Contributor

Are you trying to build portable version on Debian? There is a debian repo: https://github.com/ungoogled-software/ungoogled-chromium-debian.

@TCH68k
Copy link
Author

TCH68k commented Dec 22, 2020

I've already checked this repo, but it only supports Buster (10.0) and i have Stretch (9.0).
This portable one would be good, but unfortunately the one version which would be good for me (73.0.3683.75-1) is not available in their repository: https://github.com/ungoogled-software/ungoogled-chromium-portablelinux/releases?after=75.0.3770.100-1.1

After 72.0.3626.122-4.1, there is only 75.0.3770.80-1.1.
How can i tell the buildscript to fetch a different chromium? Change the script itself?

@TCH68k
Copy link
Author

TCH68k commented Dec 22, 2020

Wrong phrasing, and i cannot edit my post...
By different chromium, i mean a direct link, or a different repo than the portable's. Or that will not work?

@wchen342
Copy link
Contributor

I looked at the Debian repo and it have v73 but only on Buster nad Bionic, so there is no Stretch from beginning unfortunately.
I think the best you can do is trying to manually apply the patches in the ofiicial debian repo first and then apply the ungoogled-chromium patches after.

@TCH68k
Copy link
Author

TCH68k commented Dec 22, 2020

Thanks, that is a great idea, i'll do that.
This is the correct dir, right? (https://github.com/Eloston/ungoogled-chromium/tree/master/patches)

@wchen342
Copy link
Contributor

You need to get the old v73 tag.

@mbakke
Copy link
Contributor

mbakke commented Dec 23, 2020

Note: if you just need version 73 specifically, you can install GNU Guix and run guix time-machine --commit=821222433ad37fd9a43dd4c7ccb9cef9f9249f6c -- build ungoogled-chromium (or install instead of build, etc).

Guix only has .86 and .103 from the 73.xx releases though (but getting to .75 from there is relatively easy).

Obviously you can also install the latest version with Guix.

@TCH68k
Copy link
Author

TCH68k commented Dec 23, 2020

@wchen342: Yes, you're right, i almost forgot. Thanks for pointing out.

@mbakke: Thanks for the tip. If i will not manage to build UGC by this two step patching setup, i'll try Guix.

@TCH68k
Copy link
Author

TCH68k commented Dec 23, 2020

The patching works. I've just patched Chromium 73.0.3683.75 with both the Debian and UGC patches. There were some files which did not exists (i mean anywhere, they were not just misplaced), but aside from that no errors.
However, when i tried to build Chromium by following the instructions at this page (https://chromium.googlesource.com/chromium/src/+/master/docs/linux/build_instructions.md), skipping the repository fetching, the build tools refused to build, because it is not a git repository directory. I then tried to do this:

cd /tmp/
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PATH:/tmp/depot_tools"
mkdir chromium
cd /tmp/chromium/
fetch --nohooks --no-history chromium
git checkout 73.0.3683.75
gclient sync
gclient runhooks
cp /d/ugc-patches/* ./
for PATCH in *.patch; do patch -p1 < $PATCH; done
rm *.patch
gn gen out/Release "--args=is_debug=false"
autoninja -C out/Default chrome

and it died with various Python error messages before even getting to the patching part.

The question is, is it possible to build Chromium from a release package file instead of a git repo?

@wchen342
Copy link
Contributor

wchen342 commented Dec 23, 2020

The python scripts coming with chromium/google needs python2, and the ungoogled-chromium ones need python3.

If your system has python3 as default, then you need a virtual env or conda environment to run those python2 ones.

@TCH68k
Copy link
Author

TCH68k commented Dec 23, 2020

Python2 was the default. It seems i've ran out of free space on my RAM disk...

I've put the build on my SSD. Now i have this script.

#!/bin/sh
cd /root
mkdir kocsog_gugli
cd kocsog_gugli

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/root/kocsog_gugli/depot_tools

mkdir chromium
cd chromium/
fetch --nohooks chromium
git checkout 73.0.3683.75
gclient sync
gclient runhooks
gn gen out/Release "--args=is_debug=false"
autoninja -C out/Default chrome

I've tried to run this subscript

cd src
cp /d/ugc-patches/* ./
for PATCH in *.patch; do; patch -p1 -f < $PATCH; done
rm *.patch
cd ..

after the command

gclient runhooks

and the patches which were worked before, failed. Tons of conflicts, failed patches and etc.
After which command i should do the patching?

@wchen342
Copy link
Contributor

Not sure. Can you poast the complete log?

@TCH68k
Copy link
Author

TCH68k commented Dec 26, 2020

Never mind that, i just forgot to cd into src.

Now i've made up until the building itself, altough i had to tweak a thing or two. The build itself fails with this error message:

[5/39239] CXX obj/base/base/message_pump_libevent.o
FAILED: obj/base/base/message_pump_libevent.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/base/base/message_pump_libevent.o.d -DUSE_SYMBOLIZE -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCR_CLANG_REVISION=\"351477-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -DCR_LIBCXX_REVISION=349080 -DCR_LIBCXXABI_REVISION=347903 -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_ABI_UNSTABLE -DCR_SYSROOT_HASH=e7c53f04bd88d29d075bfd1f62b073aeb69cbe09 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DBASE_IMPLEMENTATION -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -I../.. -Igen -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -fcomplete-member-pointers -m64 -march=x86-64 -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-ignored-pragma-optimize -fno-omit-frame-pointer -g0 -fvisibility=hidden -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-char-subscripts -Wglobal-constructors -Wexit-time-destructors -Wshadow -isystem../../build/linux/debian_sid_amd64-sysroot/usr/include/glib-2.0 -isystem../../build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wexit-time-destructors -O2 -fno-ident -fdata-sections -ffunction-sections -std=c++14 -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_sid_amd64-sysroot -fvisibility-inlines-hidden -c ../../base/message_loop/message_pump_libevent.cc -o obj/base/base/message_pump_libevent.o
../../base/message_loop/message_pump_libevent.cc:17:10: fatal error: 'event.h' file not found
#include <event.h>
         ^~~~~~~~~
1 error generated.

The problem is, that event.h is actually inside of /usr/include and the pkg-config package is also in it's place, yet clang fails to find it. I've tried to modify CFLAGS and CPPFLAGS to no avail.

My script is here:

#!/bin/sh
cd /root
mkdir kocsog_gugli 2>/dev/null
cd kocsog_gugli

echo "Getting depot tools..."
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/root/kocsog_gugli/depot_tools

echo "Getting Chromium source..."
mkdir chromium 2>/dev/null
cd chromium/
fetch --nohooks chromium

echo "Checkout and sync..."
cd src
git checkout 73.0.3683.75
gclient sync -D

# USE FONTCONFIG PATCH FROM UGC AND NOT FROM DEBIAN! The rest of the two patchset can be merged.
echo "Patching..."
cp /d/ugc-patches/* ./
for PATCH in *.patch
do
	echo "****************"
	echo "* ""$PATCH"
	echo "****************"
	patch -p1 -f < $PATCH
	echo "****************"
	echo
done
rm *.patch
sed -i.bak 's/  gtk_version = 3/  gtk_version = 2/g' build/config/linux/gtk/gtk.gni

# Safe browsing patch is erroneous with chrome 73.0.
sed -i.bak '/^static_library("safe_browsing") {/i sources = []' chrome/browser/safe_browsing/BUILD.gn
sed -i.bak '/^static_library("safe_browsing") {/i deps = []' chrome/browser/safe_browsing/BUILD.gn

echo "Generating..."
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig/
gn gen out/Release "--args=is_debug=false"

echo "Build..."
autoninja -C out/Release chrome

#TODO: package

@wchen342
Copy link
Contributor

I think ninja doesn't use pkg_config. I faced similar problems before but they are hard to solve. Everytime it requires a different solution. In this case the quickiest way is probably just copy the file into src folder and modify the .cc and .gn files accordingly.

@TCH68k
Copy link
Author

TCH68k commented Dec 27, 2020

I think ninja does use pkg_config, that is why i had to modify $PKG_CONFIG_PATH before generating, because it did not find libopenjp2.pc.
I tried your suggestion to change #include <event.h> to `#include "event.h" and copy it into the dir. The result is this:

[2/39203] CXX obj/base/base/message_pump_libevent.o
FAILED: obj/base/base/message_pump_libevent.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/base/base/message_pump_libevent.o.d -DUSE_SYMBOLIZE -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCR_CLANG_REVISION=\"351477-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -DCR_LIBCXX_REVISION=349080 -DCR_LIBCXXABI_REVISION=347903 -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_ABI_UNSTABLE -DCR_SYSROOT_HASH=e7c53f04bd88d29d075bfd1f62b073aeb69cbe09 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DBASE_IMPLEMENTATION -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -I../.. -Igen -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -fcomplete-member-pointers -m64 -march=x86-64 -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-ignored-pragma-optimize -fno-omit-frame-pointer -g0 -fvisibility=hidden -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-char-subscripts -Wglobal-constructors -Wexit-time-destructors -Wshadow -isystem../../build/linux/debian_sid_amd64-sysroot/usr/include/glib-2.0 -isystem../../build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wexit-time-destructors -O2 -fno-ident -fdata-sections -ffunction-sections -std=c++14 -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_sid_amd64-sysroot -fvisibility-inlines-hidden -c ../../base/message_loop/message_pump_libevent.cc -o obj/base/base/message_pump_libevent.o
In file included from ../../base/message_loop/message_pump_libevent.cc:17:
../../base/message_loop/event.h:44:10: fatal error: 'event2/event-config.h' file not found
#include <event2/event-config.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

It seems, ninja simply does not see /usr/include at all.

@wchen342
Copy link
Contributor

That's strange. What if you try to run the clang command separately in the terminal? And also run it with environment variables?

@TCH68k
Copy link
Author

TCH68k commented Dec 28, 2020

Okay, i tried. First it gave me an error:

error: unable to open output file 'obj/base/base/message_pump_libevent.o': 'No
      such file or directory'
1 error generated.

Then i've ran ln -s ../../out/Release/obj obj and tried it again, with the following result:

In file included from ../../base/message_loop/message_pump_libevent.cc:5:
In file included from ../../base/message_loop/message_pump_libevent.h:13:
In file included from ../../base/message_loop/watchable_io_message_pump_posix.h:8:
../../base/location.h:14:10: fatal error: 'base/debug/debugging_buildflags.h'
      file not found
#include "base/debug/debugging_buildflags.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Then i've ran ln -s ../../out/Release/gen/base/debug/debugging_buildflags.h ../debug/debugging_buildflags.h and tried it yet again, only to get the first message again:

../../base/message_loop/message_pump_libevent.cc:17:10: fatal error: 'event.h'
      file not found
#include <event.h>
         ^~~~~~~~~
1 error generated.

This custom clang what the builder had downloaded is simply do not see /usr/include at all. If i added -I/usr/include to the command by hand, then it has finally found event.h, but yielded a lot of other errors about missing macros (probably because this should be ran from the building environment and not by hand). However, i have no idea how can i force this build environment to add -I/usr/include to all clang calls...

What do you mean by /"run it with environment variables"/? CPPFLAGS and CFLAGS? I've already tried that. Or something else?

@wchen342
Copy link
Contributor

From your description it seems ninja is not passing whatever you set on command line to clang++. You can try this:

Open src/build/config/compiler/BUILD.gn, find around line 200+ there are a set of variables. They are named cflags, cflags_cc, ldflags and so on. Parameters set here are passed to the corresponding compiler/linkers when ninja calls them, so try adding whatever worked for you (-I/usr/include?) to the corresponding list.

@TCH68k
Copy link
Author

TCH68k commented Jan 7, 2021

Almost done, but a few undefined symbol popped up at the eleventh hour again...

[13059/13293] SOLINK ./libcontent.so
FAILED: libcontent.so libcontent.so.TOC
python "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libcontent.so" --tocfile="./libcontent.so.TOC" --output="./libcontent.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -rdynamic -nostdlib++ -Wl,-rpath=\$ORIGIN/. -Wl,-rpath-link=. -o "./libcontent.so" -Wl,-soname="libcontent.so" @"./libcontent.so.rsp"
ld.lld: error: undefined symbol: switches::kFingerprintingClientRectsNoise
>>> referenced by runtime_features.cc:0 (../../content/child/runtime_features.cc:0)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasMeasureTextNoise
>>> referenced by runtime_features.cc:481 (../../content/child/runtime_features.cc:481)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasImageDataNoise
>>> referenced by runtime_features.cc:483 (../../content/child/runtime_features.cc:483)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))

ld.lld: error: undefined symbol: switches::kFingerprintingClientRectsNoise
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasMeasureTextNoise
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasImageDataNoise
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

What is this "fingerprinting" stuff? Is it necessary?

@wchen342
Copy link
Contributor

wchen342 commented Jan 8, 2021

This is probably caused by is_debug=true. If the function calls linker is referring to is surrended by IF IS_DEBUG macros then you can just delete them.

It comes from patches/extra/bromite/flag-fingerprinting-canvas-image-data-noise.patch. It adds fingerprinting resistence flags but they are disabled by defualt, so if you don't need those you can just ignore the fingerprinting related patches.

@TCH68k
Copy link
Author

TCH68k commented Jan 9, 2021

Unfortunately it is not the case. No IF IS_DEBUG macros around the calls and the patch you've referred to actually does not adds kFingerprintingClientRectsNoise to anywhere, just adds further calls beside kFingerprintingClientRectsNoise. I've checked where is this function defined and it is third_party/ungoogled/ungoogled_switches.cc:

#include "third_party/ungoogled/ungoogled_switches.h"

namespace switches {

// Enable fingerprinting deception for getClientRects and getBoundingClientRect
const char kFingerprintingClientRectsNoise[] = "fingerprinting-client-rects-noise";

// Enable fingerprinting deception for measureText
const char kFingerprintingCanvasMeasureTextNoise[] = "fingerprinting-canvas-measuretext-noise";

// Enable fingerprinting deception for Canvas image data
const char kFingerprintingCanvasImageDataNoise[] = "fingerprinting-canvas-image-data-noise";

}  // namespace switches

Perhaps not the function but the including of this file's header is surrounded by IF IS_DEBUG macros? Where is this libcontent?

@wchen342
Copy link
Contributor

The actual file that called the function is in runtime_features.cc as the error messages showed. I am not sure why the linker cannot find the function. Maybe do a search in you BUILD.gn files and see whether ungoogled_switches.h and ungoogled_switches.cc are correctly included? Also check whether these files actually exists and are in correct locations.

@TCH68k
Copy link
Author

TCH68k commented Jan 11, 2021

It is included in runtime_features.cc, but no debug macros there. However, it is not included in content/child/BUILD.gn. I've added these two files into the sources array, but the result is:

[1/1] Regenerating ninja files
ninja: error: '../../content/child/ungoogled_switches.cc', needed by 'obj/content/child/child/ungoogled_switches.o', missing and no known rule to make it

The deps array contains an entry of "//third_party/ungoogled:switches",.

The two files do exists and they are in third_party/ungoogled/. But i don't know how to tell the BUILD.gn to include them properly.

@wchen342
Copy link
Contributor

That doesn't look right, how did you add the files? Also isn't the dependecy //components/ungoogled:ungoogled_switches?

Can you run

grep -rIEC 5 --exclude-dir=out 'ungoogled.?switches' .

in your src folder and post the results?

@TCH68k
Copy link
Author

TCH68k commented Jan 12, 2021

I added the files by hand into the BUILD.gn's source variable. I have no idea what is the dependency, it was in the deps what i wrote in my last post.

I've ran the command and here is the result: http://oscomp.hu/depot/switches.log

@wchen342
Copy link
Contributor

Never mind the dependency name. It was the old name and new name changed recently.

Your gn files looks fine to me. I think probably ninja messed things up. Maybe you shall backup the out folder, and then try removing all .ninja files and regenerate using gn?

@TCH68k
Copy link
Author

TCH68k commented Jan 13, 2021

I did so. Backed up the out/Release dir, removed the .ninja files and then ran

gn gen out/Release "--args=`cat flags.gn | tr '\n' ' '`"

again. The result is the same as it was before.

@wchen342
Copy link
Contributor

That doesn't make sense. ninja shouldn't be looking for content/child/ungoogled_switches.cc unless there is an entry of ungoogled_switches.cc in one of the source array of content/child/BUILD.gn, but I didn't see that from your grep output.

Maybe try just copying the files manually.

@TCH68k
Copy link
Author

TCH68k commented Jan 13, 2021

My bad, i was misunderstandable. So, i've ran

gn gen out/Release "--args=`cat flags.gn | tr '\n' ' '`"

That worked, but then i ran

autoninja -C out/Release chrome

And that resulted in the same error as before:

[1/235] SOLINK ./libcontent.so
FAILED: libcontent.so libcontent.so.TOC
python "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libcontent.so" --tocfile="./libcontent.so.TOC" --output="./libcontent.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -rdynamic -nostdlib++ -Wl,-rpath=\$ORIGIN/. -Wl,-rpath-link=. -o "./libcontent.so" -Wl,-soname="libcontent.so" @"./libcontent.so.rsp"
ld.lld: error: undefined symbol: switches::kFingerprintingClientRectsNoise
>>> referenced by runtime_features.cc:0 (../../content/child/runtime_features.cc:0)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasMeasureTextNoise
>>> referenced by runtime_features.cc:481 (../../content/child/runtime_features.cc:481)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasImageDataNoise
>>> referenced by runtime_features.cc:483 (../../content/child/runtime_features.cc:483)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))

ld.lld: error: undefined symbol: switches::kFingerprintingClientRectsNoise
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasMeasureTextNoise
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasImageDataNoise
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

As for content/child/BUILD.gn, the variable array deps contains

    "//third_party/ungoogled:switches",

The one, you've said is the old one.

@wchen342
Copy link
Contributor

I'm running out of ideas..check whether third_party/ungoogled/ungoogled_switches.h is correctly included in content/child/runtime_features.cc and content/browser/renderer_host/render_process_host_impl.cc?

Also once I had a problem with a lld bug, so try a slightly higher or lower version of lld.

@TCH68k
Copy link
Author

TCH68k commented Jan 14, 2021

In both files this line exists:

#include "third_party/ungoogled/ungoogled_switches.h"

As for lld, isn't Chromium's building system supplies it's own of it at third_party/llvm-build/Release+Asserts/bin/lld? (It's 9.0, i've checked it.)
I actually have no any own symlink of lld; there is CLang 12's at /usr/lib/llvm-12/bin/lld, but it's not in the $PATH and has not been symlinked as lld at anywhere in my filesystem.

Still, i tried what will happen. I've created the symlinks of lld and ld.lld and renamed the building systems's one to lld1. Result is slightly differently formatted

[1/235] SOLINK ./libcontent.so
FAILED: libcontent.so libcontent.so.TOC
python "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libcontent.so" --tocfile="./libcontent.so.TOC" --output="./libcontent.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -rdynamic -nostdlib++ -Wl,-rpath=\$ORIGIN/. -Wl,-rpath-link=. -o "./libcontent.so" -Wl,-soname="libcontent.so" @"./libcontent.so.rsp"
ld.lld: error: undefined symbol: switches::kFingerprintingClientRectsNoise
>>> referenced by runtime_features.cc:0 (../../content/child/runtime_features.cc:0)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasMeasureTextNoise
>>> referenced by runtime_features.cc:481 (../../content/child/runtime_features.cc:481)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)

ld.lld: error: undefined symbol: switches::kFingerprintingCanvasImageDataNoise
>>> referenced by runtime_features.cc:483 (../../content/child/runtime_features.cc:483)
>>>               obj/content/child/child/runtime_features.o:(content::SetRuntimeFeaturesDefaultsAndUpdateFromArgs(base::CommandLine const&))
>>> referenced by render_process_host_impl.cc
>>>               obj/content/browser/browser/render_process_host_impl.o:(content::RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(base::CommandLine const&, base::CommandLine*)::kSwitchNames)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

but otherwise identical: three missing symbols (switches::kFingerprintingClientRectsNoise, switches::kFingerprintingCanvasMeasureTextNoise, switches::kFingerprintingCanvasImageDataNoise) in two files (runtime_features.cc, render_process_host_impl.cc).

@wchen342
Copy link
Contributor

Does ungoogled_switches.o exists at all in out/Default/obj?

@TCH68k
Copy link
Author

TCH68k commented Jan 14, 2021

It does at out/Release/obj/third_party/ungoogled/switches/ungoogled_switches.o and it contains the symbols too:

ungoogled_switches.o:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    df *ABS*  0000000000000000 ungoogled_switches.cc
0000000000000000 g     O .rodata        0000000000000022 .hidden _ZN8switches31kFingerprintingClientRectsNoiseE
0000000000000060 g     O .rodata        0000000000000027 .hidden _ZN8switches35kFingerprintingCanvasImageDataNoiseE
0000000000000030 g     O .rodata        0000000000000028 .hidden _ZN8switches37kFingerprintingCanvasMeasureTextNoiseE

@wchen342
Copy link
Contributor

wchen342 commented Jan 14, 2021

So basically it seems lld doesn't see the file at all. I am not sure whether you can manually add the search path. I have no more ideas now since I am not an expert in cpp.

EDIT: if you run the gcc_solink_wrapper.py line manually with the addition of -rpath to the folder containing ungoogled_switches.o, will it work?

As a last resort, you can probably just ignore the patches about the fingerprinting flags. They are not enabled by default and known to cause problems on some sites, so you can just ignore them.

@TCH68k
Copy link
Author

TCH68k commented Jan 15, 2021

I've ran

python "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libcontent.so" --tocfile="./libcontent.so.TOC" --output="./libcontent.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -rdynamic -nostdlib++ -Wl,-rpath=obj/third_party/ungoogled/switches/ -Wl,-rpath-link=. -o "./libcontent.so" -Wl,-soname="libcontent.so" @"./libcontent.so.rsp"

in out/Release. The result is the same.

I would like to avoid restarting the entire building... Can i revoke the patches somehow and force the buildsystem to build only what has changed?
Also, what exactly these fingerprinting patches about?

@wchen342
Copy link
Contributor

Actually it should be rpath-link, sorry.

If you know the basic knowledge about C++ then you can just remove the #include and the mention to those variables causing the problem.

The patches added flags you can enable to add random noise to Canvas, which can potentially be used by website to uniquely identify your browser. But there are extensions does this too, like Privacy Badger.

@TCH68k
Copy link
Author

TCH68k commented Jan 15, 2021

Tried that too already, same result.

I did so, now only the final binary cannot be linked because crc32 is a missing symbol.

[240/240] LINK ./chrome
FAILED: chrome
python "../../build/toolchain/gcc_link_wrapper.py" --output="./chrome" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -rdynamic -nostdlib++ -pie -Wl,-rpath-link=. -Wl,--disable-new-dtags -Wl,-rpath=\$ORIGIN/. -Wl,-rpath-link=. -o "./chrome" -Wl,--start-group @"./chrome.rsp" ./libembedder.so ./libbase.so ./libbindings.so ./libbindings_base.so ./libmojo_public_system_cpp.so ./libmojo_public_system.so ./libmojo_cpp_platform.so ./libmessage_support.so ./libmojo_mojom_bindings.so ./libmojo_mojom_bindings_shared.so ./liburl.so ./libmojo_base_mojom_shared.so ./libmojo_base_mojom.so ./libmojo_base_lib.so ./libmojo_base_shared_typemap_traits.so ./libbase_i18n.so ./libicui18n.so ./libicuuc.so ./libnet.so ./libprotobuf_lite.so ./libcrcrypto.so ./libboringssl.so ./libipc.so ./libipc_mojom.so ./libipc_mojom_shared.so ./libcontent_public_common_mojo_bindings_shared.so ./libblink_mojo_bindings_shared.so ./libblink_android_mojo_bindings_shared.so ./libweb_feature_mojo_bindings_mojom_shared.so ./libservice_manager_mojom_shared.so ./libservice_manager_mojom_constants_shared.so ./libmojom_platform_shared.so ./libandroid_mojo_bindings_shared.so ./libspeech_recognition_error_code_mojom_shared.so ./libusb_shared.so ./libui_accessibility_ax_mojom_shared.so ./libgeometry.so ./libcontent.so ./libgpu.so ./libgfx.so ./libcolor_space.so ./libskia.so ./libgeometry_skia.so ./libgfx_switches.so ./libanimation.so ./libcodec.so ./librange.so ./libcc_paint.so ./libcc_base.so ./libcc_debug.so ./libcrash_key.so ./libgfx_ipc.so ./libgfx_ipc_geometry.so ./liburl_ipc.so ./libviz_common.so ./libviz_resource_format_utils.so ./libviz_vulkan_context_provider.so ./libui_base.so ./libui_data_pack.so ./libevents_base.so ./libplatform.so ./libkeycodes_x11.so ./libui_base_x.so ./libdisplay.so ./libdisplay_types.so ./libmedia.so ./libshared_memory_support.so ./libkeyed_service_core.so ./libleveldatabase.so ./libservice_manager_mojom.so ./libservice_manager_mojom_constants.so ./libservice_manager_cpp_types.so ./libservice_manager_mojom_traits.so ./libservice_manager_cpp.so ./libmetrics_cpp.so ./libcc.so ./libevents.so ./libui_base_ime.so ./libui_base_ime_types.so ./libui_base_ime_linux.so ./libblink_common.so ./libnetwork_cpp.so ./libnetwork_cpp_base.so ./libmojom_modules_shared.so ./libmojom_core_shared.so ./libspeech_recognition_error_code_mojom.so ./libweb_feature_mojo_bindings_mojom.so ./libui_accessibility_ax_mojom.so ./libcontent_common_mojo_bindings_shared.so ./libmedia_session_cpp.so ./libgfx_ipc_color.so ./libgfx_ipc_skia.so ./libcapture_base.so ./libaccessibility.so ./libevents_x.so ./libgfx_x11.so ./libaura.so ./libcompositor.so ./libsurface.so ./libnetwork_service.so ./libsandbox.so ./libembedder_switches.so ./libmemory_instrumentation.so ./libresource_coordinator_public_mojom.so ./libresource_coordinator_public_mojom_shared.so ./libresource_coordinator_cpp_base.so ./libstorage_common.so ./libpublic.so ./libinterfaces_shared.so ./libresource_coordinator_cpp.so ./libresource_coordinator_cpp_features.so ./libstorage_browser.so ./libchrome_features.so ./libprefs.so ./libos_crypt.so ./libwebdata_common.so ./libsql.so ./libcloud_policy_proto_generated_compile.so ./libpolicy_component.so ./libpolicy_proto.so ./libcommon.so ./libnetwork_session_configurator.so ./libchromium_sqlite3.so ./libnative_theme.so ./libgl_wrapper.so ./libui_message_center_cpp.so ./libppapi_shared.so ./liburl_matcher.so ./libbluetooth.so ./libdevice_event_log.so ./libdevice_base.so ./libprinting.so ./libsandbox_services.so ./libkeyed_service_content.so ./libsessions.so ./libshell_dialogs.so ./libdbus.so ./libonc.so ./libhost.so ./libviews.so ./libui_base_clipboard.so ./libui_base_clipboard_types.so ./libuser_prefs.so ./libgcm.so ./libui_touch_selection.so ./libproxy_config.so ./libfido.so ./libmanager.so ./libmessage_center.so ./libfontconfig.so ./libx11_events_platform.so ./libdevices.so ./libevents_devices_x11.so ./libffmpeg.so ./libwebview.so ./libdomain_reliability.so ./libstartup_tracing.so ./libui_devtools.so ./libuser_manager.so ./libgesture_detection.so ./libsnapshot.so ./libweb_dialogs.so ./libsuid_sandbox_client.so ./libseccomp_bpf.so ./libdevice_features.so ./libgtk2ui.so ./libbrowser_ui_views.so ./libwm.so ./libui_views_mus_lib.so ./libgles2.so ./libgles2_implementation.so ./libraster.so ./libwebgpu.so ./libwm_public.so ./libppapi_proxy.so ./libcaptive_portal.so ./libcertificate_matching.so ./libextras.so ./liblive_tab_count_metrics.so ./libcapture_lib.so ./libmirroring_service.so ./libmidi.so ./libmedia_mojo_services.so ./libmedia_gpu.so ./libmedia_webrtc.so ./libmojo_core_embedder.so ./libswitches.so ./libzygote.so ./libsimple_browser.so ./libvr_common.so ./libvr_base.so ./libtracing.so ./libppapi_host.so ./libblink_controller.so ./libblink_core.so ./libblink_core_mojo_bindings_shared.so ./libwtf.so ./libmojo_base_mojom_blink.so ./libservice_manager_mojom_blink.so ./libservice_manager_mojom_constants_blink.so ./libweb_feature_mojo_bindings_mojom_blink.so ./libblink_platform.so ./libcc_animation.so ./libresource_coordinator_public_mojom_blink.so ./libspeech_recognition_error_code_mojom_blink.so ./libv8.so ./libgin.so ./libblink_modules.so ./libnet_with_v8.so ./libcatalog_lib.so ./libdiscardable_memory_client.so ./libfreetype_harfbuzz.so ./libv8_libplatform.so ./libheadless.so ./libc++.so -Wl,--end-group   -ldl -lpthread -lrt -lX11 -lX11-xcb -lxcb -lXcomposite -lXcursor -lXdamage -lXext -lXfixes -lXi -lXrender -lXtst -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lnss3 -lnssutil3 -lsmime3 -lplds4 -lplc4 -lnspr4 -lcups -ldbus-1 -lexpat -lgio-2.0 -lopenjp2
ld.lld: error: undefined symbol: crc32
>>> referenced by crc.cc:28 (../../courgette/crc.cc:28)
>>>               obj/courgette/courgette_common/crc.o:(courgette::CalculateCrc(unsigned char const*, unsigned long))
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Thanks, so i'd rather do not use the patches, but install Privacy Badger or similar. Or maybe it is possible to globally disable the Canvas for good?

@wchen342
Copy link
Contributor

Does this and this help?

I don't remember there is a flag to disable canvas. Canvas is used on a large amount of websites so even if you can disable it most of the websites won't work without it.

@TCH68k
Copy link
Author

TCH68k commented Jan 16, 2021

Yes, the second one helped:

sed -i.bak 's/        ldflags = \[\]/        ldflags = \[ "-lz" \]/g' chrome/BUILD.gn

The chrome binary has been successfully built. And it works, it does not crashes at all. So this means, that one of the removed patches caused the crashes. Or maybe the debug mode prevented it?
Tomorrow i'll build Chromium again with no debug and without the libevent, libicu and fingerprinting patches and see if it works.

Then Privacy Badger will do the job.

@TCH68k
Copy link
Author

TCH68k commented Jan 17, 2021

I've just finished building the chrome binary with the flags.gn, without the patches above and without debug. It still crashes:

Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[26697:26697:0117/171906.350669:ERROR:browser_dm_token_storage_linux.cc(101)] Error: /etc/machine-id contains 0 characters (32 were expected).
[26697:26827:0117/171906.476505:ERROR:object_proxy.cc(621)] Failed to call method: org.freedesktop.Notifications.GetCapabilities: object_path= /org/freedesktop/Notifications: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
Érvénytelen utasítás

(The last line means "invalid instruction" in hungarian.)
These messages (with the exception of the invalid instruction) are printed out by my working version too, so they are not the cause.

So, the debug build does not crash, the identically parametered release build does. We cannot debug. Can i do anything else, but remove the lines from the flags.gn one by one and build it again and again to test which causes the problem?

@wchen342
Copy link
Contributor

wchen342 commented Jan 17, 2021

Did you include is_official_build=true? Try remove that.

is_debug only disables certain compiler optimizations and enables some extra checks in the code. The functionalities shall be the same,so if speed is not a concern then you can just use a debug build.

EDIT: Also, in flags.gn change to exclude_unwind_tables=false, symbol_level=1 and blink_symbol_level=1 can probably makes it print crash backtrace even in non-debug build.

@TCH68k
Copy link
Author

TCH68k commented Jan 18, 2021

And bingo! With is_official_build set to false it now works flawlessly, no further debugging needed.

So, thank you very much again for your vast amount of help and tremendous patience, for in round two too. Here is the - now really - final script to build (it is just finished running and the resulting package contains everything, the binary is working):

#!/bin/sh
cd "$HOME"
mkdir kocsog_gugli 2>/dev/null
cd kocsog_gugli

echo
echo "======================"
echo "Getting depot tools..."
echo "======================"
echo
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:"$HOME"/kocsog_gugli/depot_tools

echo
echo "=========================="
echo "Getting Chromium source..."
echo "=========================="
echo
mkdir chromium 2>/dev/null
cd chromium/
fetch --nohooks chromium
free > /dev/null && sync > /dev/null && echo 3 > /proc/sys/vm/drop_caches && free > /dev/null

echo
echo "===================="
echo "Checkout and sync..."
echo "===================="
echo
cd src
git checkout 73.0.3683.75
gclient sync -D
free > /dev/null && sync > /dev/null && echo 3 > /proc/sys/vm/drop_caches && free > /dev/null

# Use the "fontconfig.patch" from UGC and not from Debian. The rest of the two patchset can be merged.
echo
echo "==========="
echo "Patching..."
echo "==========="
echo
echo "Getting Debian patchset..."
wget http://deb.debian.org/debian/pool/main/c/chromium/chromium_73.0.3683.75-1~deb9u1.debian.tar.xz
tar xf chromium_73.0.3683.75-1~deb9u1.debian.tar.xz
rm chromium_73.0.3683.75-1~deb9u1.debian.tar.xz
rm -rf debian/patches/arm
find debian/patches/ -name '*.patch' -exec mv {} ./ \;
rm -rf debian
echo "Getting Ungoogled-Chromium patchset..."
git clone https://github.com/Eloston/ungoogled-chromium/
cd ungoogled-chromium/
git checkout 73.0.3683.103-2
cd ..
find ungoogled-chromium/patches/ -name '*.patch' -exec mv {} ./ \;
rm -rf ungoogled-chromium
# Remove unneeded libevent, libicu and fingerprinting patches.
rm event.patch icu.patch icu57.patch icu-new.patch fingerprinting-flags-client-rects-and-measuretext.patch flag-fingerprinting-canvas-image-data-noise.patch
echo "Applying patches..."
for PATCH in *.patch
do
	echo "****************"
	echo "* ""$PATCH"
	echo "****************"
	patch -p1 -f < "$PATCH"
	echo "****************"
	echo
done
rm *.patch
# Some files are left in an uncompilable state.
echo "Some hand patching..."
# Designated initializers patch is erroneous with the bundled CLang 9.
sed -i.bak 's/    Settings(bool randomise):randomised_sampling_enabled(randomise) {}//g' base/task/sequence_manager/sequence_manager.h
# Patch a mispatched file's macro.
sed -i.bak -n '1h;1!H;${g;s/#endif\n#endif/#endif/;p;}' chrome/browser/ui/chrome_pages.cc
# Safe browsing patch is erroneous with chrome 73.0.
sed -i.bak '/^static_library("safe_browsing") {/i sources = []\n deps = []' chrome/browser/safe_browsing/BUILD.gn
# Comment some ICU calls in the bug reporting.
sed -i.bak 's|u_|// u_|g' third_party/breakpad/breakpad/src/common/string_conversion.cc
# Rename a duplicate dummy function.
sed -i.bak 's/QuarantineFileResult QuarantineFile/QuarantineFileResult QuarantineFile1/g' components/download/quarantine/quarantine.cc
# Chromium needs libz.
sed -i.bak 's/        ldflags = \[\]/        ldflags = \[ "-lz" \]/g' chrome/BUILD.gn

echo
echo "============="
echo "Generating..."
echo "============="
echo
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH":/usr/lib/x86_64-linux-gnu/pkgconfig/
wget https://raw.githubusercontent.com/Eloston/ungoogled-chromium/73.0.3683.103-2/flags.gn
echo 'gtk_version=2' >> flags.gn
echo 'use_gnome_keyring=false' >> flags.gn
echo 'use_pulseaudio=false' >> flags.gn
echo 'use_sysroot=false' >> flags.gn
sed -i.bak 's/is_official_build=true/is_official_build=false/g' flags.gn
gn gen out/Release "--args=`cat flags.gn | tr '\n' ' '`"
gn args --list out/Release/ > ninja.settings
free > /dev/null && sync > /dev/null && echo 3 > /proc/sys/vm/drop_caches && free > /dev/null

echo
echo "==========="
echo "Building..."
echo "==========="
echo
autoninja -C out/Release chrome
free > /dev/null && sync > /dev/null && echo 3 > /proc/sys/vm/drop_caches && free > /dev/null

echo
echo "============"
echo "Packaging..."
echo "============"
echo
cd out/Release
mkdir ungoogled-chromium-devuan2-gtk2-portable
cp -R locales chrome *.pak *.info *.so *.bin *.dat ungoogled-chromium-devuan2-gtk2-portable/
tar -zcf ungoogled-chromium-devuan2-gtk2-portable.tar.gz ungoogled-chromium-devuan2-gtk2-portable
rm -rf ungoogled-chromium-devuan2-gtk2-portable
mv ungoogled-chromium-devuan2-gtk2-portable.tar.gz "$HOME"/
free > /dev/null && sync > /dev/null && echo 3 > /proc/sys/vm/drop_caches && free > /dev/null

if [ "$1" != "" ];
then
	echo
	echo "=============="
	echo "Cleaning up..."
	echo "=============="
	echo
	rm -rf "$HOME"/kocsog_gugli
	free > /dev/null && sync > /dev/null && echo 3 > /proc/sys/vm/drop_caches && free > /dev/null
fi

@wchen342
Copy link
Contributor

Glad to hear it finally worked for you!

If you have some extra time, probably you can summarize the pitfalls you experienced and how you solved them in the wiki. It can be helpful to others. But no worry if you don't have the time, since this thread itself can be a great reference for those who facing building problems in the future.

@TCH68k
Copy link
Author

TCH68k commented Jan 19, 2021

Okay, when i'll get some free time for this, i will summarize them. However, should i create a new article or add the content to another?

@wchen342
Copy link
Contributor

Considering the length of the thread it shall be better to be a separate article. You can open a PR to the wiki repo and see what Eloston says. I think most likely he will agree a new article is good.

@TCH68k
Copy link
Author

TCH68k commented Jan 20, 2021

Very well, i'll collect my thoughts, re-read the entire commentstream and make a new article about building UGC with GTK2. For now, under Devuan 2 (Debian 9), but when i'll have to update to Devuan 3 (Debian 10), i'll cover that too. Whenever i get the time. (Since Debian 10 is officially supported by UGC, it will be much easier, i just have to use the GTK2 patch...)

I'm curious if the GTK2 patch could be adapted to later Chromium versions too...

@PF4Public
Copy link
Contributor

Closing this issue in favour of #1589
Please continue this discussion in #1589 if you have something to add.

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

5 participants