Basic Plasma Desktop Support

This commit is contained in:
Justin Hammond 2023-04-29 16:20:26 +08:00
parent 3ed94a5fde
commit 020e19042e
52 changed files with 38787 additions and 24 deletions

View file

@ -1,9 +1,9 @@
require conf/distro/poky.conf
DISTRO = "star64"
DISTRO_NAME = "star64"
DISTRO_VERSION = "0.1"
DISTRO_CODENAME = ""
DISTRO = "pinix"
DISTRO_NAME = "PinIx"
DISTRO_VERSION = "1.0"
DISTRO_CODENAME = "pinix"
SDK_VENDOR = "-pine64"
TARGET_VENDOR = "-pine64"
@ -52,3 +52,5 @@ INITRAMFS_FSTYPES = "cpio.gz"
INITRAMFS_IMAGE = "star64-image-initramfs"
LICENSE_FLAGS_ACCEPTED = "commercial"
QT_LTS_GIT_PROTOCOL = "https"
FULL_OPTIMIZATION += " -mtune=sifive-u74"

View file

@ -0,0 +1,78 @@
DESCRIPTION = "Minimal Star64 Packages"
inherit packagegroup
PACKAGES = " \
packagegroup-star64-minimal \
packagegroup-star64-weston \
packagegroup-star64-plasma \
"
RDEPENDS:packagegroup-star64-minimal = " \
resize-rootfs \
mc \
joe \
ca-certificates \
networkmanager \
wpa-supplicant \
avahi-daemon \
networkmanager-nmtui \
ntpdate \
tzdata \
udev-rules-star64 \
"
RDEPENDS:packagegroup-star64-weston = " \
packagegroup-star64-minimal \
gtk+3-demo \
weston \
sddm \
${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'weston-xwayland matchbox-terminal', '', d)} \
"
RDEPENDS:packagegroup-star64-plasma = " \
packagegroup-star64-minimal \
wayland \
dbus \
sddm \
systemd \
liberation-fonts \
ttf-noto \
packagegroup-kde-frameworks5 \
bluedevil \
breeze \
kactivitymanagerd \
kde-cli-tools \
kdecoration \
kscreen \
kscreenlocker \
kwayland-integration \
kwin \
libkscreen \
libksysguard \
milou \
plasma-integration \
plasma-nano \
plasma-nm \
plasma-pa \
plasma-workspace \
polkit-kde-agent-1 \
plasma-settings \
plasma-systemmonitor \
xdg-desktop-portal-kde \
kclock \
kweather \
plasma-desktop \
kdeconnect-kde \
konsole \
discover \
konqueror \
xserver-xorg-extension-glx \
xf86-video-modesetting \
gstreamer1.0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
"

View file

@ -2,20 +2,11 @@ SUMMARY = "A small commandline only image for Star64"
inherit core-image extrausers
P64_PACKAGES_MINIMAL = "resize-rootfs \
mc \
joe \
ca-certificates \
networkmanager \
wpa-supplicant \
avahi-daemon \
networkmanager-nmtui \
"
IMAGE_INSTALL = "packagegroup-core-boot \
packagegroup-core-full-cmdline \
${CORE_IMAGE_EXTRA_INSTALL} \
${P64_PACKAGES_MINIMAL} \
packagegroup-star64-minimal \
"
IMAGE_FEATURES += " splash \

View file

@ -8,12 +8,6 @@ IMAGE_FEATURES += "splash package-management ssh-server-dropbear hwcodecs weston
LICENSE = "MIT"
IMAGE_INSTALL += " wayland \
weston \
dbus \
sddm \
sddm-config-plasma-bigscreen \
packagegroup-plasma-bigscreen-workspace \
packagegroup-core-x11-utils \
systemd \
IMAGE_INSTALL += " \
packagegroup-star64-plasma \
"

View file

@ -8,6 +8,6 @@ IMAGE_FEATURES += "splash package-management ssh-server-dropbear hwcodecs weston
LICENSE = "MIT"
IMAGE_INSTALL += " gtk+3-demo \
${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'weston-xwayland matchbox-terminal', '', d)} \
IMAGE_INSTALL += " \
packagegroup-star64-weston \
"

View file

@ -0,0 +1 @@
PACKAGECONFIG:remove = "networkd resolved nss-resolve "

View file

@ -0,0 +1,16 @@
DESCRIPTION = "udev rules for Star64 Boards"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = " \
file://99-video.rules \
"
S = "${WORKDIR}"
INHIBIT_DEFAULT_DEPS = "1"
do_install () {
install -d ${D}${sysconfdir}/udev/rules.d
install -m 0644 ${WORKDIR}/99-video.rules ${D}${sysconfdir}/udev/rules.d/
}

View file

@ -0,0 +1 @@
SUBSYSTEM=="drm", KERNEL=="card[0-9]*",NAME="dri/%k", MODE="0666"

View file

@ -0,0 +1,56 @@
From 8739e1c3bef653415ad4b9b9c318ccfa76c43da6 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 31 Mar 2022 15:00:24 -0700
Subject: [PATCH] Check for clang before guessing gcc or lcc
clang --version can yield a string like below when its installed into
such a directory
clang version 14.0.0 (https://github.com/llvm/llvm-project 3f43d803382d57e3fc010ca19833077d1023e9c9)
Target: aarch64-yoe-linux
Thread model: posix
InstalledDir: /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/gnome-text-editor/42.0-r0/recipe-sysroot-native/usr/bin/aarch64-yoe-linux
as you can see InstallDir has 'xt-' subtring and this trips the check to
guess gcc
if 'Free Software Foundation' in out or 'xt-' in out:
Therefore, check if compiler is clang then there is no point of running
this check anyway.
Upstream-Status: Submitted [https://github.com/mesonbuild/meson/pull/10218]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
mesonbuild/compilers/detect.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 53948b01a..ba335cf39 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -427,13 +427,14 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin
version = search_version(out)
guess_gcc_or_lcc: T.Optional[str] = None
- if 'Free Software Foundation' in out or 'xt-' in out:
- guess_gcc_or_lcc = 'gcc'
- if 'e2k' in out and 'lcc' in out:
- guess_gcc_or_lcc = 'lcc'
- if 'Microchip Technology' in out:
- # this output has "Free Software Foundation" in its version
- guess_gcc_or_lcc = None
+ if not 'clang' in compiler_name:
+ if 'Free Software Foundation' in out or 'xt-' in out:
+ guess_gcc_or_lcc = 'gcc'
+ if 'e2k' in out and 'lcc' in out:
+ guess_gcc_or_lcc = 'lcc'
+ if 'Microchip Technology' in out:
+ # this output has "Free Software Foundation" in its version
+ guess_gcc_or_lcc = None
if guess_gcc_or_lcc:
defines = _get_gnu_compiler_defines(compiler)
--
2.35.1

View file

@ -0,0 +1,45 @@
From 6c4eef1d92e9e42fdbc888365cab3c95fb33c605 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@intel.com>
Date: Tue, 3 Jul 2018 13:59:09 +0100
Subject: [PATCH] Make CPU family warnings fatal
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
mesonbuild/envconfig.py | 2 +-
mesonbuild/environment.py | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)
Index: meson-0.60.2/mesonbuild/envconfig.py
===================================================================
--- meson-0.60.2.orig/mesonbuild/envconfig.py
+++ meson-0.60.2/mesonbuild/envconfig.py
@@ -266,8 +266,8 @@ class MachineInfo(HoldableObject):
'but is missing {}.'.format(minimum_literal - set(literal)))
cpu_family = literal['cpu_family']
- if cpu_family not in known_cpu_families:
- mlog.warning(f'Unknown CPU family {cpu_family}, please report this at https://github.com/mesonbuild/meson/issues/new')
+ if cpu_family not in known_cpu_families and cpu_family != "riscv":
+ raise EnvironmentException('Unknown CPU family {}, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.'.format(cpu_family))
endian = literal['endian']
if endian not in ('little', 'big'):
Index: meson-0.60.2/mesonbuild/environment.py
===================================================================
--- meson-0.60.2.orig/mesonbuild/environment.py
+++ meson-0.60.2/mesonbuild/environment.py
@@ -354,10 +354,8 @@ def detect_cpu_family(compilers: Compile
if any_compiler_has_define(compilers, '__64BIT__'):
trial = 'ppc64'
- if trial not in known_cpu_families:
- mlog.warning(f'Unknown CPU family {trial!r}, please report this at '
- 'https://github.com/mesonbuild/meson/issues/new with the '
- 'output of `uname -a` and `cat /proc/cpuinfo`')
+ if trial not in known_cpu_families and trail != "riscv":
+ raise EnvironmentException('Unknown CPU family %s, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.' % trial)
return trial

View file

@ -0,0 +1,37 @@
From 2e9582167bf9d3273004edb2637310531f0155ab Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Mon, 19 Nov 2018 14:24:26 +0100
Subject: [PATCH] python module: do not manipulate the environment when calling
pkg-config
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
mesonbuild/modules/python.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 3bbccd1..fda7a25 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -277,9 +277,6 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
# there is no LIBPC, so we can't search in it
return NotFoundDependency('python', env)
- old_pkg_libdir = os.environ.pop('PKG_CONFIG_LIBDIR', None)
- old_pkg_path = os.environ.pop('PKG_CONFIG_PATH', None)
- os.environ['PKG_CONFIG_LIBDIR'] = pkg_libdir
try:
return PythonPkgConfigDependency(name, env, kwargs, installation, True)
finally:
@@ -288,8 +285,7 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
os.environ[name] = value
elif name in os.environ:
del os.environ[name]
- set_env('PKG_CONFIG_LIBDIR', old_pkg_libdir)
- set_env('PKG_CONFIG_PATH', old_pkg_path)
+ pass
candidates.append(functools.partial(wrap_in_pythons_pc_dir, pkg_name, env, kwargs, installation))
# We only need to check both, if a python install has a LIBPC. It might point to the wrong location,

View file

@ -0,0 +1,28 @@
From 656bf55fed01df2d2e2ad6d9d9887173cb16b85c Mon Sep 17 00:00:00 2001
From: Peter Kjellerstedt <pkj@axis.com>
Date: Thu, 26 Jul 2018 16:32:49 +0200
Subject: [PATCH 2/2] Support building allarch recipes again
This registers "allarch" as a known CPU family.
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
mesonbuild/envconfig.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
index 4d58c91..ff01ad1 100644
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -36,6 +36,7 @@ from pathlib import Path
known_cpu_families = (
+ 'allarch',
'aarch64',
'alpha',
'arc',
--
2.24.0

View file

@ -0,0 +1,43 @@
#!/usr/bin/env python3
import os
import string
import sys
class Template(string.Template):
delimiter = "@"
class Environ():
def __getitem__(self, name):
val = os.environ[name]
val = val.split()
if len(val) > 1:
val = ["'%s'" % x for x in val]
val = ', '.join(val)
val = '[%s]' % val
elif val:
val = "'%s'" % val.pop()
return val
try:
sysroot = os.environ['OECORE_NATIVE_SYSROOT']
except KeyError:
print("Not in environment setup, bailing")
sys.exit(1)
template_file = os.path.join(sysroot, 'usr/share/meson/meson.cross.template')
cross_file = os.path.join(sysroot, 'usr/share/meson/%smeson.cross' % os.environ["TARGET_PREFIX"])
native_template_file = os.path.join(sysroot, 'usr/share/meson/meson.native.template')
native_file = os.path.join(sysroot, 'usr/share/meson/meson.native')
with open(template_file) as in_file:
template = in_file.read()
output = Template(template).substitute(Environ())
with open(cross_file, "w") as out_file:
out_file.write(output)
with open(native_template_file) as in_file:
template = in_file.read()
output = Template(template).substitute({'OECORE_NATIVE_SYSROOT': os.environ['OECORE_NATIVE_SYSROOT']})
with open(native_file, "w") as out_file:
out_file.write(output)

View file

@ -0,0 +1,31 @@
#!/bin/sh
if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
exec "meson.real" "$@"
fi
if [ -z "$SSL_CERT_DIR" ]; then
export SSL_CERT_DIR="$OECORE_NATIVE_SYSROOT/etc/ssl/certs/"
fi
# If these are set to a cross-compile path, meson will get confused and try to
# use them as native tools. Unset them to prevent this, as all the cross-compile
# config is already in meson.cross.
unset CC CXX CPP LD AR NM STRIP
case "$1" in
setup|configure|dist|install|introspect|init|test|wrap|subprojects|rewrite|compile|devenv|env2mfile|help) MESON_CMD="$1" ;;
*) echo meson-wrapper: Implicit setup command assumed; MESON_CMD=setup ;;
esac
if [ "$MESON_CMD" = "setup" ]; then
MESON_SETUP_OPTS=" \
--cross-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/${TARGET_PREFIX}meson.cross" \
--native-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.native" \
"
echo meson-wrapper: Running meson with setup options: \"$MESON_SETUP_OPTS\"
fi
exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
"$@" \
$MESON_SETUP_OPTS

View file

