Skip to content

Latest commit

 

History

History
229 lines (181 loc) · 7.64 KB

V2.md

File metadata and controls

229 lines (181 loc) · 7.64 KB

Region: eu-central-1 AMI: ami-0f673487d7e5f89ca (Amazon Linux 2023 AMI) Architecture: 64-bit (Arm) Instance type: c7g.8xlarge Storage: 200GiB (gp3) Configure an SSH key pair so you can login via SSH

Login via SSH

sudo -i

Install build dependencies

yum install -y "@Development Tools" alsa-lib-devel atk-devel bc bluez-libs-devel bzip2-devel cairo-devel cups-devel dbus-devel dbus-glib-devel dbus-x11 expat-devel glibc-langpack-en gperf gtk3-devel httpd libatomic libcap-devel libjpeg-devel libXScrnSaver-devel libxkbcommon-x11-devel mod_ssl ncurses-compat-libs nspr-devel nss-devel pam-devel pciutils-devel perl php php-cli pulseaudio-libs-devel python python-psutil ruby xorg-x11-server-Xvfb libcurl-devel libxml2-devel clang openssl-devel.aarch64 libdrm-devel.aarch64 python3-pyqt5-sip.aarch64 libuuid-devel.aarch64 nano wget rust

Install depot_tools

export DEPOT_TOOLS_BOOTSTRAP_PYTHON3=0
cd /root
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PATH:${HOME}/depot_tools"

Get Chromium source

mkdir /root/chromium && cd /root/chromium
git clone --depth 1 --no-tags -n https://github.com/chromium/chromium.git src
cd src
# This will take a while!
git fetch --prune --depth=1 --tags origin 123.0.6312.86 # Chrome 123.0.6312.86
git checkout --quiet 123.0.6312.86

Get matching depot_tools version

cd /root/chromium/src
COMMIT_DATE=$(git log -n 1 --pretty=format:%ci)
cd /root/depot_tools
git checkout $(git rev-list -n 1 --before="$COMMIT_DATE" main)
export DEPOT_TOOLS_UPDATE=0
nano /root/chromium/.gclient
# Copy contents of included .gclient to /root/chromium/.gclient
cd /root/chromium/src
nano DEPS

Add 'condition': 'host_os == "win"' in src/buildtools/reclient second.

  • Change git_args = ['log', '-1', '--format=%H %ct'] to git_args = ['log', '-1', '--format="%H %ct"'] in build/util/lastchange.py

Set up gclient

gclient sync -D --no-history --shallow --force --reset
gclient runhooks

Replace NodeJs with aarch64 version

cd /root/chromium/src
sed -i 's@update_unix "darwin-x64" "mac"@# update_unix "darwin-x64" "mac"@g' third_party/node/update_node_binaries
sed -i 's@update_unix "darwin-arm64" "mac"@# update_unix "darwin-arm64" "mac"@g' third_party/node/update_node_binaries
sed -i 's@update_unix "linux-x64" "linux"@update_unix "linux-arm64" "linux"@g' third_party/node/update_node_binaries
./third_party/node/update_node_binaries
rm -rf third_party/node/linux/node-linux-x64
ln -s /root/chromium/src/third_party/node/linux/node-linux-arm64 /root/chromium/src/third_party/node/linux/node-linux-x64

Replace Java with aarch64 version

cd /root
rm -rf /root/chromium/src/third_party/jdk/current
wget https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15%2B10/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.15_10.tar.gz
tar zxvf OpenJDK11U-jre_aarch64_linux_hotspot_11.0.15_10.tar.gz
mv jdk-11.0.15+10-jre /root/chromium/src/third_party/jdk/current

Install CMake

cd /root
wget https://cmake.org/files/v3.23/cmake-3.23.0.tar.gz
tar -xvzf cmake-3.23.0.tar.gz
cd cmake-3.23.0
./bootstrap
make -j$(nproc)
make install
export PATH="$PATH:/usr/local/bin"

Replace Ninja with aarch64 version

cd /root
git clone https://github.com/ninja-build/ninja.git -b v1.8.2
cd ninja
./configure.py --bootstrap
rm -f /root/depot_tools/ninja
ln -s /root/ninja/ninja /root/depot_tools/ninja

Install LLVM

cd /root/chromium/src
sed -i "s#dirs.lib_dir, 'libxml2.a'#os.path.join(dirs.install_dir, 'lib64'), 'libxml2.a'#g" tools/clang/scripts/build.py # UPDATED
  • Delete " '-DLLVM_ENABLE_LLD=ON'," from ./tools/clang/scripts/build.py
  • Remove the if args.with_ml_inline_model block from ./tools/clang/scripts/build.py
# Removed D_SYSROOT appends now because it looks fine on aarch64