@ -0,0 +1,158 @@
HOMEPAGE = "http://mesonbuild.com"
SUMMARY = "A high performance build system"
DESCRIPTION = "Meson is a build system designed to increase programmer \
productivity. It does this by providing a fast, simple and easy to use \
interface for modern software development tools and practices."
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
SRC_URI = "git://github.com/mesonbuild/meson.git;protocol=https;branch=1.0 \
file://meson-setup.py \
file://meson-wrapper \
file://0001-python-module-do-not-manipulate-the-environment-when.patch \
file://0001-Make-CPU-family-warnings-fatal.patch \
file://0002-Support-building-allarch-recipes-again.patch \
file://0001-Check-for-clang-before-guessing-gcc-or-lcc.patch \
"
SRCREV = "f341097c7e7914c250133bd58feb4985d1fbdcd6"
S = "${WORKDIR}/git"
inherit python_setuptools_build_meta
RDEPENDS:${PN} = "ninja python3-modules python3-pkg-resources"
FILES:${PN} += "${datadir}/polkit-1"
do_install:append () {
# As per the same issue in the python recipe itself:
# Unfortunately the following pyc files are non-deterministc due to 'frozenset'
# being written without strict ordering, even with PYTHONHASHSEED = 0
# Upstream is discussing ways to solve the issue properly, until then let's
# just not install the problematic files.
# More info: http://benno.id.au/blog/2013/01/15/python-determinism
rm ${D}${libdir}/python*/site-packages/mesonbuild/dependencies/__pycache__/mpi.cpython*
}
BBCLASSEXTEND = "native nativesdk"
inherit meson-routines
# The cross file logic is similar but not identical to that in meson.bbclass,
# since it's generating for an SDK rather than a cross-compile. Important
# differences are:
# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
# real paths by meson-setup.sh when the SDK is extracted.
# - Some overrides aren't needed, since the SDK injects paths that take care of
# them.
def var_list2str(var, d):
items = d.getVar(var).split()
return items[0] if len(items) == 1 else ', '.join(repr(s) for s in items)
def generate_native_link_template(d):
val = ['-L@{OECORE_NATIVE_SYSROOT}${libdir_native}',
'-L@{OECORE_NATIVE_SYSROOT}${base_libdir_native}',
'-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${libdir_native}',
'-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${base_libdir_native}',
'-Wl,--allow-shlib-undefined'
]
build_arch = d.getVar('BUILD_ARCH')
if 'x86_64' in build_arch:
loader = 'ld-linux-x86-64.so.2'
elif 'i686' in build_arch:
loader = 'ld-linux.so.2'
elif 'aarch64' in build_arch:
loader = 'ld-linux-aarch64.so.1'
elif 'ppc64le' in build_arch:
loader = 'ld64.so.2'
elif 'loongarch64' in build_arch:
loader = 'ld-linux-loongarch-lp64d.so.1'
if loader:
val += ['-Wl,--dynamic-linker=@{OECORE_NATIVE_SYSROOT}${base_libdir_native}/' + loader]
return repr(val)
install_templates() {
install -d ${D}${datadir}/meson
cat >${D}${datadir}/meson/meson.native.template <<EOF
[binaries]
c = ${@meson_array('BUILD_CC', d)}
cpp = ${@meson_array('BUILD_CXX', d)}
ar = ${@meson_array('BUILD_AR', d)}
nm = ${@meson_array('BUILD_NM', d)}
strip = ${@meson_array('BUILD_STRIP', d)}
readelf = ${@meson_array('BUILD_READELF', d)}
pkgconfig = 'pkg-config-native'
[built-in options]
c_args = ['-isystem@{OECORE_NATIVE_SYSROOT}${includedir_native}' , ${@var_list2str('BUILD_OPTIMIZATION', d)}]
c_link_args = ${@generate_native_link_template(d)}
cpp_args = ['-isystem@{OECORE_NATIVE_SYSROOT}${includedir_native}' , ${@var_list2str('BUILD_OPTIMIZATION', d)}]
cpp_link_args = ${@generate_native_link_template(d)}
[properties]
sys_root = '@OECORE_NATIVE_SYSROOT'
EOF
cat >${D}${datadir}/meson/meson.cross.template <<EOF
[binaries]
c = @CC
cpp = @CXX
ar = @AR
nm = @NM
strip = @STRIP
pkgconfig = 'pkg-config'
[built-in options]
c_args = @CFLAGS
c_link_args = @LDFLAGS
cpp_args = @CPPFLAGS
cpp_link_args = @LDFLAGS
[properties]
needs_exe_wrapper = true
sys_root = @OECORE_TARGET_SYSROOT
[host_machine]
system = '$host_system'
cpu_family = '$host_cpu_family'
cpu = '$host_cpu'
endian = '$host_endian'
EOF
}
do_install:append:class-nativesdk() {
host_system=${SDK_OS}
host_cpu_family=${@meson_cpu_family("SDK_ARCH", d)}
host_cpu=${SDK_ARCH}
host_endian=${@meson_endian("SDK", d)}
install_templates
install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
# We need to wrap the real meson with a thin env setup wrapper.
mv ${D}${bindir}/meson ${D}${bindir}/meson.real
install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
}
FILES:${PN}:append:class-nativesdk = "${datadir}/meson ${SDKPATHNATIVE}"
do_install:append:class-native() {
host_system=${HOST_OS}
host_cpu_family=${@meson_cpu_family("HOST_ARCH", d)}
host_cpu=${HOST_ARCH}
host_endian=${@meson_endian("HOST", d)}
install_templates
install -d ${D}${datadir}/post-relocate-setup.d
install -m 0755 ${WORKDIR}/meson-setup.py ${D}${datadir}/post-relocate-setup.d/
# We need to wrap the real meson with a thin wrapper that substitues native/cross files
# when running in a direct SDK environment.
mv ${D}${bindir}/meson ${D}${bindir}/meson.real
install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
}

View file

@ -0,0 +1,2 @@
#needed to build qtwebengine (for the messed up pkgconfig depenedencies)
BBCLASSEXTEND = "native nativesdk"

View file

@ -0,0 +1 @@
SYSTEMD_AUTO_ENABLE:${PN} = "disable"

View file

@ -0,0 +1,67 @@
# SPDX-FileCopyrightText: 2023 Justin Hammond <justin@dynam.ac>
#
# SPDX-License-Identifier: MIT
DESCRIPTION = "Konqueror"
SUMMARY = "A Webbrowser for KDE"
HOMEPAGE = "https://invent.kde.org/network/konqueror"
LICENSE = "BSD-3-Clause & GPL-2.0-only & GPL-2.0-or-later & GPL-3.0-only & LGPL-2.0-only & LGPL-2.0-or-later & LGPL-2.1-or-later & LGPL-3.0-only"
LIC_FILES_CHKSUM = " \
file://LICENSES/BSD-3-Clause.txt;md5=f225922a2c12dfa5218fb70c49db3ea6 \
file://LICENSES/GPL-2.0-only.txt;md5=9e2385fe012386d34dcc5c9863070881 \
file://LICENSES/GPL-2.0-or-later.txt;md5=9e2385fe012386d34dcc5c9863070881 \
file://LICENSES/GPL-3.0-only.txt;md5=49fc03046e56a282c0c743b5d3a55b7c \
file://LICENSES/LGPL-2.0-only.txt;md5=da48810c4ddf8e49efa031294a26b98c \
file://LICENSES/LGPL-2.0-or-later.txt;md5=da48810c4ddf8e49efa031294a26b98c \
file://LICENSES/LGPL-2.1-or-later.txt;md5=147a320ed8b16b036829a0c71d424153 \
file://LICENSES/LGPL-3.0-only.txt;md5=8d51f5b5fd447f7a1040c3dc9f0a8de6 \
"
S = "${WORKDIR}/git"
DEPENDS = " \
qtwebengine \
kwindowsystem \
kparts \
kcrash \
kinit \
kiconthemes \
kdbusaddons \
kguiaddons \
kactivities \
kdesu \
qtbase \
"
inherit cmake_kdeapp
inherit kcoreaddons
inherit kconfig
inherit kauth
inherit mime-xdg
inherit kcmutils
EXTRA_OECMAKE:append = " \
-DBUILD_TESTING=OFF \
-DOE_KF5_PATH_HOST_ROOT=${STAGING_DIR_HOST} \
"
FILES:${PN} += " \
${datadir}/k* \
${datadir}/webenginepart \
${datadir}/akregator \
${libdir}/plugins/khtml \
${libdir}/plugins/kwebkitpart \
${libdir}/plugins/webenginepart \
${libdir}/libkdeinit5_konqueror.so \
${libdir}/libkdeinit5_kfmclient.so \
${libdir}/libkwebenginepart.so \
${libdir}/libKF5Konq.so \
${libdir}/libkonqsidebarplugin.so \
"
FILES:${PN}-dev = " \
${includedir}/konqsidebarplugin.h \
${includedir}/KF5/konq* \
${includedir}/KF5/libkonq* \
"
INSANE_SKIP:${PN} = "dev-so"

View file

@ -0,0 +1,21 @@
From ce8c1d569f398a700419e92875ac681910e1a9e5 Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Fri, 28 Apr 2023 16:08:17 +0800
Subject: [PATCH] Fix linking with QtPrintSupport
---
webenginepart/src/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/webenginepart/src/CMakeLists.txt b/webenginepart/src/CMakeLists.txt
index a65a80fc6..e8bebb341 100644
--- a/webenginepart/src/CMakeLists.txt
+++ b/webenginepart/src/CMakeLists.txt
@@ -3,6 +3,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Notifications )
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Sonnet)
find_package(Hunspell)
+find_package(Qt5 REQUIRED COMPONENTS PrintSupport)
add_definitions(-DTRANSLATION_DOMAIN=\"webenginepart\")

View file

@ -0,0 +1,6 @@
require ${PN}.inc
SRC_URI += " \
git://invent.kde.org/network/konqueror.git;protocol=https;branch=release/23.04 \
file://0001-Fix-linking-with-QtPrintSupport.patch \
"
SRCREV = "fac551bcfbf8cc75c11f994b6f920f1273094461"

View file

@ -0,0 +1,69 @@
# SPDX-FileCopyrightText: 2020 Andreas Cord-Landwehr <cordlandwehr@kde.org>
#
# SPDX-License-Identifier: MIT
DESCRIPTION = "Plasma Desktop"
SUMMARY = "A Plasma Desktop"
HOMEPAGE = "https://invent.kde.org/plasma/plasma-desktop"
LICENSE = "BSD-3-Clause & CC0-1.0 & GFDL-1.2-or-later & GPL-2.0-only & GPL-2.0-or-later & GPL-3.0-only & LGPL-2.0-only & LGPL-2.0-or-later & LGPL-2.1-only & LGPL-2.1-or-later & LGPL-3.0-only"
LIC_FILES_CHKSUM = " \
file://LICENSES/BSD-3-Clause.txt;md5=954f4d71a37096249f837652a7f586c0 \
file://LICENSES/CC0-1.0.txt;md5=65d3616852dbf7b1a6d4b53b00626032 \
file://LICENSES/GFDL-1.2-or-later.txt;md5=9f58808219e9a42ff1228309d6f83dc6 \
file://LICENSES/GPL-2.0-only.txt;md5=9e2385fe012386d34dcc5c9863070881 \
file://LICENSES/GPL-2.0-or-later.txt;md5=9e2385fe012386d34dcc5c9863070881 \
file://LICENSES/GPL-3.0-only.txt;md5=49fc03046e56a282c0c743b5d3a55b7c \
file://LICENSES/LGPL-2.0-only.txt;md5=da48810c4ddf8e49efa031294a26b98c \
file://LICENSES/LGPL-2.0-or-later.txt;md5=da48810c4ddf8e49efa031294a26b98c \
file://LICENSES/LGPL-2.1-only.txt;md5=147a320ed8b16b036829a0c71d424153 \
file://LICENSES/LGPL-2.1-or-later.txt;md5=147a320ed8b16b036829a0c71d424153 \
file://LICENSES/LGPL-3.0-only.txt;md5=8d51f5b5fd447f7a1040c3dc9f0a8de6 \
"
PR = "r0"
DEPENDS = " \
qtdeclarative \
kwayland \
kwindowsystem \
plasma-framework \
attica \
krunner \
kactivities-stats \
knotifyconfig \
knewstuff \
kdelibs4support \
kitemmodels \
kinit \
plasma-workspace \
wayland-native \
qtwayland-native \
kauth-native \
kauth \
libxkbfile \
"
inherit cmake_plasma
FILES:${PN} += " \
${datadir}/k* \
${datadir}/appdata \
${datadir}/config.kcfg \
${datadir}/color-schemes \
${datadir}/plasma \
${datadir}/dbus-1 \
${datadir}/icons \
${datadir}/polkit-1 \
${datadir}/solid \
${libdir}/libkdeinit5_kaccess.so \
${OE_QMAKE_PATH_QML} \
${OE_QMAKE_PATH_PLUGINS} \
${libdir}/kconf_update_bin \
"
RDEPENDS:${PN} += " \
qtdeclarative \
plasma-workspace \
qtgraphicaleffects \
qtquickcontrols-qmlplugins \
gawk \
"

View file

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: none
# SPDX-License-Identifier: CC0-1.0
require ${PN}.inc
SRC_URI += "https://download.kde.org/stable/plasma/5.27.4/plasma-desktop-5.27.4.tar.xz"
SRC_URI[sha256sum] = "b94f1cd5f121312268d757078041d83220556c90f73e895518fb19542ae3c800"

View file

@ -0,0 +1,49 @@
From b9cedf712cc1298347fead9b014495e3c0591b07 Mon Sep 17 00:00:00 2001
From: OpenEmbedded <oe.patch@oe>
Date: Wed, 26 Apr 2023 17:01:13 +0000
Subject: [PATCH] commit 95aab0fd83619408995720ce53d7a74790580220 author
liberato@chromium.org <liberato@chromium.org> Thu Jul 08 02:01:22 2021
committer liberato@chromium.org <liberato@chromium.org> Thu Jul 08
02:01:22 2021 tree ac725b5e2c548c8142aa7096d8184d87d3876a49 parent
e073b7a22e4993e0a7cab80a42a21524e5349f95
Add av_stream_get_first_dts for Chromium
---
libavformat/avformat.h | 4 ++++
libavformat/utils.c | 7 +++++++
2 files changed, 11 insertions(+)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6ce367e..cba3f5e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1115,6 +1115,10 @@ struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
*/
int64_t av_stream_get_end_pts(const AVStream *st);
+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st);
+// Chromium: We use the internal field first_dts ^^^
+
#define AV_PROGRAM_RUNNING 1
/**
diff --git a/libavformat/utils.c b/libavformat/utils.c
index cee86ae..6a01413 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -150,6 +150,13 @@ const AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
return avcodec_find_decoder(codec_id);
}
+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st)
+{
+ return cffstream(st)->first_dts;
+}
+// Chromium: We use the internal field first_dts ^^^
+
/* an arbitrarily chosen "sane" max packet size -- 50M */
#define SANE_CHUNK_SIZE (50000000)

View file

@ -0,0 +1,5 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI:append:riscv64 = "\
file://0001-fix-chromium.patch \
"

View file

@ -0,0 +1,2 @@
#needed to build qtwebengine (for the messed up pkgconfig depenedencies)
BBCLASSEXTEND = "native nativesdk"

View file

@ -0,0 +1 @@
PACKAGECONFIG:append = "resolvconf"

View file

@ -0,0 +1,4 @@
DEPENDS:append = " \
appstream \
kuserfeedback \
"

View file

@ -0,0 +1,11 @@
SRC_URI:append:jh7110 = " \
file://0001-Use-VisionFive2-specific-MESA-Fork.patch \
"
#The Cmake files include the sysroot directory to pipewire and spa, delete the actual sysroot from the path.
do_install:prepend() {
if [ "0" -ne $(find . -name \*.cmake | grep '_usr\|Export' | wc -l) ]; then
echo sed -i 's#'${RECIPE_SYSROOT}/usr'#\$\{_IMPORT_PREFIX\}#g' $(find . -name "*.cmake" | grep '_usr\|Export' )
sed -i 's#'${RECIPE_SYSROOT}/usr'#\$\{_IMPORT_PREFIX\}#g' $(find . -name "*.cmake" | grep '_usr\|Export' )
fi
}

View file

@ -0,0 +1,3 @@
SRC_URI:append:jh7110 = " \
file://0001-Use-VisionFive2-specific-MESA-Fork.patch \
"

View file

@ -0,0 +1,7 @@
SRC_URI:append:jh7110 = " \
file://0001-Use-VisionFive2-specific-MESA-Fork.patch \
"
DEPENDS:append = " \
appstream \
"

View file

@ -0,0 +1,21 @@
PACKAGECONFIG:append:class-target = " \
gles2 \
sm \
openssl \
fontconfig \
freetype \
harfbuzz \
sql-sqlite \
zlib \
jpeg \
libpng \
gif \
dbus \
udev \
accessibility \
cups \
gbm \
kms \
eglfs \
"
#PACKAGECONFIG:remove = "tests"

View file

@ -0,0 +1,3 @@
PACKAGECONFIG:append = " \
qml-debug \
"

View file

@ -0,0 +1,4 @@
#wrong path in yocto-meta-kde
SRC_URI = " \
git://code.qt.io/qt/qtfeedback.git;name=qtfeedback;branch=master;protocol=https \
"

View file

@ -0,0 +1,4 @@
PACKAGECONFIG:remove = " \
xcomposite-egl \
xcomposite-glx \
"

View file

@ -0,0 +1,34 @@
From 0daecef3dca30f0adc613228b70f426e71056f5b Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Wed, 26 Apr 2023 12:19:59 +0800
Subject: [PATCH] add riscv64 support
---
configure.pri | 1 +
mkspecs/features/functions.prf | 1 +
2 files changed, 2 insertions(+)
diff --git a/configure.pri b/configure.pri
index e072961f0..d8f385cf0 100644
--- a/configure.pri
+++ b/configure.pri
@@ -144,6 +144,7 @@ defineTest(qtConfTest_detectArch) {
contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true)
contains(QT_ARCH, "mips"): return(true)
contains(QT_ARCH, "mips64"): return(true)
+ contains(QT_ARCH, "riscv64"): return(true)
qtLog("Architecture not supported.")
return(false)
}
diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf
index 7f630588a..07b812f4b 100644
--- a/mkspecs/features/functions.prf
+++ b/mkspecs/features/functions.prf
@@ -112,6 +112,7 @@ defineReplace(gnArch) {
contains(qtArch, "mips"): return(mipsel)
contains(qtArch, "mips64"): return(mips64el)
contains(qtArch, "mips64el"): return(mips64el)
+ contains(qtArch, "riscv64"): return(riscv64)
return(unknown)
}

View file

@ -0,0 +1,23 @@
From 747f4bde1fa389041c2761d70436559ca2568e94 Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Thu, 27 Apr 2023 00:45:04 +0800
Subject: [PATCH] don't try to link gn statically
---
src/buildtools/gn.pro | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro
index a8ca6567b..c007223ed 100644
--- a/src/buildtools/gn.pro
+++ b/src/buildtools/gn.pro
@@ -20,7 +20,8 @@ build_pass|!debug_and_release {
gn_gen_args = --no-last-commit-position --out-path $$out_path \
--cc \"$$which($$CC_host)\" --cxx \"$$which($$CXX_host)\" \
- --ld \"$$which($$CXX_host)\" --ar \"$$which(ar)\"
+ --ld \"$$which($$CXX_host)\" --ar \"$$which(ar)\" \
+ --no-static-libstdc++
msvc:!clang_cl: gn_gen_args += --use-lto

View file

@ -0,0 +1,524 @@
From c5c905bc97c6d38323d820d4d44b95f2a1883a36 Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Wed, 26 Apr 2023 12:21:39 +0800
Subject: [PATCH 3/8] add riscv64 support - chromium
---
chromium/base/process/launch_posix.cc | 2 +-
chromium/build/build_config.h | 5 +
chromium/build/toolchain/linux/BUILD.gn | 17 +++
chromium/skia/BUILD.gn | 2 +
chromium/third_party/angle/gni/angle.gni | 2 +-
.../angle/include/platform/PlatformMethods.h | 1 +
.../blink/renderer/platform/heap/asm/BUILD.gn | 2 +
.../platform/heap/asm/SaveRegisters_riscv64.S | 45 ++++++
.../boringssl/src/include/openssl/base.h | 2 +
.../dav1d/config/linux/riscv64/config.h | 38 +++++
.../third_party/lss/linux_syscall_support.h | 132 +++++++++++++++++-
.../third_party/llvm-10.0/BUILD.gn | 1 +
.../modules/desktop_capture/differ_block.cc | 2 +-
.../third_party/webrtc/rtc_base/system/arch.h | 4 +
gn/tools/gn/args.cc | 3 +
gn/util/build_config.h | 10 ++
16 files changed, 258 insertions(+), 10 deletions(-)
create mode 100644 chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_riscv64.S
create mode 100644 chromium/third_party/dav1d/config/linux/riscv64/config.h
diff --git a/chromium/base/process/launch_posix.cc b/chromium/base/process/launch_posix.cc
index a8b1f0bdf95..2ea2287335d 100644
--- a/chromium/base/process/launch_posix.cc
+++ b/chromium/base/process/launch_posix.cc
@@ -704,7 +704,7 @@ NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags,
alignas(16) char stack_buf[PTHREAD_STACK_MIN];
#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \
defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_S390_FAMILY) || \
- defined(ARCH_CPU_PPC64_FAMILY)
+ defined(ARCH_CPU_PPC64_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY)
// The stack grows downward.
void* stack = stack_buf + sizeof(stack_buf);
#else
diff --git a/chromium/build/build_config.h b/chromium/build/build_config.h
index 2c3e81ee1d4..230b90347dd 100644
--- a/chromium/build/build_config.h
+++ b/chromium/build/build_config.h
@@ -193,6 +193,11 @@
#define ARCH_CPU_32_BITS 1
#define ARCH_CPU_BIG_ENDIAN 1
#endif
+#elif defined(__riscv) && __riscv_xlen == 64
+#define ARCH_CPU_RISCV_FAMILY 1
+#define ARCH_CPU_RISCV64 1
+#define ARCH_CPU_64_BITS 1
+#define ARCH_CPU_LITTLE_ENDIAN 1
#else
#error Please add support for your architecture in build/build_config.h
#endif
diff --git a/chromium/build/toolchain/linux/BUILD.gn b/chromium/build/toolchain/linux/BUILD.gn
index fa8b17e9db3..edc2ec51465 100644
--- a/chromium/build/toolchain/linux/BUILD.gn
+++ b/chromium/build/toolchain/linux/BUILD.gn
@@ -298,3 +298,20 @@ gcc_toolchain("mips64") {
is_clang = false
}
}
+
+gcc_toolchain("riscv64") {
+ cc = "gcc"
+ cxx = "g++"
+
+ readelf = "readelf"
+ nm = "nm"
+ ar = "ar"
+ ld = cxx
+
+ toolchain_args = {
+ current_cpu = "riscv64"
+ current_os = "linux"
+ is_clang = false
+ }
+}
+
diff --git a/chromium/skia/BUILD.gn b/chromium/skia/BUILD.gn
index 6a107a51a90..955371e9e91 100644
--- a/chromium/skia/BUILD.gn
+++ b/chromium/skia/BUILD.gn
@@ -821,6 +821,8 @@ skia_source_set("skia_opts") {
sources = skia_opts.none_sources
} else if (current_cpu == "s390x") {
sources = skia_opts.none_sources
+ } else if (current_cpu == "riscv64") {
+ sources = skia_opts.none_sources
} else {
assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
}
diff --git a/chromium/third_party/angle/gni/angle.gni b/chromium/third_party/angle/gni/angle.gni
index c4fe8c83b14..a4319d79337 100644
--- a/chromium/third_party/angle/gni/angle.gni
+++ b/chromium/third_party/angle/gni/angle.gni
@@ -54,7 +54,7 @@ angle_data_dir = "angledata"
declare_args() {
if (current_cpu == "arm64" || current_cpu == "x64" ||
current_cpu == "mips64el" || current_cpu == "s390x" ||
- current_cpu == "ppc64") {
+ current_cpu == "ppc64" || current_cpu == "riscv64") {
angle_64bit_current_cpu = true
} else if (current_cpu == "arm" || current_cpu == "x86" ||
current_cpu == "mipsel" || current_cpu == "s390" ||
diff --git a/chromium/third_party/angle/include/platform/PlatformMethods.h b/chromium/third_party/angle/include/platform/PlatformMethods.h
index 4697a87e458..e0f43658352 100644
--- a/chromium/third_party/angle/include/platform/PlatformMethods.h
+++ b/chromium/third_party/angle/include/platform/PlatformMethods.h
@@ -9,6 +9,7 @@
#ifndef ANGLE_PLATFORMMETHODS_H
#define ANGLE_PLATFORMMETHODS_H
+#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <array>
diff --git a/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn b/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn
index fe44daf27a5..3533a84c9f6 100644
--- a/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn
+++ b/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn
@@ -38,6 +38,8 @@ if (current_cpu == "x86" || current_cpu == "x64") {
sources = [ "SaveRegisters_mips64.S" ]
} else if (current_cpu == "ppc64") {
sources = [ "SaveRegisters_ppc64.S" ]
+ } else if (current_cpu == "riscv64") {
+ sources = [ "SaveRegisters_riscv64.S" ]
}
if (current_cpu == "arm") {
diff --git a/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_riscv64.S b/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_riscv64.S
new file mode 100644
index 00000000000..30208fd45a8
--- /dev/null
+++ b/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_riscv64.S
@@ -0,0 +1,45 @@
+/*
+ * typedef void (*PushAllRegistersCallback)(ThreadState*, intptr_t*);
+ * extern "C" void PushAllRegisters(ThreadState*, PushAllRegistersCallback)
+ */
+
+.type PushAllRegisters, %function
+.global PushAllRegisters
+.hidden PushAllRegisters
+PushAllRegisters:
+ /* Push all callee-saves registers to get them
+ * on the stack for conservative stack scanning.
+ * Reserve space for callee-saved registers and return address.
+ */
+ addi sp,sp,-112
+ /* Save the callee-saved registers and the return address. */
+ sd ra,0(sp)
+ sd s0,8(sp)
+ sd s1,16(sp)
+ sd s2,24(sp)
+ sd s3,32(sp)
+ sd s4,40(sp)
+ sd s5,48(sp)
+ sd s6,56(sp)
+ sd s7,64(sp)
+ sd s8,72(sp)
+ sd s9,80(sp)
+ sd s10,88(sp)
+ sd s11,96(sp)
+ /* Note: the callee-saved floating point registers do not need to be
+ * copied to the stack, because fp registers never hold heap pointers
+ * and so do not need to be kept visible to the garbage collector.
+ * Pass the first argument untouched in a0 and the
+ * stack pointer to the callback.
+ */
+ mv ra,a1
+ mv a1,sp
+ jalr ra
+ /* Restore return address, adjust stack and return.
+ * Note: the copied registers do not need to be reloaded here,
+ * because they were preserved by the called routine.
+ */
+ ld ra,0(sp)
+ addi sp,sp,112
+ ret
+.size PushAllRegisters, . - PushAllRegisters
diff --git a/chromium/third_party/boringssl/src/include/openssl/base.h b/chromium/third_party/boringssl/src/include/openssl/base.h
index d681bdf81e6..42d64371646 100644
--- a/chromium/third_party/boringssl/src/include/openssl/base.h
+++ b/chromium/third_party/boringssl/src/include/openssl/base.h
@@ -105,6 +105,8 @@ extern "C" {
#elif defined(__mips__) && defined(__LP64__)
#define OPENSSL_64_BIT
#define OPENSSL_MIPS64
+#elif defined(__riscv) && __SIZEOF_POINTER__ == 8
+#define OPENSSL_64_BIT
#elif defined(__pnacl__)
#define OPENSSL_32_BIT
#define OPENSSL_PNACL
diff --git a/chromium/third_party/dav1d/config/linux/riscv64/config.h b/chromium/third_party/dav1d/config/linux/riscv64/config.h
new file mode 100644
index 00000000000..3ad3dc4b103
--- /dev/null
+++ b/chromium/third_party/dav1d/config/linux/riscv64/config.h
@@ -0,0 +1,38 @@
+/*
+ * Autogenerated by the Meson build system.
+ * Do not edit, your changes will be lost.
+ */
+
+#pragma once
+
+#define ARCH_AARCH64 0
+
+#define ARCH_ARM 0
+
+#define ARCH_PPC64LE 0
+
+#define ARCH_X86 0
+
+#define ARCH_X86_32 0
+
+#define ARCH_X86_64 0
+
+#define CONFIG_16BPC 1
+
+#define CONFIG_8BPC 1
+
+// #define CONFIG_LOG 1 -- Logging is controlled by Chromium
+
+#define ENDIANNESS_BIG 0
+
+#define HAVE_ASM 0
+
+#define HAVE_AS_FUNC 0
+
+#define HAVE_CLOCK_GETTIME 1
+
+#define HAVE_GETAUXVAL 1
+
+#define HAVE_POSIX_MEMALIGN 1
+
+#define HAVE_UNISTD_H 1
diff --git a/chromium/third_party/lss/linux_syscall_support.h b/chromium/third_party/lss/linux_syscall_support.h
index e4ac22644c0..51ba86a71f0 100644
--- a/chromium/third_party/lss/linux_syscall_support.h
+++ b/chromium/third_party/lss/linux_syscall_support.h
@@ -88,7 +88,7 @@
*/
#if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \
defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \
- defined(__aarch64__) || defined(__s390__)) \
+ defined(__aarch64__) || defined(__s390__) || defined(__riscv)) \
&& (defined(__linux) || defined(__ANDROID__))
#ifndef SYS_CPLUSPLUS
@@ -301,7 +301,7 @@ struct kernel_old_sigaction {
} __attribute__((packed,aligned(4)));
#elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32)
#define kernel_old_sigaction kernel_sigaction
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) || defined(__riscv)
// No kernel_old_sigaction defined for arm64.
#endif
@@ -341,7 +341,9 @@ struct kernel_sigaction {
void (*sa_sigaction_)(int, siginfo_t *, void *);
};
unsigned long sa_flags;
+#ifndef __riscv
void (*sa_restorer)(void);
+#endif
struct kernel_sigset_t sa_mask;
#endif
};
@@ -519,7 +521,7 @@ struct kernel_stat {
int st_blocks;
int st_pad4[14];
};
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) || defined(__riscv)
struct kernel_stat {
unsigned long st_dev;
unsigned long st_ino;
@@ -1065,7 +1067,7 @@ struct kernel_statfs {
#define __NR_getrandom (__NR_SYSCALL_BASE + 384)
#endif
/* End of ARM 3/EABI definitions */
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) || defined(__riscv)
#ifndef __NR_setxattr
#define __NR_setxattr 5
#endif
@@ -1880,7 +1882,7 @@ struct kernel_statfs {
#undef LSS_RETURN
#if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \
- || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__))
+ || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__) || defined(__riscv))
/* Failing system calls return a negative result in the range of
* -1..-4095. These are "errno" values with the sign inverted.
*/
@@ -3373,6 +3375,122 @@ struct kernel_statfs {
}
LSS_RETURN(int, __ret);
}
+ #elif defined(__riscv)
+ #undef LSS_REG
+ #define LSS_REG(r,a) register int64_t __r##r __asm__("a"#r) = (int64_t)a
+ #undef LSS_BODY
+ #define LSS_BODY(type,name,args...) \
+ register int64_t __res_a0 __asm__("a0"); \
+ register int64_t __a7 __asm__("a7") = __NR_##name; \
+ int64_t __res; \
+ __asm__ __volatile__ ("scall\n" \
+ : "=r"(__res_a0) \
+ : "r"(__a7) , ## args \
+ : "memory"); \
+ __res = __res_a0; \
+ LSS_RETURN(type, __res)
+ #undef _syscall0
+ #define _syscall0(type, name) \
+ type LSS_NAME(name)(void) { \
+ LSS_BODY(type, name); \
+ }
+ #undef _syscall1
+ #define _syscall1(type, name, type1, arg1) \
+ type LSS_NAME(name)(type1 arg1) { \
+ LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \
+ }
+ #undef _syscall2
+ #define _syscall2(type, name, type1, arg1, type2, arg2) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2) { \
+ LSS_REG(0, arg1); LSS_REG(1, arg2); \
+ LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \
+ }
+ #undef _syscall3
+ #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \
+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \
+ }
+ #undef _syscall4
+ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
+ LSS_REG(3, arg4); \
+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \
+ }
+ #undef _syscall5
+ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5) { \
+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
+ LSS_REG(3, arg4); LSS_REG(4, arg5); \
+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \
+ "r"(__r4)); \
+ }
+ #undef _syscall6
+ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5, type6 arg6) { \
+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \
+ LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \
+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \
+ "r"(__r4), "r"(__r5)); \
+ }
+
+ LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
+ int flags, void *arg, int *parent_tidptr,
+ void *newtls, int *child_tidptr) {
+ int64_t __res;
+ {
+ register int64_t __res_a0 __asm__("a0");
+ register uint64_t __flags __asm__("a0") = flags;
+ register void *__stack __asm__("a1") = child_stack;
+ register void *__ptid __asm__("a2") = parent_tidptr;
+ register void *__tls __asm__("a3") = newtls;
+ register int *__ctid __asm__("a4") = child_tidptr;
+ __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be
+ * used by the child.
+ */
+ "addi %2,%2,-16\n"
+ "sd %1, 0(%2)\n"
+ "sd %4, 8(%2)\n"
+
+ /* %a0 = syscall(%a0 = flags,
+ * %a1 = child_stack,
+ * %a2 = parent_tidptr,
+ * %a3 = newtls,
+ * %a4 = child_tidptr)
+ */
+ "li a7, %8\n"
+ "scall\n"
+
+ /* if (%a0 != 0)
+ * return %a0;
+ */
+ "bnez %0, 1f\n"
+
+ /* In the child, now. Call "fn(arg)".
+ */
+ "ld a1, 0(sp)\n"
+ "ld a0, 8(sp)\n"
+ "jalr a1\n"
+
+ /* Call _exit(%a0).
+ */
+ "li a7, %9\n"
+ "scall\n"
+ "1:\n"
+ : "=r" (__res_a0)
+ : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
+ "r"(__ptid), "r"(__tls), "r"(__ctid),
+ "i"(__NR_clone), "i"(__NR_exit)
+ : "cc", "memory");
+ __res = __res_a0;
+ }
+ LSS_RETURN(int, __res);
+ }
#endif
#define __NR__exit __NR_exit
#define __NR__gettid __NR_gettid
@@ -4181,7 +4299,7 @@ struct kernel_statfs {
LSS_SC_BODY(4, int, 8, d, type, protocol, sv);
}
#endif
- #if defined(__ARM_EABI__) || defined (__aarch64__)
+ #if defined(__ARM_EABI__) || defined (__aarch64__) || defined(__riscv)
LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg,
int, flags)
LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*,
@@ -4503,7 +4621,7 @@ struct kernel_statfs {
// TODO: define this in an arch-independant way instead of inlining the clone
// syscall body.
-# if defined(__aarch64__)
+# if defined(__aarch64__) || defined(__riscv)
LSS_INLINE pid_t LSS_NAME(fork)(void) {
// No fork syscall on aarch64 - implement by means of the clone syscall.
// Note that this does not reset glibc's cached view of the PID/TID, so
diff --git a/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn b/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn
index 70e14c06fbd..f44a8569e69 100644
--- a/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn
+++ b/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn
@@ -149,6 +149,7 @@ swiftshader_llvm_source_set("swiftshader_llvm") {
deps += [ ":swiftshader_llvm_ppc" ]
} else if (current_cpu == "x86" || current_cpu == "x64") {
deps += [ ":swiftshader_llvm_x86" ]
+ } else if (current_cpu == "riscv64") {
} else {
assert(false, "Unsupported current_cpu")
}
diff --git a/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc b/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc
index 4f0c5430c9a..a89fcc97533 100644
--- a/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc
+++ b/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc
@@ -30,7 +30,7 @@ bool VectorDifference(const uint8_t* image1, const uint8_t* image2) {
static bool (*diff_proc)(const uint8_t*, const uint8_t*) = nullptr;
if (!diff_proc) {
-#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY)
+#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) || defined(WEBRTC_ARCH_RISCV_FAMILY)
// For ARM and MIPS processors, always use C version.
// TODO(hclam): Implement a NEON version.
diff_proc = &VectorDifference_C;
diff --git a/chromium/third_party/webrtc/rtc_base/system/arch.h b/chromium/third_party/webrtc/rtc_base/system/arch.h
index ed216e660fd..28898aebdca 100644
--- a/chromium/third_party/webrtc/rtc_base/system/arch.h
+++ b/chromium/third_party/webrtc/rtc_base/system/arch.h
@@ -50,6 +50,10 @@
#elif defined(__EMSCRIPTEN__)
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
+#elif defined(__riscv) && __riscv_xlen == 64
+#define WEBRTC_ARCH_RISCV_FAMILY
+#define WEBRTC_ARCH_64_BITS
+#define WEBRTC_ARCH_LITTLE_ENDIAN
#else
#error Please add support for your architecture in rtc_base/system/arch.h
#endif
diff --git a/gn/tools/gn/args.cc b/gn/tools/gn/args.cc
index d3491a42247..16e0bc6025c 100644
--- a/gn/tools/gn/args.cc
+++ b/gn/tools/gn/args.cc
@@ -329,6 +329,7 @@ void Args::SetSystemVarsLocked(Scope* dest) const {
static const char kMips64[] = "mips64el";
static const char kS390X[] = "s390x";
static const char kPPC64[] = "ppc64";
+ static const char kRiscv64[] = "riscv64";
const char* arch = nullptr;
// Set the host CPU architecture based on the underlying OS, not
@@ -353,6 +354,8 @@ void Args::SetSystemVarsLocked(Scope* dest) const {
// This allows us to use the same toolchain as ppc64 BE
// and specific flags are included using the host_byteorder logic.
arch = kPPC64;
+ else if (os_arch == "riscv64")
+ arch = kRiscv64;
else
CHECK(false) << "OS architecture not handled. (" << os_arch << ")";
diff --git a/gn/util/build_config.h b/gn/util/build_config.h
index addd7cfb081..5fe346edd48 100644
--- a/gn/util/build_config.h
+++ b/gn/util/build_config.h
@@ -172,6 +172,16 @@
#define ARCH_CPU_32_BITS 1
#define ARCH_CPU_BIG_ENDIAN 1
#endif
+#elif defined(__riscv)
+#define ARCH_CPU_RISCV_FAMILY 1
+#if __riscv_xlen == 64
+#define ARCH_CPU_RISCV64 1
+#define ARCH_CPU_64_BITS 1
+#else
+#define ARCH_CPU_RISCV32 1
+#define ARCH_CPU_32_BITS 1
+#endif
+#define ARCH_CPU_LITTLE_ENDIAN 1
#else
#error Please add support for your architecture in build_config.h
#endif
--
2.31.1

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,835 @@
From 01db66746d8dd0d684948725d793a9e95be88544 Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Wed, 26 Apr 2023 12:23:52 +0800
Subject: [PATCH 5/8] add risc64 crashpad support - chromium
---
.../crashpad/minidump/minidump_context.h | 35 ++++++++
.../minidump/minidump_context_writer.cc | 44 +++++++++
.../minidump/minidump_context_writer.h | 40 +++++++++
.../minidump/minidump_misc_info_writer.cc | 4 +
.../crashpad/snapshot/capture_memory.cc | 10 +++
.../crashpad/snapshot/cpu_architecture.h | 8 +-
.../crashpad/crashpad/snapshot/cpu_context.cc | 2 +
.../crashpad/crashpad/snapshot/cpu_context.h | 16 ++++
.../snapshot/linux/cpu_context_linux.cc | 24 +++++
.../snapshot/linux/cpu_context_linux.h | 16 ++++
.../linux/exception_snapshot_linux.cc | 55 ++++++++++++
.../snapshot/linux/exception_snapshot_linux.h | 3 +
.../snapshot/linux/process_reader_linux.cc | 3 +
.../crashpad/snapshot/linux/signal_context.h | 61 +++++++++++++
.../snapshot/linux/system_snapshot_linux.cc | 12 +++
.../snapshot/linux/thread_snapshot_linux.cc | 16 ++++
.../snapshot/linux/thread_snapshot_linux.h | 3 +
.../crashpad/crashpad/util/linux/ptracer.cc | 90 +++++++++++++++++++
.../crashpad/util/linux/thread_info.h | 78 +++++++++++++++-
19 files changed, 518 insertions(+), 2 deletions(-)
diff --git a/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h b/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h
index 3a3e603cb0d..cf074d2b823 100644
--- a/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h
+++ b/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h
@@ -592,6 +592,41 @@ struct MinidumpContextMIPS64 {
uint64_t fir;
};
+//! \brief 64bit RISC-V-specifc flags for MinidumpContextRISCV64::context_flags.
+//! Based on minidump_cpu_riscv64.h from breakpad
+enum MinidumpContextRISCV64Flags : uint32_t {
+ //! \brief Identifies the context structure as RISCV64.
+ kMinidumpContextRISCV64 = 0x00080000,
+
+ //! \brief Indicates the validity of integer registers.
+ //!
+ //! Registers `x1`-`x31` and pc are valid.
+ kMinidumpContextRISCV64Integer = kMinidumpContextRISCV64 | 0x00000002,
+
+ //! \brief Indicates the validity of floating point registers.
+ //!
+ //! Floating point registers `f0`-`f31`, and `fcsr` are valid
+ kMinidumpContextRISCV64FloatingPoint = kMinidumpContextRISCV64 | 0x00000004,
+
+ //! \brief Indicates the validity of all registers.
+ kMinidumpContextRISCV64All = kMinidumpContextRISCV64Integer |
+ kMinidumpContextRISCV64FloatingPoint,
+};
+
+//! \brief A 64bit RISCV CPU context (register state) carried in a minidump file.
+struct MinidumpContextRISCV64 {
+ uint64_t context_flags;
+
+ //! \brief General purpose registers.
+ uint64_t regs[32];
+
+ //! \brief FPU registers.
+ uint64_t fpregs[32];
+
+ //! \brief FPU status register.
+ uint64_t fcsr;
+};
+
} // namespace crashpad
#endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
diff --git a/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc b/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
index d7e53a4932f..e932f0dc974 100644
--- a/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
+++ b/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
@@ -101,6 +101,13 @@ MinidumpContextWriter::CreateFromSnapshot(const CPUContext* context_snapshot) {
break;
}
+ case kCPUArchitectureRISCV64: {
+ context = std::make_unique<MinidumpContextRISCV64Writer>();
+ reinterpret_cast<MinidumpContextRISCV64Writer*>(context.get())
+ ->InitializeFromSnapshot(context_snapshot->riscv64);
+ break;
+ }
+
default: {
LOG(ERROR) << "unknown context architecture "
<< context_snapshot->architecture;
@@ -453,4 +460,41 @@ size_t MinidumpContextMIPS64Writer::ContextSize() const {
return sizeof(context_);
}
+MinidumpContextRISCV64Writer::MinidumpContextRISCV64Writer()
+ : MinidumpContextWriter(), context_() {
+ context_.context_flags = kMinidumpContextRISCV64;
+}
+
+MinidumpContextRISCV64Writer::~MinidumpContextRISCV64Writer() = default;
+
+void MinidumpContextRISCV64Writer::InitializeFromSnapshot(
+ const CPUContextRISCV64* context_snapshot) {
+ DCHECK_EQ(state(), kStateMutable);
+ DCHECK_EQ(context_.context_flags, kMinidumpContextRISCV64);
+
+ context_.context_flags = kMinidumpContextRISCV64All;
+
+ static_assert(sizeof(context_.regs) == sizeof(context_snapshot->regs),
+ "GPRs size mismatch");
+ memcpy(context_.regs, context_snapshot->regs, sizeof(context_.regs));
+
+ static_assert(sizeof(context_.fpregs) == sizeof(context_snapshot->fpregs),
+ "FPRs size mismatch");
+ memcpy(context_.fpregs,
+ context_snapshot->fpregs,
+ sizeof(context_.fpregs));
+ context_.fcsr = context_snapshot->fcsr;
+}
+
+bool MinidumpContextRISCV64Writer::WriteObject(
+ FileWriterInterface* file_writer) {
+ DCHECK_EQ(state(), kStateWritable);
+ return file_writer->Write(&context_, sizeof(context_));
+}
+
+size_t MinidumpContextRISCV64Writer::ContextSize() const {
+ DCHECK_GE(state(), kStateFrozen);
+ return sizeof(context_);
+}
+
} // namespace crashpad
diff --git a/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h b/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
index d4ab936ee7f..9b52589619c 100644
--- a/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
+++ b/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
@@ -315,6 +315,46 @@ class MinidumpContextMIPS64Writer final : public MinidumpContextWriter {
DISALLOW_COPY_AND_ASSIGN(MinidumpContextMIPS64Writer);
};
+//! \brief The writer for a MinidumpContextRISCV64 structure in a minidump file.
+class MinidumpContextRISCV64Writer final : public MinidumpContextWriter {
+ public:
+ MinidumpContextRISCV64Writer();
+ ~MinidumpContextRISCV64Writer() override;
+
+ //! \brief Initializes the MinidumpContextRISCV based on \a context_snapshot.
+ //!
+ //! \param[in] context_snapshot The context snapshot to use as source data.
+ //!
+ //! \note Valid in #kStateMutable. No mutation of context() may be done before
+ //! calling this method, and it is not normally necessary to alter
+ //! context() after calling this method.
+ void InitializeFromSnapshot(const CPUContextRISCV64* context_snapshot);
+
+ //! \brief Returns a pointer to the context structure that this object will
+ //! write.
+ //!
+ //! \attention This returns a non-`const` pointer to this objects private
+ //! data so that a caller can populate the context structure directly.
+ //! This is done because providing setter interfaces to each field in the
+ //! context structure would be unwieldy and cumbersome. Care must be taken
+ //! to populate the context structure correctly. The context structure
+ //! must only be modified while this object is in the #kStateMutable
+ //! state.
+ MinidumpContextRISCV64* context() { return &context_; }
+
+ protected:
+ // MinidumpWritable:
+ bool WriteObject(FileWriterInterface* file_writer) override;
+
+ // MinidumpContextWriter:
+ size_t ContextSize() const override;
+
+ private:
+ MinidumpContextRISCV64 context_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpContextRISCV64Writer);
+};
+
} // namespace crashpad
#endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_
diff --git a/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc b/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
index 0974e3ddf5a..a3d94601144 100644
--- a/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
+++ b/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
@@ -135,6 +135,10 @@ std::string MinidumpMiscInfoDebugBuildString() {
static constexpr char kCPU[] = "mips";
#elif defined(ARCH_CPU_MIPS64EL)
static constexpr char kCPU[] = "mips64";
+#elif defined(ARCH_CPU_RISCV)
+ static constexpr char kCPU[] = "riscv";
+#elif defined(ARCH_CPU_RISCV64)
+ static constexpr char kCPU[] = "riscv64";
#else
#error define kCPU for this CPU
#endif
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc b/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc
index 7a1b2763c08..715f0a94634 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc
+++ b/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc
@@ -112,6 +112,16 @@ void CaptureMemory::PointedToByContext(const CPUContext& context,
for (size_t i = 0; i < base::size(context.mipsel->regs); ++i) {
MaybeCaptureMemoryAround(delegate, context.mipsel->regs[i]);
}
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ if (context.architecture == kCPUArchitectureRISCV) {
+ for (size_t i = 0; i < base::size(context.riscv->regs); ++i) {
+ MaybeCaptureMemoryAround(delegate, context.riscv->regs[i]);
+ }
+ } else {
+ for (size_t i = 0; i < base::size(context.riscv64->regs); ++i) {
+ MaybeCaptureMemoryAround(delegate, context.riscv64->regs[i]);
+ }
+ }
#else
#error Port.
#endif
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h b/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
index 811a7209587..5b09abdb967 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
+++ b/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
@@ -43,7 +43,13 @@ enum CPUArchitecture {
kCPUArchitectureMIPSEL,
//! \brief 64-bit MIPSEL.
- kCPUArchitectureMIPS64EL
+ kCPUArchitectureMIPS64EL,
+
+ //! \brief 32-bit RISCV.
+ kCPUArchitectureRISCV,
+
+ //! \brief 64-bit RISCV.
+ kCPUArchitectureRISCV64
};
} // namespace crashpad
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc b/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc
index c75b5555e1d..0c6d536891b 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc
+++ b/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc
@@ -196,10 +196,12 @@ bool CPUContext::Is64Bit() const {
case kCPUArchitectureX86_64:
case kCPUArchitectureARM64:
case kCPUArchitectureMIPS64EL:
+ case kCPUArchitectureRISCV64:
return true;
case kCPUArchitectureX86:
case kCPUArchitectureARM:
case kCPUArchitectureMIPSEL:
+ case kCPUArchitectureRISCV:
return false;
default:
NOTREACHED();
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h b/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h
index fb23c4679f0..e120a980448 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h
+++ b/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h
@@ -352,6 +352,20 @@ struct CPUContextMIPS64 {
uint64_t fir;
};
+//! \brief A context structure carrying RISC CPU state.
+struct CPUContextRISCV {
+ uint32_t regs[32];
+ uint64_t fpregs[32];
+ uint32_t fcsr;
+};
+
+//! \brief A context structure carrying RISC64 CPU state.
+struct CPUContextRISCV64 {
+ uint64_t regs[32];
+ uint64_t fpregs[32];
+ uint32_t fcsr;
+};
+
//! \brief A context structure capable of carrying the context of any supported
//! CPU architecture.
struct CPUContext {
@@ -382,6 +396,8 @@ struct CPUContext {
CPUContextARM64* arm64;
CPUContextMIPS* mipsel;
CPUContextMIPS64* mips64;
+ CPUContextRISCV* riscv;
+ CPUContextRISCV64* riscv64;
};
};
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc b/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
index 8464a5a27b2..ec41216daa9 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
@@ -266,6 +266,30 @@ void InitializeCPUContextARM64_OnlyFPSIMD(
context->fpcr = float_context.fpcr;
}
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+
+template <typename Traits>
+void InitializeCPUContextRISCV(
+ const typename Traits::SignalThreadContext& thread_context,
+ const typename Traits::SignalFloatContext& float_context,
+ typename Traits::CPUContext* context) {
+ static_assert(sizeof(context->regs) == sizeof(thread_context),
+ "registers size mismatch");
+ static_assert(sizeof(context->fpregs) == sizeof(float_context.f),
+ "fp registers size mismatch");
+ memcpy(&context->regs, &thread_context, sizeof(context->regs));
+ memcpy(&context->fpregs, &float_context, sizeof(context->fpregs));
+ context->fcsr = float_context.fcsr;
+}
+template void InitializeCPUContextRISCV<ContextTraits32>(
+ const ContextTraits32::SignalThreadContext& thread_context,
+ const ContextTraits32::SignalFloatContext& float_context,
+ ContextTraits32::CPUContext* context);
+template void InitializeCPUContextRISCV<ContextTraits64>(
+ const ContextTraits64::SignalThreadContext& thread_context,
+ const ContextTraits64::SignalFloatContext& float_context,
+ ContextTraits64::CPUContext* context);
+
#endif // ARCH_CPU_X86_FAMILY
} // namespace internal
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h b/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
index 9f46a48977e..1add07f81af 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
@@ -174,6 +174,22 @@ void InitializeCPUContextMIPS(
#endif // ARCH_CPU_MIPS_FAMILY || DOXYGEN
+#if defined(ARCH_CPU_RISCV_FAMILY) || DOXYGEN
+
+//! \brief Initializes a CPUContextRISCV structure from native context
+//! structures on Linux.
+//!
+//! \param[in] thread_context The native thread context.
+//! \param[in] float_context The native float context.
+//! \param[out] context The CPUContextRISCV structure to initialize.
+template <typename Traits>
+void InitializeCPUContextRISCV(
+ const typename Traits::SignalThreadContext& thread_context,
+ const typename Traits::SignalFloatContext& float_context,
+ typename Traits::CPUContext* context);
+
+#endif // ARCH_CPU_RISCV_FAMILY || DOXYGEN
+
} // namespace internal
} // namespace crashpad
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc b/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
index cd40b3b12d6..9963437e38c 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
@@ -323,6 +323,61 @@ bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
reader, context_address, context_.mips64);
}
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+
+template <typename Traits>
+static bool ReadContext(ProcessReaderLinux* reader,
+ LinuxVMAddress context_address,
+ typename Traits::CPUContext* dest_context) {
+ const ProcessMemory* memory = reader->Memory();
+
+ LinuxVMAddress gregs_address = context_address +
+ offsetof(UContext<Traits>, mcontext) +
+ offsetof(typename Traits::MContext, gregs);
+
+ typename Traits::SignalThreadContext thread_context;
+ if (!memory->Read(gregs_address, sizeof(thread_context), &thread_context)) {
+ LOG(ERROR) << "Couldn't read gregs";
+ return false;
+ }
+
+ LinuxVMAddress fpregs_address = context_address +
+ offsetof(UContext<Traits>, mcontext) +
+ offsetof(typename Traits::MContext, fpregs);
+
+ typename Traits::SignalFloatContext fp_context;
+ if (!memory->Read(fpregs_address, sizeof(fp_context), &fp_context)) {
+ LOG(ERROR) << "Couldn't read fpregs";
+ return false;
+ }
+
+ InitializeCPUContextRISCV<Traits>(thread_context, fp_context, dest_context);
+
+ return true;
+}
+
+template <>
+bool ExceptionSnapshotLinux::ReadContext<ContextTraits32>(
+ ProcessReaderLinux* reader,
+ LinuxVMAddress context_address) {
+ context_.architecture = kCPUArchitectureRISCV;
+ context_.riscv = &context_union_.riscv;
+
+ return internal::ReadContext<ContextTraits32>(
+ reader, context_address, context_.riscv);
+}
+
+template <>
+bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
+ ProcessReaderLinux* reader,
+ LinuxVMAddress context_address) {
+ context_.architecture = kCPUArchitectureRISCV64;
+ context_.riscv64 = &context_union_.riscv64;
+
+ return internal::ReadContext<ContextTraits64>(
+ reader, context_address, context_.riscv64);
+}
+
#endif // ARCH_CPU_X86_FAMILY
bool ExceptionSnapshotLinux::Initialize(ProcessReaderLinux* process_reader,
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h b/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
index ea0cd21066d..a612272ab73 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
@@ -84,6 +84,9 @@ class ExceptionSnapshotLinux final : public ExceptionSnapshot {
#elif defined(ARCH_CPU_MIPS_FAMILY)
CPUContextMIPS mipsel;
CPUContextMIPS64 mips64;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ CPUContextRISCV riscv;
+ CPUContextRISCV64 riscv64;
#endif
} context_union_;
CPUContext context_;
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc b/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
index ee246e8bcbe..dfe6959f0fc 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
@@ -108,6 +108,9 @@ void ProcessReaderLinux::Thread::InitializeStack(ProcessReaderLinux* reader) {
#elif defined(ARCH_CPU_MIPS_FAMILY)
stack_pointer = reader->Is64Bit() ? thread_info.thread_context.t64.regs[29]
: thread_info.thread_context.t32.regs[29];
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ stack_pointer = reader->Is64Bit() ? thread_info.thread_context.t64.sp
+ : thread_info.thread_context.t32.sp;
#else
#error Port.
#endif
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h b/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
index 110024680bd..dbaf20f459f 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
@@ -422,6 +422,67 @@ static_assert(offsetof(UContext<ContextTraits64>, mcontext.fpregs) ==
"context offset mismatch");
#endif
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+
+struct MContext32 {
+ uint32_t gregs[32];
+ uint64_t fpregs[32];
+ unsigned int fcsr;
+};
+
+struct MContext64 {
+ uint64_t gregs[32];
+ uint64_t fpregs[32];
+ unsigned int fcsr;
+};
+
+struct ContextTraits32 : public Traits32 {
+ using MContext = MContext32;
+ using SignalThreadContext = ThreadContext::t32_t;
+ using SignalFloatContext = FloatContext::f32_t;
+ using CPUContext = CPUContextRISCV;
+};
+
+struct ContextTraits64 : public Traits64 {
+ using MContext = MContext64;
+ using SignalThreadContext = ThreadContext::t64_t;
+ using SignalFloatContext = FloatContext::f64_t;
+ using CPUContext = CPUContextRISCV64;
+};
+
+template <typename Traits>
+struct UContext {
+ typename Traits::ULong flags;
+ typename Traits::Address link;
+ SignalStack<Traits> stack;
+ Sigset<Traits> sigmask;
+ char padding[128 - sizeof(sigmask)];
+ typename Traits::Char_64Only padding2[8];
+ typename Traits::MContext mcontext;
+};
+
+#if defined(ARCH_CPU_RISCV)
+static_assert(offsetof(UContext<ContextTraits32>, mcontext) ==
+ offsetof(ucontext_t, uc_mcontext),
+ "context offset mismatch");
+static_assert(offsetof(UContext<ContextTraits32>, mcontext.gregs) ==
+ offsetof(ucontext_t, uc_mcontext.__gregs),
+ "context offset mismatch");
+static_assert(offsetof(UContext<ContextTraits32>, mcontext.fpregs) ==
+ offsetof(ucontext_t, uc_mcontext.__fpregs),
+ "context offset mismatch");
+#elif defined(ARCH_CPU_RISCV64)
+static_assert(offsetof(UContext<ContextTraits64>, mcontext) ==
+ offsetof(ucontext_t, uc_mcontext),
+ "context offset mismatch");
+static_assert(offsetof(UContext<ContextTraits64>, mcontext.gregs) ==
+ offsetof(ucontext_t, uc_mcontext.__gregs),
+ "context offset mismatch");
+static_assert(offsetof(UContext<ContextTraits64>, mcontext.fpregs) ==
+ offsetof(ucontext_t, uc_mcontext.__fpregs),
+ "context offset mismatch");
+#endif
+
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc b/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
index a99da3e4b6d..8ce47032a1c 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
@@ -204,6 +204,9 @@ CPUArchitecture SystemSnapshotLinux::GetCPUArchitecture() const {
#elif defined(ARCH_CPU_MIPS_FAMILY)
return process_reader_->Is64Bit() ? kCPUArchitectureMIPS64EL
: kCPUArchitectureMIPSEL;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ return process_reader_->Is64Bit() ? kCPUArchitectureRISCV64
+ : kCPUArchitectureRISCV;
#else
#error port to your architecture
#endif
@@ -219,6 +222,9 @@ uint32_t SystemSnapshotLinux::CPURevision() const {
#elif defined(ARCH_CPU_MIPS_FAMILY)
// Not implementable on MIPS
return 0;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ // Not implementable on RISCV
+ return 0;
#else
#error port to your architecture
#endif
@@ -239,6 +245,9 @@ std::string SystemSnapshotLinux::CPUVendor() const {
#elif defined(ARCH_CPU_MIPS_FAMILY)
// Not implementable on MIPS
return std::string();
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ // Not implementable on RISCV
+ return std::string();
#else
#error port to your architecture
#endif
@@ -372,6 +381,9 @@ bool SystemSnapshotLinux::NXEnabled() const {
#elif defined(ARCH_CPU_MIPS_FAMILY)
// Not implementable on MIPS
return false;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ // Not implementable on RISCV
+ return false;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc b/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
index e3e2bebddb9..73a95e3623c 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
@@ -186,6 +186,22 @@ bool ThreadSnapshotLinux::Initialize(ProcessReaderLinux* process_reader,
thread.thread_info.float_context.f32,
context_.mipsel);
}
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ if (process_reader->Is64Bit()) {
+ context_.architecture = kCPUArchitectureRISCV64;
+ context_.riscv64 = &context_union_.riscv64;
+ InitializeCPUContextRISCV<ContextTraits64>(
+ thread.thread_info.thread_context.t64,
+ thread.thread_info.float_context.f64,
+ context_.riscv64);
+ } else {
+ context_.architecture = kCPUArchitectureRISCV;
+ context_.riscv = &context_union_.riscv;
+ InitializeCPUContextRISCV<ContextTraits32>(
+ thread.thread_info.thread_context.t32,
+ thread.thread_info.float_context.f32,
+ context_.riscv);
+ }
#else
#error Port.
#endif
diff --git a/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h b/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
index 44cc6f6d973..6a919f9087e 100644
--- a/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
+++ b/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
@@ -68,6 +68,9 @@ class ThreadSnapshotLinux final : public ThreadSnapshot {
#elif defined(ARCH_CPU_MIPS_FAMILY)
CPUContextMIPS mipsel;
CPUContextMIPS64 mips64;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ CPUContextRISCV riscv;
+ CPUContextRISCV64 riscv64;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
diff --git a/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc b/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc
index 557e0d36357..392e207d05d 100644
--- a/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc
+++ b/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc
@@ -398,6 +398,96 @@ bool GetThreadArea64(pid_t tid,
return true;
}
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+
+template <typename Destination>
+bool GetRegisterSet(pid_t tid, int set, Destination* dest, bool can_log) {
+ iovec iov;
+ iov.iov_base = dest;
+ iov.iov_len = sizeof(*dest);
+ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast<void*>(set), &iov) != 0) {
+ PLOG_IF(ERROR, can_log) << "ptrace";
+ return false;
+ }
+ if (iov.iov_len != sizeof(*dest)) {
+ LOG_IF(ERROR, can_log) << "Unexpected registers size";
+ return false;
+ }
+ return true;
+}
+
+bool GetFloatingPointRegisters32(pid_t tid,
+ FloatContext* context,
+ bool can_log) {
+ return false;
+}
+
+bool GetFloatingPointRegisters64(pid_t tid,
+ FloatContext* context,
+ bool can_log) {
+ return GetRegisterSet(tid, NT_PRFPREG, &context->f64.f, can_log);
+}
+
+bool GetThreadArea32(pid_t tid,
+ const ThreadContext& context,
+ LinuxVMAddress* address,
+ bool can_log) {
+ return false;
+}
+
+bool GetThreadArea64(pid_t tid,
+ const ThreadContext& context,
+ LinuxVMAddress* address,
+ bool can_log) {
+ *address = context.t64.tp;
+ return true;
+}
+
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+
+template <typename Destination>
+bool GetRegisterSet(pid_t tid, int set, Destination* dest, bool can_log) {
+ iovec iov;
+ iov.iov_base = dest;
+ iov.iov_len = sizeof(*dest);
+ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast<void*>(set), &iov) != 0) {
+ PLOG_IF(ERROR, can_log) << "ptrace";
+ return false;
+ }
+ if (iov.iov_len != sizeof(*dest)) {
+ LOG_IF(ERROR, can_log) << "Unexpected registers size";
+ return false;
+ }
+ return true;
+}
+
+bool GetFloatingPointRegisters32(pid_t tid,
+ FloatContext* context,
+ bool can_log) {
+ return false;
+}
+
+bool GetFloatingPointRegisters64(pid_t tid,
+ FloatContext* context,
+ bool can_log) {
+ return GetRegisterSet(tid, NT_PRFPREG, &context->f64.f, can_log);
+}
+
+bool GetThreadArea32(pid_t tid,
+ const ThreadContext& context,
+ LinuxVMAddress* address,
+ bool can_log) {
+ return false;
+}
+
+bool GetThreadArea64(pid_t tid,
+ const ThreadContext& context,
+ LinuxVMAddress* address,
+ bool can_log) {
+ *address = context.t64.tp;
+ return true;
+}
+
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
diff --git a/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h b/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h
index 5b55c24a76d..cfbd684e1ac 100644
--- a/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h
+++ b/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h
@@ -79,6 +79,40 @@ union ThreadContext {
uint32_t cp0_status;
uint32_t cp0_cause;
uint32_t padding1_;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ // Reflects user_regs_struct in asm/ptrace.h.
+ uint32_t pc;
+ uint32_t ra;
+ uint32_t sp;
+ uint32_t gp;
+ uint32_t tp;
+ uint32_t t0;
+ uint32_t t1;
+ uint32_t t2;
+ uint32_t s0;
+ uint32_t s1;
+ uint32_t a0;
+ uint32_t a1;
+ uint32_t a2;
+ uint32_t a3;
+ uint32_t a4;
+ uint32_t a5;
+ uint32_t a6;
+ uint32_t a7;
+ uint32_t s2;
+ uint32_t s3;
+ uint32_t s4;
+ uint32_t s5;
+ uint32_t s6;
+ uint32_t s7;
+ uint32_t s8;
+ uint32_t s9;
+ uint32_t s10;
+ uint32_t s11;
+ uint32_t t3;
+ uint32_t t4;
+ uint32_t t5;
+ uint32_t t6;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -132,6 +166,40 @@ union ThreadContext {
uint64_t cp0_badvaddr;
uint64_t cp0_status;
uint64_t cp0_cause;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ // Reflects user_regs_struct in asm/ptrace.h.
+ uint64_t pc;
+ uint64_t ra;
+ uint64_t sp;
+ uint64_t gp;
+ uint64_t tp;
+ uint64_t t0;
+ uint64_t t1;
+ uint64_t t2;
+ uint64_t s0;
+ uint64_t s1;
+ uint64_t a0;
+ uint64_t a1;
+ uint64_t a2;
+ uint64_t a3;
+ uint64_t a4;
+ uint64_t a5;
+ uint64_t a6;
+ uint64_t a7;
+ uint64_t s2;
+ uint64_t s3;
+ uint64_t s4;
+ uint64_t s5;
+ uint64_t s6;
+ uint64_t s7;
+ uint64_t s8;
+ uint64_t s9;
+ uint64_t s10;
+ uint64_t s11;
+ uint64_t t3;
+ uint64_t t4;
+ uint64_t t5;
+ uint64_t t6;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -143,11 +211,12 @@ union ThreadContext {
using NativeThreadContext = user_regs;
#elif defined(ARCH_CPU_MIPS_FAMILY)
// No appropriate NativeThreadsContext type available for MIPS
+#elif defined(ARCH_CPU_RISCV_FAMILY)
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64
-#if !defined(ARCH_CPU_MIPS_FAMILY)
+#if !defined(ARCH_CPU_MIPS_FAMILY) && !defined(ARCH_CPU_RISCV_FAMILY)
#if defined(ARCH_CPU_32_BITS)
static_assert(sizeof(t32_t) == sizeof(NativeThreadContext), "Size mismatch");
#else // ARCH_CPU_64_BITS
@@ -218,6 +287,9 @@ union FloatContext {
} fpregs[32];
uint32_t fpcsr;
uint32_t fpu_id;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ uint64_t f[32];
+ uint32_t fcsr;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -252,6 +324,9 @@ union FloatContext {
double fpregs[32];
uint32_t fpcsr;
uint32_t fpu_id;
+#elif defined(ARCH_CPU_RISCV_FAMILY)
+ uint64_t f[32];
+ uint32_t fcsr;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -280,6 +355,7 @@ union FloatContext {
static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch");
#elif defined(ARCH_CPU_MIPS_FAMILY)
// No appropriate floating point context native type for available MIPS.
+#elif defined(ARCH_CPU_RISCV_FAMILY)
#else
#error Port.
#endif // ARCH_CPU_X86
--
2.31.1

View file

@ -0,0 +1,566 @@
From 0be3e8523df593423d93f76b60989978a7011e6e Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Wed, 26 Apr 2023 12:24:43 +0800
Subject: [PATCH 6/8] add risc64 breakpad support - chromium
---
.../dump_writer_common/raw_context_cpu.h | 2 +
.../linux/dump_writer_common/thread_info.cc | 28 +++-
.../linux/dump_writer_common/thread_info.h | 2 +-
.../client/linux/handler/exception_handler.cc | 7 +-
.../client/linux/handler/exception_handler.h | 2 +-
.../microdump_writer/microdump_writer.cc | 12 +-
.../minidump_writer/linux_core_dumper.cc | 5 +
.../linux/minidump_writer/linux_dumper.h | 3 +-
.../minidump_writer/linux_ptrace_dumper.cc | 3 +
.../linux/minidump_writer/minidump_writer.cc | 14 +-
.../linux/minidump_writer/minidump_writer.h | 2 +-
.../src/common/linux/breakpad_getcontext.S | 62 +++++++++
.../src/common/linux/memory_mapped_file.cc | 3 +-
.../src/common/linux/ucontext_constants.h | 8 ++
.../common/minidump_cpu_riscv64.h | 121 ++++++++++++++++++
.../google_breakpad/common/minidump_format.h | 2 +
16 files changed, 261 insertions(+), 15 deletions(-)
create mode 100644 chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_riscv64.h
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h b/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h
index 07d9171a0a6..24b7614394f 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h
@@ -44,6 +44,8 @@ typedef MDRawContextARM RawContextCPU;
typedef MDRawContextARM64_Old RawContextCPU;
#elif defined(__mips__)
typedef MDRawContextMIPS RawContextCPU;
+#elif defined(__riscv)
+typedef MDRawContextRISCV64 RawContextCPU;
#else
#error "This code has not been ported to your platform yet."
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc b/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
index aae1dc13b25..bdba3c8380a 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
@@ -270,7 +270,23 @@ void ThreadInfo::FillCPUContext(RawContextCPU* out) const {
out->float_save.fir = mcontext.fpc_eir;
#endif
}
-#endif // __mips__
+#elif defined(__riscv)
+
+uintptr_t ThreadInfo::GetInstructionPointer() const {
+ return mcontext.__gregs[REG_PC];
+}
+
+void ThreadInfo::FillCPUContext(RawContextCPU* out) const {
+ out->context_flags = MD_CONTEXT_RISCV64_FULL;
+
+ my_memcpy (out->iregs, mcontext.__gregs, MD_CONTEXT_RISCV64_GPR_COUNT * 8);
+
+ out->float_save.fcsr = mcontext.__fpregs.__d.__fcsr;
+ my_memcpy(&out->float_save.regs, &mcontext.__fpregs.__d.__f,
+ MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT * 8);
+}
+
+#endif // __riscv
void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) {
assert(gp_regs || size);
@@ -279,6 +295,11 @@ void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) {
*gp_regs = mcontext.gregs;
if (size)
*size = sizeof(mcontext.gregs);
+#elif defined(__riscv)
+ if (gp_regs)
+ *gp_regs = mcontext.__gregs;
+ if (size)
+ *size = sizeof(mcontext.__gregs);
#else
if (gp_regs)
*gp_regs = &regs;
@@ -294,6 +315,11 @@ void ThreadInfo::GetFloatingPointRegisters(void** fp_regs, size_t* size) {
*fp_regs = &mcontext.fpregs;
if (size)
*size = sizeof(mcontext.fpregs);
+#elif defined(__riscv)
+ if (fp_regs)
+ *fp_regs = &mcontext.__fpregs;
+ if (size)
+ *size = sizeof(mcontext.__fpregs);
#else
if (fp_regs)
*fp_regs = &fpregs;
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h b/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h
index fb216fa6d71..65c231b4e65 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h
@@ -68,7 +68,7 @@ struct ThreadInfo {
// Use the structures defined in <sys/user.h>
struct user_regs_struct regs;
struct user_fpsimd_struct fpregs;
-#elif defined(__mips__)
+#elif defined(__mips__) || defined(__riscv)
// Use the structure defined in <sys/ucontext.h>.
mcontext_t mcontext;
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc b/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
index 5cdabcf64c1..a81e370d71c 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
@@ -461,7 +461,7 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) {
memcpy(&g_crash_context_.float_state, fp_ptr,
sizeof(g_crash_context_.float_state));
}
-#elif !defined(__ARM_EABI__) && !defined(__mips__)
+#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
// FP state is not part of user ABI on ARM Linux.
// In case of MIPS Linux FP state is already part of ucontext_t
// and 'float_state' is not a member of CrashContext.
@@ -701,7 +701,7 @@ bool ExceptionHandler::WriteMinidump() {
}
#endif
-#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) && !defined(__riscv)
// FPU state is not part of ARM EABI ucontext_t.
memcpy(&context.float_state, context.context.uc_mcontext.fpregs,
sizeof(context.float_state));
@@ -726,6 +726,9 @@ bool ExceptionHandler::WriteMinidump() {
#elif defined(__mips__)
context.siginfo.si_addr =
reinterpret_cast<void*>(context.context.uc_mcontext.pc);
+#elif defined(__riscv)
+ context.siginfo.si_addr =
+ reinterpret_cast<void*>(context.context.uc_mcontext.__gregs[REG_PC]);
#else
#error "This code has not been ported to your platform yet."
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h b/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h
index f80843ea720..6d2ab07774d 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h
@@ -192,7 +192,7 @@ class ExceptionHandler {
siginfo_t siginfo;
pid_t tid; // the crashing thread.
ucontext_t context;
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
// #ifdef this out because FP state is not part of user ABI for Linux ARM.
// In case of MIPS Linux FP state is already part of ucontext_t so
// 'float_state' is not required.
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc b/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
index fa3c1713a56..d3624ad7dea 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
@@ -138,7 +138,7 @@ class MicrodumpWriter {
const MicrodumpExtraInfo& microdump_extra_info,
LinuxDumper* dumper)
: ucontext_(context ? &context->context : NULL),
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
float_state_(context ? &context->float_state : NULL),
#endif
dumper_(dumper),
@@ -337,6 +337,12 @@ class MicrodumpWriter {
# else
# error "This mips ABI is currently not supported (n32)"
#endif
+#elif defined(__riscv)
+# if __riscv_xlen == 64
+ const char kArch[] = "riscv64";
+# else
+# error "This RISC-V ABI is currently not supported"
+#endif
#else
#error "This code has not been ported to your platform yet"
#endif
@@ -409,7 +415,7 @@ class MicrodumpWriter {
void DumpCPUState() {
RawContextCPU cpu;
my_memset(&cpu, 0, sizeof(RawContextCPU));
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
UContextReader::FillCPUContext(&cpu, ucontext_, float_state_);
#else
UContextReader::FillCPUContext(&cpu, ucontext_);
@@ -605,7 +611,7 @@ class MicrodumpWriter {
void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); }
const ucontext_t* const ucontext_;
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
const google_breakpad::fpstate_t* const float_state_;
#endif
LinuxDumper* dumper_;
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc
index 4150689839a..5833db7eabf 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc
@@ -112,6 +112,9 @@ bool LinuxCoreDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) {
#elif defined(__mips__)
stack_pointer =
reinterpret_cast<uint8_t*>(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]);
+#elif defined(__riscv)
+ stack_pointer =
+ reinterpret_cast<uint8_t*>(info->mcontext.__gregs[MD_CONTEXT_RISCV64_REG_SP]);
#else
#error "This code hasn't been ported to your platform yet."
#endif
@@ -208,6 +211,8 @@ bool LinuxCoreDumper::EnumerateThreads() {
info.mcontext.mdlo = status->pr_reg[EF_LO];
info.mcontext.mdhi = status->pr_reg[EF_HI];
info.mcontext.pc = status->pr_reg[EF_CP0_EPC];
+#elif defined(__riscv)
+ memcpy(info.mcontext.__gregs, status->pr_reg, sizeof(info.mcontext.__gregs));
#else // __mips__
memcpy(&info.regs, status->pr_reg, sizeof(info.regs));
#endif // __mips__
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h
index 7bee160f1ab..df04e2c0706 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h
@@ -63,7 +63,8 @@ namespace google_breakpad {
(defined(__mips__) && _MIPS_SIM == _ABIO32)
typedef Elf32_auxv_t elf_aux_entry;
#elif defined(__x86_64) || defined(__aarch64__) || \
- (defined(__mips__) && _MIPS_SIM != _ABIO32)
+ (defined(__mips__) && _MIPS_SIM != _ABIO32) || \
+ (defined(__riscv) && __riscv_xlen == 64)
typedef Elf64_auxv_t elf_aux_entry;
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
index e3ddb81a659..0295fa3baaf 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
@@ -298,6 +298,9 @@ bool LinuxPtraceDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) {
#elif defined(__mips__)
stack_pointer =
reinterpret_cast<uint8_t*>(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]);
+#elif defined(__riscv)
+ stack_pointer =
+ reinterpret_cast<uint8_t*>(info->mcontext.__gregs[MD_CONTEXT_RISCV64_REG_SP]);
#else
#error "This code hasn't been ported to your platform yet."
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
index 32634ef002a..df367d6e412 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
@@ -136,7 +136,7 @@ class MinidumpWriter {
: fd_(minidump_fd),
path_(minidump_path),
ucontext_(context ? &context->context : NULL),
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
float_state_(context ? &context->float_state : NULL),
#endif
dumper_(dumper),
@@ -468,7 +468,7 @@ class MinidumpWriter {
if (!cpu.Allocate())
return false;
my_memset(cpu.get(), 0, sizeof(RawContextCPU));
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_);
#else
UContextReader::FillCPUContext(cpu.get(), ucontext_);
@@ -897,7 +897,7 @@ class MinidumpWriter {
dirent->location.rva = 0;
}
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || defined(__riscv)
bool WriteCPUInformation(MDRawSystemInfo* sys_info) {
char vendor_id[sizeof(sys_info->cpu.x86_cpu_info.vendor_id) + 1] = {0};
static const char vendor_id_name[] = "vendor_id";
@@ -925,6 +925,12 @@ class MinidumpWriter {
# else
# error "This mips ABI is currently not supported (n32)"
#endif
+#elif defined(__riscv)
+# if __riscv_xlen == 64
+ MD_CPU_ARCHITECTURE_RISCV64;
+# else
+# error "This RISC-V ABI is currently not supported"
+# endif
#elif defined(__i386__)
MD_CPU_ARCHITECTURE_X86;
#else
@@ -1333,7 +1339,7 @@ class MinidumpWriter {
const char* path_; // Path to the file where the minidum should be written.
const ucontext_t* const ucontext_; // also from the signal handler
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
const google_breakpad::fpstate_t* const float_state_; // ditto
#endif
LinuxDumper* dumper_;
diff --git a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h
index e3b0b16daea..0d18c328956 100644
--- a/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h
+++ b/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h
@@ -48,7 +48,7 @@ class ExceptionHandler;
#if defined(__aarch64__)
typedef struct fpsimd_context fpstate_t;
-#elif !defined(__ARM_EABI__) && !defined(__mips__)
+#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv)
typedef std::remove_pointer<fpregset_t>::type fpstate_t;
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S b/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S
index 528dba7a97f..520b317d3f7 100644
--- a/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S
+++ b/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S
@@ -481,6 +481,68 @@ breakpad_getcontext:
.cfi_endproc
.size breakpad_getcontext, . - breakpad_getcontext
+#elif defined(__riscv) && __riscv_xlen == 64
+
+#define __NR_rt_sigprocmask 135
+#define _NSIG8 64 / 8
+#define SIG_BLOCK 0
+
+ .text
+ .global breakpad_getcontext
+ .hidden breakpad_getcontext
+ .type breakpad_getcontext, @function
+ .align 2
+breakpad_getcontext:
+ sd ra, MCONTEXT_GREGS_OFFSET + 0*8(a0)
+ sd ra, MCONTEXT_GREGS_OFFSET + 1*8(a0)
+ sd sp, MCONTEXT_GREGS_OFFSET + 2*8(a0)
+ sd s0, MCONTEXT_GREGS_OFFSET + 8*8(a0)
+ sd s1, MCONTEXT_GREGS_OFFSET + 9*8(a0)
+ sd x0, MCONTEXT_GREGS_OFFSET + 10*8(a0) /* return 0 by overwriting a0. */
+ sd s2, MCONTEXT_GREGS_OFFSET + 18*8(a0)
+ sd s3, MCONTEXT_GREGS_OFFSET + 19*8(a0)
+ sd s4, MCONTEXT_GREGS_OFFSET + 20*8(a0)
+ sd s5, MCONTEXT_GREGS_OFFSET + 21*8(a0)
+ sd s6, MCONTEXT_GREGS_OFFSET + 22*8(a0)
+ sd s7, MCONTEXT_GREGS_OFFSET + 23*8(a0)
+ sd s8, MCONTEXT_GREGS_OFFSET + 24*8(a0)
+ sd s9, MCONTEXT_GREGS_OFFSET + 25*8(a0)
+ sd s10, MCONTEXT_GREGS_OFFSET + 26*8(a0)
+ sd s11, MCONTEXT_GREGS_OFFSET + 27*8(a0)
+
+#ifndef __riscv_float_abi_soft
+ frsr a1
+
+ fsd fs0, MCONTEXT_FPREGS_OFFSET + 8*8(a0)
+ fsd fs1, MCONTEXT_FPREGS_OFFSET + 9*8(a0)
+ fsd fs2, MCONTEXT_FPREGS_OFFSET + 18*8(a0)
+ fsd fs3, MCONTEXT_FPREGS_OFFSET + 19*8(a0)
+ fsd fs4, MCONTEXT_FPREGS_OFFSET + 20*8(a0)
+ fsd fs5, MCONTEXT_FPREGS_OFFSET + 21*8(a0)
+ fsd fs6, MCONTEXT_FPREGS_OFFSET + 22*8(a0)
+ fsd fs7, MCONTEXT_FPREGS_OFFSET + 23*8(a0)
+ fsd fs8, MCONTEXT_FPREGS_OFFSET + 24*8(a0)
+ fsd fs9, MCONTEXT_FPREGS_OFFSET + 25*8(a0)
+ fsd fs10, MCONTEXT_FPREGS_OFFSET + 26*8(a0)
+ fsd fs11, MCONTEXT_FPREGS_OFFSET + 27*8(a0)
+
+ sw a1, MCONTEXT_FSR_OFFSET(a0)
+#endif /* __riscv_float_abi_soft */
+
+/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG / 8) */
+ li a3, _NSIG8
+ add a2, a0, UCONTEXT_SIGMASK_OFFSET
+ mv a1, zero
+ li a0, SIG_BLOCK
+
+ li a7, __NR_rt_sigprocmask
+ scall
+
+ /* Always return 0 for success, even if sigprocmask failed. */
+ mv a0, zero
+ ret
+ .size breakpad_getcontext, . - breakpad_getcontext
+
#else
#error "This file has not been ported for your CPU!"
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc b/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc
index 99362945ca8..a5821de5b2f 100644
--- a/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc
+++ b/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc
@@ -65,7 +65,8 @@ bool MemoryMappedFile::Map(const char* path, size_t offset) {
}
#if defined(__x86_64__) || defined(__aarch64__) || \
- (defined(__mips__) && _MIPS_SIM == _ABI64)
+ (defined(__mips__) && _MIPS_SIM == _ABI64) || \
+ (defined(__riscv) && __riscv_xlen == 64)
struct kernel_stat st;
if (sys_fstat(fd, &st) == -1 || st.st_size < 0) {
diff --git a/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h b/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h
index c390508a1af..0a970e3bbd7 100644
--- a/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h
+++ b/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h
@@ -146,6 +146,14 @@
#endif
#define FPREGS_OFFSET_MXCSR 24
+#elif defined(__riscv)
+
+#define UCONTEXT_SIGMASK_OFFSET 40
+
+#define MCONTEXT_GREGS_OFFSET 176
+#define MCONTEXT_FPREGS_OFFSET 432
+#define MCONTEXT_FSR_OFFSET (MCONTEXT_FPREGS_OFFSET + 32*8)
+
#else
#error "This header has not been ported for your CPU"
#endif
diff --git a/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_riscv64.h b/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_riscv64.h
new file mode 100644
index 00000000000..ff988a67676
--- /dev/null
+++ b/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_riscv64.h
@@ -0,0 +1,121 @@
+/* Copyright 2013 Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
+
+/* minidump_format.h: A cross-platform reimplementation of minidump-related
+ * portions of DbgHelp.h from the Windows Platform SDK.
+ *
+ * (This is C99 source, please don't corrupt it with C++.)
+ *
+ * This file contains the necessary definitions to read minidump files
+ * produced on ARM. These files may be read on any platform provided
+ * that the alignments of these structures on the processing system are
+ * identical to the alignments of these structures on the producing system.
+ * For this reason, precise-sized types are used. The structures defined
+ * by this file have been laid out to minimize alignment problems by
+ * ensuring that all members are aligned on their natural boundaries.
+ * In some cases, tail-padding may be significant when different ABIs specify
+ * different tail-padding behaviors. To avoid problems when reading or
+ * writing affected structures, MD_*_SIZE macros are provided where needed,
+ * containing the useful size of the structures without padding.
+ *
+ * Structures that are defined by Microsoft to contain a zero-length array
+ * are instead defined here to contain an array with one element, as
+ * zero-length arrays are forbidden by standard C and C++. In these cases,
+ * *_minsize constants are provided to be used in place of sizeof. For a
+ * cleaner interface to these sizes when using C++, see minidump_size.h.
+ *
+ * These structures are also sufficient to populate minidump files.
+ *
+ * Because precise data type sizes are crucial for this implementation to
+ * function properly and portably, a set of primitive types with known sizes
+ * are used as the basis of each structure defined by this file.
+ *
+ * Author: Colin Blundell
+ */
+
+/*
+ * RISCV64 support
+ */
+
+#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__
+#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__
+
+#include "google_breakpad/common/breakpad_types.h"
+
+#define MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT 32
+#define MD_CONTEXT_RISCV64_GPR_COUNT 32
+
+typedef struct {
+ /* 32 64-bit floating point registers, f0 .. f31. */
+ uint64_t regs[MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT];
+
+ uint32_t fcsr; /* FPU control and status register */
+} MDFloatingSaveAreaRISCV64;
+
+/* For (MDRawContextRISCV64).context_flags. These values indicate the type of
+ * context stored in the structure. */
+#define MD_CONTEXT_RISCV64 0x00400000
+#define MD_CONTEXT_RISCV64_CONTROL (MD_CONTEXT_RISCV64 | 0x00000001)
+#define MD_CONTEXT_RISCV64_INTEGER (MD_CONTEXT_RISCV64 | 0x00000002)
+#define MD_CONTEXT_RISCV64_FLOATING_POINT (MD_CONTEXT_RISCV64 | 0x00000004)
+#define MD_CONTEXT_RISCV64_DEBUG (MD_CONTEXT_RISCV64 | 0x00000008)
+#define MD_CONTEXT_RISCV64_FULL (MD_CONTEXT_RISCV64_CONTROL | \
+ MD_CONTEXT_RISCV64_INTEGER | \
+ MD_CONTEXT_RISCV64_FLOATING_POINT)
+#define MD_CONTEXT_RISCV64_ALL (MD_CONTEXT_RISCV64_FULL | MD_CONTEXT_RISCV64_DEBUG)
+
+typedef struct {
+ /* Determines which fields of this struct are populated */
+ uint32_t context_flags;
+
+ /* 32 64-bit integer registers, x1 .. x31 + the PC
+ * Note the following fixed uses:
+ * x8 is the frame pointer
+ * x1 is the link register
+ * x2 is the stack pointer
+ * The PC is effectively x0.
+ */
+ uint64_t iregs[MD_CONTEXT_RISCV64_GPR_COUNT];
+
+ /* The next field is included with MD_CONTEXT64_ARM_FLOATING_POINT */
+ MDFloatingSaveAreaRISCV64 float_save;
+
+} MDRawContextRISCV64;
+
+/* Indices into iregs for registers with a dedicated or conventional
+ * purpose.
+ */
+enum MDRISCV64RegisterNumbers {
+ MD_CONTEXT_RISCV64_REG_FP = 8,
+ MD_CONTEXT_RISCV64_REG_RA = 1,
+ MD_CONTEXT_RISCV64_REG_SP = 2,
+ MD_CONTEXT_RISCV64_REG_PC = 0
+};
+
+#endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__ */
diff --git a/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h b/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h
index 7b36d1127da..1013a8916b4 100644
--- a/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h
+++ b/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h
@@ -118,6 +118,7 @@ typedef struct {
#include "minidump_cpu_mips.h"
#include "minidump_cpu_ppc.h"
#include "minidump_cpu_ppc64.h"
+#include "minidump_cpu_riscv64.h"
#include "minidump_cpu_sparc.h"
#include "minidump_cpu_x86.h"
@@ -660,6 +661,7 @@ typedef enum {
MD_CPU_ARCHITECTURE_PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */
MD_CPU_ARCHITECTURE_ARM64_OLD = 0x8003, /* Breakpad-defined value for ARM64 */
MD_CPU_ARCHITECTURE_MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */
+ MD_CPU_ARCHITECTURE_RISCV64 = 0x8005, /* Breakpad-defined value for RISCV64 */
MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */
} MDCPUArchitecture;
--
2.31.1

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,217 @@
From 513a8121a20f691697acc6a2bf4863049a44cd9c Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Thu, 27 Apr 2023 00:48:04 +0800
Subject: [PATCH 8/8] some fixes for external ffmpeg and riscv64 builds
---
chromium/build/config/posix/BUILD.gn | 2 +-
.../build/linux/sysroot_scripts/install-sysroot.py | 3 ++-
chromium/cc/base/list_container_helper.h | 1 +
chromium/media/ffmpeg/ffmpeg_common.h | 1 +
chromium/media/filters/audio_file_reader.cc | 2 +-
chromium/media/filters/ffmpeg_audio_decoder.cc | 2 +-
chromium/media/filters/ffmpeg_demuxer.cc | 12 ++++++------
chromium/media/filters/ffmpeg_glue.cc | 4 ----
chromium/media/filters/ffmpeg_video_decoder.cc | 2 +-
chromium/media/filters/media_file_checker.cc | 2 +-
.../video_coding/codecs/h264/h264_decoder_impl.cc | 2 +-
11 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/chromium/build/config/posix/BUILD.gn b/chromium/build/config/posix/BUILD.gn
index e61554c5656..06f551ad8db 100644
--- a/chromium/build/config/posix/BUILD.gn
+++ b/chromium/build/config/posix/BUILD.gn
@@ -35,7 +35,7 @@ config("runtime_library") {
# changes). Nothing should ever read this define.
sysroot_hash =
exec_script("//build/linux/sysroot_scripts/install-sysroot.py",
- [ "--print-hash=$current_cpu" ],
+ [ "--print-hash=amd64" ],
"trim string",
[ "//build/linux/sysroot_scripts/sysroots.json" ])
defines += [ "CR_SYSROOT_HASH=$sysroot_hash" ]
diff --git a/chromium/build/linux/sysroot_scripts/install-sysroot.py b/chromium/build/linux/sysroot_scripts/install-sysroot.py
index f8b7906cc55..dd458263bba 100755
--- a/chromium/build/linux/sysroot_scripts/install-sysroot.py
+++ b/chromium/build/linux/sysroot_scripts/install-sysroot.py
@@ -41,13 +41,14 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
URL_PREFIX = 'https://commondatastorage.googleapis.com'
URL_PATH = 'chrome-linux-sysroot/toolchain'
-VALID_ARCHS = ('arm', 'arm64', 'i386', 'amd64', 'mips', 'mips64el')
+VALID_ARCHS = ('arm', 'arm64', 'i386', 'amd64', 'mips', 'mips64el', 'riscv64')
ARCH_TRANSLATIONS = {
'x64': 'amd64',
'x86': 'i386',
'mipsel': 'mips',
'mips64': 'mips64el',
+ 'riscv64' : 'riscv64',
}
DEFAULT_TARGET_PLATFORM = 'sid'
diff --git a/chromium/cc/base/list_container_helper.h b/chromium/cc/base/list_container_helper.h
index 9e65013cbdb..8890e66f972 100644
--- a/chromium/cc/base/list_container_helper.h
+++ b/chromium/cc/base/list_container_helper.h
@@ -7,6 +7,7 @@
#include <stddef.h>
+#include <cstring>
#include <memory>
#include <algorithm>
#include <vector>
diff --git a/chromium/media/ffmpeg/ffmpeg_common.h b/chromium/media/ffmpeg/ffmpeg_common.h
index 2734a485cbd..70b1877a43c 100644
--- a/chromium/media/ffmpeg/ffmpeg_common.h
+++ b/chromium/media/ffmpeg/ffmpeg_common.h
@@ -29,6 +29,7 @@ extern "C" {
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavutil/avutil.h>
+#include <libavutil/channel_layout.h>
#include <libavutil/imgutils.h>
#include <libavutil/log.h>
#include <libavutil/mastering_display_metadata.h>
diff --git a/chromium/media/filters/audio_file_reader.cc b/chromium/media/filters/audio_file_reader.cc
index cb81d920def..bd73908d0ca 100644
--- a/chromium/media/filters/audio_file_reader.cc
+++ b/chromium/media/filters/audio_file_reader.cc
@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
}
bool AudioFileReader::OpenDecoder() {
- AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+ const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (codec) {
// MP3 decodes to S16P which we don't support, tell it to use S16 instead.
if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
diff --git a/chromium/media/filters/ffmpeg_audio_decoder.cc b/chromium/media/filters/ffmpeg_audio_decoder.cc
index 0d825ed791b..72fac6167ef 100644
--- a/chromium/media/filters/ffmpeg_audio_decoder.cc
+++ b/chromium/media/filters/ffmpeg_audio_decoder.cc
@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecoder(const AudioDecoderConfig& config) {
}
}
- AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+ const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (!codec ||
avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
DLOG(ERROR) << "Could not initialize audio decoder: "
diff --git a/chromium/media/filters/ffmpeg_demuxer.cc b/chromium/media/filters/ffmpeg_demuxer.cc
index d34db63f3ef..427565b00c1 100644
--- a/chromium/media/filters/ffmpeg_demuxer.cc
+++ b/chromium/media/filters/ffmpeg_demuxer.cc
@@ -98,12 +98,12 @@ static base::TimeDelta ExtractStartTime(AVStream* stream) {
// Next try to use the first DTS value, for codecs where we know PTS == DTS
// (excludes all H26x codecs). The start time must be returned in PTS.
- if (stream->first_dts != kNoFFmpegTimestamp &&
+ if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
const base::TimeDelta first_pts =
- ConvertFromTimeBase(stream->time_base, stream->first_dts);
+ ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
if (first_pts < start_time)
start_time = first_pts;
}
@@ -408,11 +408,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
scoped_refptr<DecoderBuffer> buffer;
if (type() == DemuxerStream::TEXT) {
- int id_size = 0;
+ size_t id_size = 0;
uint8_t* id_data = av_packet_get_side_data(
packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- int settings_size = 0;
+ size_t settings_size = 0;
uint8_t* settings_data = av_packet_get_side_data(
packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
@@ -424,7 +424,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
side_data.data(), side_data.size());
} else {
- int side_data_size = 0;
+ size_t side_data_size = 0;
uint8_t* side_data = av_packet_get_side_data(
packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
@@ -485,7 +485,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
packet->size - data_offset);
}
- int skip_samples_size = 0;
+ size_t skip_samples_size = 0;
const uint32_t* skip_samples_ptr =
reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/chromium/media/filters/ffmpeg_glue.cc b/chromium/media/filters/ffmpeg_glue.cc
index 0ef3521473d..8483ecc348f 100644
--- a/chromium/media/filters/ffmpeg_glue.cc
+++ b/chromium/media/filters/ffmpeg_glue.cc
@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* opaque, int64_t offset, int whence) {
}
void FFmpegGlue::InitializeFFmpeg() {
- av_register_all();
}
static void LogContainer(bool is_local_file,
@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol) {
// Enable fast, but inaccurate seeks for MP3.
format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
- // Ensures we can read out various metadata bits like vp8 alpha.
- format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
-
// Ensures format parsing errors will bail out. From an audit on 11/2017, all
// instances were real failures. Solves bugs like http://crbug.com/710791.
format_context_->error_recognition |= AV_EF_EXPLODE;
diff --git a/chromium/media/filters/ffmpeg_video_decoder.cc b/chromium/media/filters/ffmpeg_video_decoder.cc
index ef12477ee89..7996606f5f9 100644
--- a/chromium/media/filters/ffmpeg_video_decoder.cc
+++ b/chromium/media/filters/ffmpeg_video_decoder.cc
@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config,
if (decode_nalus_)
codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
- AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+ const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
ReleaseFFmpegResources();
return false;
diff --git a/chromium/media/filters/media_file_checker.cc b/chromium/media/filters/media_file_checker.cc
index 59c2a2fc618..1a9872c7acb 100644
--- a/chromium/media/filters/media_file_checker.cc
+++ b/chromium/media/filters/media_file_checker.cc
@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeDelta check_time) {
auto context = AVStreamToAVCodecContext(format_context->streams[i]);
if (!context)
continue;
- AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+ const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
stream_contexts[i] = {std::move(context), std::move(loop)};
diff --git a/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
index 9002b874611..d12fade8b63 100644
--- a/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+++ b/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(const VideoCodec* codec_settings,
// a pointer |this|.
av_context_->opaque = this;
- AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+ const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
if (!codec) {
// This is an indication that FFmpeg has not been initialized or it has not
// been compiled/initialized with the correct set of codecs.
--
2.31.1

View file

@ -0,0 +1,19 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
#SRC_URI:append:riscv64 = "\
# file://0001-add-riscv64-support.patch \
# file://0002-don-t-try-to-link-gn-statically.patch \
# file://0003-add-riscv64-support-chromium.patch;patchdir=src/3rdparty \
# file://0004-add-riscv64-sandbox-support-chromium.patch;patchdir=src/3rdparty \
# file://0005-add-risc64-crashpad-support-chromium.patch;patchdir=src/3rdparty \
# file://0006-add-risc64-breakpad-support-chromium.patch;patchdir=src/3rdparty \
# file://0007-riscv64-add-support-to-chromium-v8.patch;patchdir=src/3rdparty \
# file://0008-some-fixes-for-external-ffmpeg-and-riscv64-builds.patch;patchdir=src/3rdparty \
#"
PACKAGECONFIG:append = " icu ffmpeg harfbuzz opus libwebp libvpx libevent libpng glib zlib pulseaudio"
#due to broken pkgconfig detection in v8/chromium, it searches the host sysroot and not the target sysroot. Ugly hack.
DEPENDS:append:riscv64 = " libwebp-native harfbuzz-native"
COMPATIBLE_MACHINE:riscv64 = "(jh7110)"

View file

@ -0,0 +1 @@
COMPATIBLE_MACHINE:riscv64 = "(jh7110)"

View file

@ -0,0 +1,22 @@
From 3eecf18c4e63e067947981c74f503c16d20bb2ba Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Fri, 28 Apr 2023 11:28:43 +0800
Subject: [PATCH] fix build with gcc 11.3
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 8efebd0..5d740fd 100644
--- a/meson.build
+++ b/meson.build
@@ -134,7 +134,7 @@ add_project_arguments(
'-Werror=format-security',
# NOTE: Can be removed with AppStream 1.0
- '-Wno-error=c++20-compat',
+ #'-Wno-error=c++20-compat',
language: 'cpp'
)

View file

@ -0,0 +1,43 @@
From 6ab00a4279823829a9b82dc9e4d055da4de88c6e Mon Sep 17 00:00:00 2001
From: Markus Volk <f_l_k@t-online.de>
Date: Mon, 12 Dec 2022 15:42:42 +0100
Subject: [PATCH] fix crosscompile
Signed-off-by: Markus Volk <f_l_k@t-online.de>
Upstream-Status: Inappropriate [oe-specific]
---
data/meson.build | 2 +-
meson.build | 2 +-
tools/meson.build | 9 +++++++++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/data/meson.build b/data/meson.build
index aea0cb25..1a085fc9 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -14,7 +14,7 @@ install_data('its/metainfo.loc',
metainfo_with_relinfo = custom_target('gen-output',
input : ['../NEWS', 'org.freedesktop.appstream.cli.metainfo.xml'],
output : ['nol10n_withrelinfo_org.freedesktop.appstream.cli.metainfo.xml'],
- command : [ascli_exe, 'news-to-metainfo', '--limit=6', '@INPUT0@', '@INPUT1@', '@OUTPUT@']
+ command : ['appstreamcli', 'news-to-metainfo', '--limit=6', '@INPUT0@', '@INPUT1@', '@OUTPUT@']
)
metainfo_i18n = i18n.itstool_join(
diff --git a/meson.build b/meson.build
index fd0e3373..2f273ada 100644
--- a/meson.build
+++ b/meson.build
@@ -124,7 +124,7 @@ if get_option ('gir')
dependency('gobject-introspection-1.0', version: '>=1.56')
endif
-stemmer_inc_dirs = include_directories(['/usr/include'])
+stemmer_inc_dirs = include_directories([''])
if get_option('stemming')
stemmer_lib = cc.find_library('stemmer', required: true)
if not cc.has_header('libstemmer.h')
--
2.34.1

View file

@ -0,0 +1,29 @@
From 48777f27be1c2114380c9a15fb6e974dc0623e7e Mon Sep 17 00:00:00 2001
From: Justin Hammond <justin@dynam.ac>
Date: Fri, 28 Apr 2023 14:02:14 +0800
Subject: [PATCH] fix cmake locations
---
qt/cmake/AppStreamQtConfig.cmake.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/qt/cmake/AppStreamQtConfig.cmake.in b/qt/cmake/AppStreamQtConfig.cmake.in
index b64a4f5..edb24c9 100644
--- a/qt/cmake/AppStreamQtConfig.cmake.in
+++ b/qt/cmake/AppStreamQtConfig.cmake.in
@@ -1,5 +1,5 @@
-get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../" ABSOLUTE)
+get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
# Use original install prefix when loaded through a "/usr move"
# cross-prefix symbolic link such as /lib -> /usr/lib.
@@ -32,7 +32,7 @@ add_library(AppStreamQt SHARED IMPORTED)
set_target_properties(AppStreamQt PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/include/"
INTERFACE_LINK_LIBRARIES "Qt5::Core"
- IMPORTED_LOCATION "@LIBDIR_FULL@/libAppStreamQt.so.${AppStreamQt_VERSION}"
+ IMPORTED_LOCATION "${PACKAGE_PREFIX_DIR}/lib/libAppStreamQt.so.${AppStreamQt_VERSION}"
IMPORTED_SONAME "libAppStreamQt.${AppStreamQt_VERSION_MAJOR}"
)

View file

@ -0,0 +1,55 @@
SUMMARY = "AppStream is a collaborative effort for making machine-readable software metadata easily available."
HOMEPAGE = "https://github.com/ximion/appstream"
LICENSE = "LGPL-2.1-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=435ed639f84d4585d93824e7da3d85da"
DEPENDS = " \
appstream-native \
curl-native \
curl \
docbook-xml-dtd4-native \
gperf-native \
glib-2.0 \
libyaml \
libxml2 \
libxmlb \
libxslt-native \
itstool-native \
docbook-xsl-stylesheets-native \
python3-pygments-native \
cmake \
qtbase-native \
"
inherit meson gobject-introspection gettext gtk-doc pkgconfig vala qmake5_base
GIR_MESON_OPTION = ""
SRC_URI = "https://www.freedesktop.org/software/appstream/releases/AppStream-${PV}.tar.xz \
file://0001-fix-build-with-gcc-11.3.patch \
file://0002-fix-cmake-locations.patch \
"
SRC_URI:append:class-target = " file://0001-fix-crosscompile.patch"
SRC_URI[sha256sum] = "77e274e163db1f0a1bec8f4134b1d0f31e9c0a8c54cd37f724a7d30a71cf41d2"
S = "${WORKDIR}/AppStream-${PV}"
PACKAGECONFIG ?= "stemming ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} ${@bb.utils.filter('DISTRO_FEATURES', 'kde', d)}"
#PACKAGECONFIG:append = " qt"
PACKAGECONFIG[systemd] = "-Dsystemd=true,-Dsystemd=false,systemd"
PACKAGECONFIG[stemming] = "-Dstemming=true,-Dstemming=false,libstemmer"
PACKAGECONFIG[kde] = "-Dqt=true,-Dqt=false,qtbase"
FILES:${PN} += "${datadir}"
EXTRA_OEMESON:class-target += "--cross-file=${WORKDIR}/meson-${PN}.cross"
do_write_config:append:class-target() {
cat >${WORKDIR}/meson-${PN}.cross <<EOF
[binaries]
appstreamcli = '${STAGING_BINDIR_NATIVE}/appstreamcli'
EOF
}
BBCLASSEXTEND = "native"

View file

@ -0,0 +1,57 @@
From eacc9e9c62a3857ce1e2e24b81fc22d8ae91f422 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Thu, 9 May 2019 22:06:48 +0200
Subject: [PATCH] Build so-lib
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Stolen from [1]
[1] https://raw.githubusercontent.com/archlinux/svntogit-packages/packages/snowball/trunk/dynamiclib.diff
Upstream-Status: Pending
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
---
GNUmakefile | 7 +++++--
libstemmer/symbol.map | 6 ++++++
2 files changed, 11 insertions(+), 2 deletions(-)
create mode 100644 libstemmer/symbol.map
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -170,12 +170,12 @@ C_OTHER_OBJECTS = $(C_OTHER_SOURCES:.c=.
JAVA_CLASSES = $(JAVA_SOURCES:.java=.class)
JAVA_RUNTIME_CLASSES=$(JAVARUNTIME_SOURCES:.java=.class)
-CFLAGS=-O2 -W -Wall -Wmissing-prototypes -Wmissing-declarations
+CFLAGS=-O2 -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations
CPPFLAGS=
INCLUDES=-Iinclude
-all: snowball$(EXEEXT) libstemmer.a stemwords$(EXEEXT) $(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS)
+all: snowball$(EXEEXT) libstemmer.a libstemmer.so stemwords$(EXEEXT) $(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS)
algorithms.mk: libstemmer/mkalgorithms.pl libstemmer/modules.txt
libstemmer/mkalgorithms.pl algorithms.mk libstemmer/modules.txt
@@ -225,6 +225,9 @@ libstemmer/libstemmer.o: libstemmer/modu
libstemmer.a: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
$(AR) -cru $@ $^
+libstemmer.so: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
+ $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname,libstemmer.so.0,-version-script,libstemmer/symbol.map -o $@.0.0.0 $^
+
examples/%.o: examples/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
--- /dev/null
+++ b/libstemmer/symbol.map
@@ -0,0 +1,6 @@
+SB_STEMMER_0 {
+ global:
+ sb_stemmer_*;
+ local:
+ *;
+};

View file

@ -0,0 +1,37 @@
SUMMARY = "Snowball compiler and stemming algorithms"
HOMEPAGE = "https://snowballstem.org/"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://COPYING;md5=19139aaf3c8c8fa1ca6edd59c072fb9f"
DEPENDS:append:class-target = " ${BPN}-native"
SRC_URI = "git://github.com/snowballstem/snowball.git;branch=master;protocol=https \
file://0001-Build-so-lib.patch \
"
SRCREV = "48a67a2831005f49c48ec29a5837640e23e54e6b"
S = "${WORKDIR}/git"
LIBVER = "0.0.0"
inherit lib_package
do_compile:prepend:class-target() {
# use native tools
sed -i 's:./snowball :snowball :g' ${S}/GNUmakefile
}
do_install() {
install -d ${D}${bindir}
install -m 755 ${S}/snowball ${D}${bindir}
install -m 755 ${S}/stemwords ${D}${bindir}
install -d ${D}${libdir}
install -m 755 ${S}/libstemmer.so.${LIBVER} ${D}${libdir}/
ln -s libstemmer.so.${LIBVER} ${D}${libdir}/libstemmer.so.0
ln -s libstemmer.so.${LIBVER} ${D}${libdir}/libstemmer.so
install -d ${D}${includedir}
install -m 644 ${S}/include/*.h ${D}${includedir}
}
BBCLASSEXTEND = "native"

View file

@ -0,0 +1,138 @@
[Autologin]
# Whether sddm should automatically log back into sessions when they exit
Relogin=false
# Name of session file for autologin session (if empty try last logged in)
Session=
# Username for autologin session
User=
[General]
# Which display server should be used.
# Valid values are: x11, x11-user, wayland.
DisplayServer=wayland
# Comma-separated list of environment variables to be set
GreeterEnvironment=QT_WAYLAND_SHELL_INTEGRATION=layer-shell
# Halt command
HaltCommand=/usr/bin/systemctl poweroff
# Input method module
#InputMethod=qtvirtualkeyboard
# Comma-separated list of Linux namespaces for user session to enter
Namespaces=
# Initial NumLock state. Can be on, off or none.
# If property is set to none, numlock won't be changed
# NOTE: Currently ignored if autologin is enabled.
Numlock=none
# Reboot command
RebootCommand=/usr/bin/systemctl reboot
[Theme]
# Current theme name
Current=
# Cursor size used in the greeter
CursorSize=
# Cursor theme used in the greeter
CursorTheme=
# Number of users to use as threshold
# above which avatars are disabled
# unless explicitly enabled with EnableAvatars
DisableAvatarsThreshold=7
# Enable display of custom user avatars
EnableAvatars=true
# Global directory for user avatars
# The files should be named <username>.face.icon
FacesDir=/usr/share/sddm/faces
# Font used in the greeter
Font=
# Theme directory path
ThemeDir=/usr/share/sddm/themes
[Users]
# Default $PATH for logged in users
DefaultPath=/usr/local/bin:/usr/bin:/bin
# Comma-separated list of shells.
# Users with these shells as their default won't be listed
HideShells=
# Comma-separated list of users that should not be listed
HideUsers=
# Maximum user id for displayed users
MaximumUid=60000
# Minimum user id for displayed users
MinimumUid=1000
# Remember the session of the last successfully logged in user
RememberLastSession=true
# Remember the last successfully logged in user
RememberLastUser=true
# When logging in as the same user twice, restore the original session, rather than create a new one
ReuseSession=true
[Wayland]
# Path of the Wayland compositor to execute when starting the greeter
CompositorCommand=kwin_wayland --no-lockscreen
#CompositorCommand=weston --shell=fullscreen-shell.so --backend=drm-backend.so --drm-device=card1
# Enable Qt's automatic high-DPI scaling
EnableHiDPI=true
# Path to a script to execute when starting the desktop session
SessionCommand=/usr/share/sddm/scripts/wayland-session
# Comma-separated list of directories containing available Wayland sessions
SessionDir=/usr/local/share/wayland-sessions,/usr/share/wayland-sessions
# Path to the user session log file
SessionLogFile=.local/share/sddm/wayland-session.log
[X11]
# Path to a script to execute when starting the display server
DisplayCommand=/usr/share/sddm/scripts/Xsetup
# Path to a script to execute when stopping the display server
DisplayStopCommand=/usr/share/sddm/scripts/Xstop
# Enable Qt's automatic high-DPI scaling
EnableHiDPI=false
# Arguments passed to the X server invocation
ServerArguments=-nolisten tcp
# Path to X server binary
ServerPath=/usr/bin/X
# Path to a script to execute when starting the desktop session
SessionCommand=/usr/share/sddm/scripts/Xsession
# Comma-separated list of directories containing available X sessions
SessionDir=/usr/local/share/xsessions,/usr/share/xsessions
# Path to the user session log file
SessionLogFile=.local/share/sddm/xorg-session.log
# Path to Xephyr binary
XephyrPath=/usr/bin/Xephyr

View file

@ -0,0 +1,13 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI:append:star64 = "\
file://sddm.conf \
"
CONFFILES:${PN} += "${sysconfdir}/sddm.conf"
FILES:${PN} += "${sysconfdir}/sddm.conf"
do_install:append() {
install -m 644 ${WORKDIR}/sddm.conf ${D}/${sysconfdir}/
}