sed -i "s/self\.lib_dir = os\.path\.join(self\.install_dir, 'lib')/self\.lib_dir = os\.path\.join(self\.build_dir, 'lib')/g" ./tools/clang/scripts/build.py
sed -i "s/cxxflags = \[\]/cxxflags = \['-lrt', '-lpthread'\]/g" ./tools/clang/scripts/build.py
sed -i "s/bootstrap_targets = 'X86'/bootstrap_targets = 'ARM;AArch64'/g" ./tools/clang/scripts/build.py
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib6
./tools/clang/scripts/build.py --without-android --without-fuchsia --use-system-cmake --host-cc /bin/clang --host-cxx /bin/clang++ --bootstrap

Delete runtimes_triples_args['i386-unknown-linux-gnu'], runtimes_triples_args['armv7-unknown-linux-gnueabihf'] and runtimes_triples_args['x86_64-unknown-linux-gnu'] from ./tools/clang/scripts/build.py

Create build dir:

mkdir -p /root/chromium/src/out/Headless
mount --types tmpfs --options size=48G,nr_inodes=128k,mode=1777 tmpfs /root/chromium/src/out/Headless
touch /root/chromium/src/out/Headless/args.gn

Copy contents of included args.gn to /root/chromium/src/out/Headless/args.gn.

Apply compatibility patches

echo '#ifndef F_LINUX_SPECIFIC_BASE' >> /usr/include/fcntl.h
echo '#define F_LINUX_SPECIFIC_BASE 1024' >> /usr/include/fcntl.h
echo '#endif' >> /usr/include/fcntl.h
echo '#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)' >> /usr/include/fcntl.h
echo '#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)' >> /usr/include/fcntl.h
echo '#define F_SEAL_SEAL 0x0001' >> /usr/include/fcntl.h
echo '#define F_SEAL_SHRINK 0x0002' >> /usr/include/fcntl.h
echo '#define F_SEAL_GROW 0x0004' >> /usr/include/fcntl.h
echo '#define F_SEAL_GROW 0x0004' >> /usr/include/fcntl.h
echo '#define F_SEAL_FUTURE_WRITE 0x0010' >> /usr/include/fcntl.h
sed -i '1i#define MFD_CLOEXEC 0x0001U' /root/chromium/src/v8/src/base/platform/platform-posix.cc

Disable GPU features:

sed -i 's/configs += \[ "\/\/build\/config\/linux\/dri" \]/    configs += []/g' content/gpu/BUILD.gn
sed -i 's/configs += \[ "\/\/build\/config\/linux\/dri" \]/    configs += []/g' media/gpu/sandbox/BUILD.gn

Install Rust nightly for aarch64:

Find out current rust version:

cat ./third_party/rust-toolchain/VERSION

Go to https://github.com/rust-lang/rust/commit/[hash] and figure out when the commit was made. Let's say 2024-02-14 in this case.

rm ./third_party/rust-toolchain/bin/rustc
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
ln -s $(which rustc) ./third_party/rust-toolchain/bin/rustc
. "$HOME/.cargo/env"
rustup default nightly-2024-02-14

Fix GCC:

export LIBRARY_PATH="/usr/lib/gcc/aarch64-amazon-linux/11:$LIBRARY_PATH" #?
ln -s /usr/lib/gcc/aarch64-amazon-linux/11/crtbeginS.o /usr/lib/crtbeginS.o
ln -s /usr/lib/gcc/aarch64-amazon-linux/11/crtendS.o /usr/lib/crtendS.o

Start compilation:

gn gen out/Headless
autoninja -C out/Headless headless_shell
strip -o out/Headless/headless_shell out/Headless/headless_shell
strip -o out/Headless/libEGL.so out/Headless/libEGL.so
strip -o out/Headless/libGLESv2.so out/Headless/libGLESv2.so
strip -o out/Headless/libvk_swiftshader.so out/Headless/libvk_swiftshader.so
strip -o out/Headless/libvulkan.so.1 out/Headless/libvulkan.so.1
mkdir final
cp out/Headless/headless_shell final/headless_shell
cp out/Headless/libEGL.so final/libEGL.so
cp out/Headless/libGLESv2.so final/libGLESv2.so
cp out/Headless/libvk_swiftshader.so final/libvk_swiftshader.so
cp out/Headless/libvulkan.so.1 final/libvulkan.so.1
cp /lib64/libnss3.so final/libnss3.so
cp /lib64/libsoftokn3.so final/libsoftokn3.so
cp /lib64/libnspr4.so final/libnspr4.so
cp /lib64/libexpat.so.1 final/libexpat.so.1
cp /lib64/libplc4.so final/libplc4.so
cp /lib64/libplds4.so final/libplds4.so
cp /lib64/libfreebl3.so final/libfreebl3.so
cp /lib64/libfreeblpriv3.so final/libfreeblpriv3.so
cp out/Headless/vk_swiftshader_icd.json final/vk_swiftshader_icd.json
cd final
zip -r chromium.zip .