www/qt6-webengine: NEW PORT

The Qt WebEngine module provides a web browser engine that makes it easy
to embed content from the World Wide Web into your Qt application on
platforms that do not have a native web engine.

Qt WebEngine provides C++ classes and QML types for rendering HTML,
XHTML, and SVG documents, styled using Cascading Style Sheets (CSS) and
scripted with JavaScript. HTML documents can be made fully editable by
the user through the use of the contenteditable attribute on HTML
elements.

Most of the patches were taken from Chromium 102.0.5005.115
(6fbdece63f) and a small portion also from Chromium 105.0.5195.102
(96b9a69e70) , which has been required since Qt 6.4.1.

In contrast to www/qt5-webengine, some things have changed in the build
process:

* Python 3.x is used
* CMake maintains the whole build process at the top.
* devel/binutils is no longer required.

At last but not least: Many thanks to madpilot for additional tests and
hints and to tcberner for the moral support during the last mile!

Reviewed by:	madpilot, tcberner (kde)
Approved by:	fluffy (kde)
Differential Revision:	https://reviews.freebsd.org/D37859
This commit is contained in:
Kai Knoblich 2023-01-14 13:10:38 +01:00
parent 885e50f344
commit 3227b809dd
615 changed files with 17005 additions and 5 deletions

View File

@ -24,9 +24,9 @@ qmake_ARGS?= # empty
_COMMON_DISTS= 3d base charts datavis3d declarative imageformats multimedia \
networkauth quick3d quicktimeline remoteobjects scxml sensors \
serialbus serialport svg tools translations virtualkeyboard \
wayland webchannel websockets
wayland webchannel webengine websockets
_QT5_DISTS= connectivity gamepad graphicaleffects location quickcontrols \
quickcontrols2 script speech webengine webglplugin webview \
quickcontrols2 script speech webglplugin webview \
x11extras xmlpatterns
_QT6_DISTS= 5compat doc languageserver lottie positioning shadertools

View File

@ -133,7 +133,7 @@ _QT_MK_POST_INCLUDED= qt.mk
_USE_QT_COMMON= 3d charts datavis3d declarative doc imageformats multimedia \
networkauth quick3d quicktimeline remoteobjects scxml \
sensors serialbus serialport svg virtualkeyboard wayland \
webchannel websockets
webchannel webengine websockets
_USE_QT5_ONLY= assistant buildtools concurrent connectivity core dbus \
declarative-test designer diag examples gamepad \
@ -142,7 +142,7 @@ _USE_QT5_ONLY= assistant buildtools concurrent connectivity core dbus \
qdbus qdbusviewer qdoc qdoc-data qev qmake quickcontrols \
quickcontrols2 script scripttools speech sql sql-mysql sql-odbc \
sql-pgsql sql-sqlite2 sql-sqlite3 sql-tds testlib uiplugin \
uitools webengine webglplugin webkit websockets-qml webview \
uitools webglplugin webkit websockets-qml webview \
widgets x11extras xml xmlpatterns
. if ${ARCH} == amd64 || ${ARCH} == i386
_USE_QT5_ONLY+= sql-ibase
@ -365,7 +365,7 @@ qt-webchannel_PORT= www/${_QT_RELNAME}-webchannel
qt-webchannel_LIB= libQt${_QT_LIBVER}WebChannel.so
qt-webengine_PORT= www/${_QT_RELNAME}-webengine
qt-webengine_LIB= libQt${_QT_LIBVER}WebEngine.so
qt-webengine_LIB= libQt${_QT_LIBVER}WebEngineCore.so
qt-webglplugin_PORT= www/${_QT_RELNAME}-webglplugin
qt-webglplugin_PATH= ${LOCALBASE}/${QT_PLUGINDIR_REL}/platforms/libqwebgl.so

View File

@ -1816,6 +1816,7 @@
SUBDIR += qt5-websockets-qml
SUBDIR += qt5-webview
SUBDIR += qt6-webchannel
SUBDIR += qt6-webengine
SUBDIR += qt6-websockets
SUBDIR += quark
SUBDIR += qutebrowser

142
www/qt6-webengine/Makefile Normal file
View File

@ -0,0 +1,142 @@
# QtWebEngine itself is a very thin layer of Qt code on top of a large part of
# Chromium (everything up to the content/ layer). As such, most of the work in
# this port revolves around taming Chromium and getting it to build on FreeBSD.
# While it does build at the moment, there are several items that should be
# investigated or improved:
# - We are using several stub files, especially in Chromium's base/ and net/
# layers. We should look at implementing the missing bits instead.
# - We are currently not using any sandboxing mechanism.
# - The process of porting QtWebEngine needs to be documented so we can move to
# newer releases more easily.
#
# Also note that, due to the insane amount of patches this port needs, it tends
# to lag behind the rest of the official Qt6 ones, which is why we set
# QT6_VERSION and DISTINFO_FILE here.
PORTNAME= webengine
DISTVERSION= ${QT6_VERSION}
CATEGORIES= www
PKGNAMEPREFIX= qt6-
MAINTAINER= kde@FreeBSD.org
COMMENT= Qt 6 library to render web content
BUILD_DEPENDS= ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat \
${PYTHON_PKGNAMEPREFIX}html5lib>0:www/py-html5lib@${PY_FLAVOR} \
${LOCALBASE}/include/vulkan/vulkan.h:graphics/vulkan-headers
LIB_DEPENDS= libavcodec.so:multimedia/ffmpeg \
libdbus-1.so:devel/dbus \
libevent.so:devel/libevent \
libexpat.so:textproc/expat2 \
libfontconfig.so:x11-fonts/fontconfig \
libfreetype.so:print/freetype2 \
libharfbuzz.so:print/harfbuzz \
liblcms2.so:graphics/lcms2 \
libnspr4.so:devel/nspr \
libnss3.so:security/nss \
libopenh264.so:multimedia/openh264 \
libopus.so:audio/opus \
libpci.so:devel/libpci \
libpng.so:graphics/png \
libre2.so:devel/re2 \
libsnappy.so:archivers/snappy \
libvpx.so:multimedia/libvpx \
libwebp.so:graphics/webp \
libxkbcommon.so:x11/libxkbcommon
USES= bison cmake gl gnome gperf jpeg localbase:ldflags minizip ninja:build \
nodejs:build,lts pkgconfig python:build qt-dist:6,webengine xorg
USE_GL= gl
USE_GNOME= glib20 libxml2 libxslt
USE_QT= base declarative:run positioning quick3d:build webchannel
USE_XORG= x11 xcb xcomposite xcursor xdamage xext xfixes xi xkbfile \
xrandr xrender xscrnsaver xshmfence xtst
CMAKE_ON= QT_FEATURE_webengine_system_ffmpeg QT_FEATURE_webengine_proprietary_codecs
# The build system reads the environment variable $NINJA_PATH to decide whether
# to boostrap ninja or not (and also to invoke it afterwards). CC and CXX are
# read by some Chromium code to determine which compiler to invoke when running
# some configuration tests.
CONFIGURE_ENV+= NINJAFLAGS="-j${MAKE_JOBS_NUMBER}" \
NINJA_PATH="${LOCALBASE}/bin/ninja" \
PATH=${CONFIGURE_WRKSRC}/bin:${LOCALBASE}/bin:${PATH}
MAKE_ENV+= CC="${CC}" CXX="${CXX}" \
C_INCLUDE_PATH=${LOCALBASE}/include \
CPLUS_INCLUDE_PATH=${LOCALBASE}/include \
${CONFIGURE_ENV}
# Avoid running multiple make(1) jobs, but only those. Otherwise the build
# fails intermittently due race conditions if multiple ninja instances are
# running at the same time (mostly for the targets "WebEngineCore" and
# "convert_dict").
#
# MAKE_JOBS_UNSAFE is too invasive because it also affects the number of jobs
# for ninja(1) and would slow everything down which we don't want. We pass the
# real number of make jobs via MAKE_JOBS_NUMBER to ninja(1) to CONFIGURE_ENV.
DO_MAKE_BUILD= ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} -j1 ${MAKE_ARGS:N${DESTDIRNAME}=*}
BINARY_ALIAS= python=${PYTHON_CMD}
# Add extra-patch-no-mempcpy-nasm only when there's no mempcpy() in base.
# Nested variable expansion avoids executing the test when not needed for
# expanding EXTRA_PATCHES.
# mempcpy was introduced in ee37f64cf875255338f917a9da76c643cf59786c
EXTRA_PATCHES+= ${"${:!${GREP} mempcpy ${CROSS_SYSROOT}/usr/include/string.h \
|| ${TRUE}!}" == "":?${PATCHDIR}/extra-patch-no-mempcpy-nasm:}
DISTINFO_FILE= ${.CURDIR}/distinfo
QT6_VERSION= 6.4.2
OPTIONS_DEFAULT= ALSA
OPTIONS_SINGLE= AUDIO
OPTIONS_SINGLE_AUDIO= ALSA PULSEAUDIO SNDIO
AUDIO_DESC= Audio backend
# Need the alsa plugins to get sound at runtime, otherwise messages
# that the pcm_oss plugin can't be opened.
ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib
ALSA_RUN_DEPENDS= alsa-plugins>=0:audio/alsa-plugins
ALSA_CMAKE_ON= -DQT_FEATURE_webengine_system_alsa:BOOL=ON
ALSA_CMAKE_OFF= -DQT_FEATURE_webengine_system_alsa:BOOL=OFF
PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio
PULSEAUDIO_CMAKE_ON= -DQT_FEATURE_webengine_system_pulseaudio:BOOL=ON
PULSEAUDIO_CMAKE_OFF= -DQT_FEATURE_webengine_system_pulseaudio:BOOL=OFF
SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio
SNDIO_CMAKE_ON= -DQT_FEATURE_webengine_system_sndio:BOOL=ON
SNDIO_CMAKE_OFF= -DQT_FEATURE_webengine_system_sndio:BOOL=OFF
.include <bsd.port.pre.mk>
.if ${ARCH} == i386
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-i386-compress_files_js
.endif
post-extract:
@${MKDIR} ${WRKSRC}/src/3rdparty/chromium/media/audio/sndio \
${WRKSRC}/src/3rdparty/chromium/sandbox/policy/freebsd \
${WRKSRC}/src/3rdparty/chromium/sandbox/policy/openbsd
post-patch:
@${REINPLACE_CMD} -e 's|%%DISTVERSION%%|${DISTVERSION}|' \
${WRKSRC}/CMakeLists.txt
@${REINPLACE_CMD} -e 's|%%CPPFLAGS%%|${CPPFLAGS}|;s|%%CXXFLAGS%%|${CXXFLAGS}|;s|%%LDFLAGS%%|${LDFLAGS}|' \
${WRKSRC}/src/host/BUILD.toolchain.gn.in
@${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' \
${WRKSRC}/src/3rdparty/chromium/third_party/pdfium/core/fxge/linux/fx_linux_impl.cpp \
${WRKSRC}/src/3rdparty/chromium/third_party/wayland/features.gni
pre-configure:
# We used to remove bundled libraries to be sure that webengine uses
# system libraries and not shipped ones.
#
# Leads to missing header errors: icu, libvpx, libwebp, re2, snappy, zlib
# No-Op: flac
#
# cd ${WRKSRC} && ${PYTHON_CMD} \
# ./build/linux/unbundle/remove_bundled_libraries.py [list of preserved]
cd ${WRKSRC}/src/3rdparty/chromium && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} \
./build/linux/unbundle/replace_gn_files.py --system-libraries \
fontconfig freetype harfbuzz-ng libdrm libevent libpng libxml libxslt openh264 opus || ${FALSE}
.include <bsd.port.post.mk>

View File

@ -0,0 +1,3 @@
TIMESTAMP = 1673107224
SHA256 (KDE/Qt/6.4.2/qtwebengine-everywhere-src-6.4.2.tar.xz) = ffa945518d1cc8d9ee73523e8d9c2090844f5a2d9c7eac05c4ad079472a119c9
SIZE (KDE/Qt/6.4.2/qtwebengine-everywhere-src-6.4.2.tar.xz) = 440538956

View File

@ -0,0 +1,14 @@
Reduce Brotli compression on i386 to have more memory available. Otherwise,
node.js stops with either SIGSEGV or SIGABRT after ~530 processed files.
--- src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/compress_files.js.orig 2023-01-10 09:16:05 UTC
+++ src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/compress_files.js
@@ -52,7 +52,7 @@ async function brotli(sourceData, compressedFilename)
output.write(Buffer.from(brotliConst));
output.write(Buffer.from(sizeHeader));
return new Promise((resolve, reject) => {
- pipeline(Readable.from(sourceData), zlib.createBrotliCompress(), output, err => {
+ pipeline(Readable.from(sourceData), zlib.createBrotliCompress({ params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }), output, err => {
return err ? reject(err) : resolve();
});
});

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/third_party/nasm/config/config-linux.h.orig 2022-06-08 06:40:31 UTC
+++ src/3rdparty/chromium/third_party/nasm/config/config-linux.h
@@ -336,7 +336,7 @@
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mempcpy' function. */
-#define HAVE_MEMPCPY 1
+/* #undef HAVE_MEMPCPY */
/* Define to 1 if you have a working `mmap' system call. */
#define HAVE_MMAP 1

View File

@ -0,0 +1,15 @@
Set the actual version of www/qt6-webengine, otherwise the version of qt6-base,
which is present in the ports tree, would be assumed and used during
compilation.
--- CMakeLists.txt.orig 2023-01-06 21:06:32 UTC
+++ CMakeLists.txt
@@ -12,7 +12,7 @@ project(QtWebEngine
find_package(Qt6 6.2 CONFIG REQUIRED COMPONENTS BuildInternals Core)
project(QtWebEngine
- VERSION ${Qt6Core_VERSION}
+ VERSION %%DISTVERSION%%
DESCRIPTION "QtWebEngine and QtPdf modules"
HOMEPAGE_URL "https://qt.io/"
LANGUAGES CXX C

View File

@ -0,0 +1,104 @@
--- cmake/Functions.cmake.orig 2022-11-08 21:18:48 UTC
+++ cmake/Functions.cmake
@@ -429,7 +429,7 @@ function(add_linker_options target buildDir completeSt
set(archives_rsp "${buildDir}/${ninjaTarget}_archives.rsp")
set(libs_rsp "${buildDir}/${ninjaTarget}_libs.rsp")
set_target_properties(${cmakeTarget} PROPERTIES STATIC_LIBRARY_OPTIONS "@${objects_rsp}")
- if(LINUX)
+ if(LINUX OR FREEBSD)
get_gn_arch(cpu ${TEST_architecture_arch})
if(CMAKE_CROSSCOMPILING AND cpu STREQUAL "arm" AND ${config} STREQUAL "Debug")
target_link_options(${cmakeTarget} PRIVATE "LINKER:--long-plt")
@@ -667,6 +667,8 @@ function(get_gn_os result)
set(${result} "mac" PARENT_SCOPE)
elseif(IOS)
set(${result} "ios" PARENT_SCOPE)
+ elseif(FREEBSD)
+ set(${result} "freebsd" PARENT_SCOPE)
else()
message(DEBUG "Unrecognized OS")
endif()
@@ -854,7 +856,7 @@ macro(append_build_type_setup)
extend_gn_list(gnArgArg
ARGS enable_precompiled_headers
- CONDITION BUILD_WITH_PCH AND NOT LINUX
+ CONDITION BUILD_WITH_PCH AND NOT (LINUX OR FREEBSD)
)
extend_gn_list(gnArgArg
ARGS dcheck_always_on
@@ -902,7 +904,7 @@ macro(append_compiler_linker_sdk_setup)
use_libcxx=true
)
endif()
- if(DEFINED QT_FEATURE_stdlib_libcpp AND LINUX)
+ if(DEFINED QT_FEATURE_stdlib_libcpp AND (LINUX OR FREEBSD))
extend_gn_list(gnArgArg ARGS use_libcxx
CONDITION QT_FEATURE_stdlib_libcpp
)
@@ -930,7 +932,7 @@ macro(append_compiler_linker_sdk_setup)
)
endif()
get_gn_arch(cpu ${TEST_architecture_arch})
- if(LINUX AND CMAKE_CROSSCOMPILING AND cpu STREQUAL "arm")
+ if((LINUX OR FREEBSD) AND CMAKE_CROSSCOMPILING AND cpu STREQUAL "arm")
extend_gn_list_cflag(gnArgArg
ARG arm_tune
@@ -997,7 +999,7 @@ macro(append_toolchain_setup)
endmacro()
macro(append_toolchain_setup)
- if(LINUX)
+ if(LINUX OR FREEBSD)
list(APPEND gnArgArg
custom_toolchain="${buildDir}/target_toolchain:target"
host_toolchain="${buildDir}/host_toolchain:host"
@@ -1024,7 +1026,7 @@ macro(append_pkg_config_setup)
macro(append_pkg_config_setup)
- if(LINUX)
+ if(LINUX OR FREEBSD)
list(APPEND gnArgArg
pkg_config="${PKG_CONFIG_EXECUTABLE}"
host_pkg_config="${PKG_CONFIG_HOST_EXECUTABLE}"
@@ -1100,6 +1102,20 @@ function(add_gn_build_aritfacts_to_target cmakeTarget
set_target_properties(${cmakeTarget} PROPERTIES
LINK_DEPENDS ${buildDir}/${config}/${arch}/${ninjaTarget}.stamp
)
+ # For some reason when the build of QtWebEngine's "convert_dict" is
+ # completed the "convert_dict.stamp" isn't created.
+ #
+ # Work around this issue by creating "convert_dict.stamp" manually.
+ if(${ninjaTarget} STREQUAL "convert_dict")
+ add_custom_command(
+ POST_BUILD
+ COMMENT "Add workaround for missing ${ninjaTarget}.stamp file after build"
+ COMMAND ${CMAKE_COMMAND} -E touch ${buildDir}/${config}/${arch}/${ninjaTarget}.stamp
+ TARGET ${target}
+ DEPENDS run_${module}_NinjaDone
+ USES_TERMINAL
+ )
+ endif()
if(QT_IS_MACOS_UNIVERSAL)
add_intermediate_archive(${target} ${buildDir}/${config}/${arch} ${completeStatic})
elseif(IOS)
@@ -1222,7 +1238,7 @@ function(check_for_ulimit)
function(check_for_ulimit)
message("-- Checking 'ulimit -n'")
- execute_process(COMMAND bash -c "ulimit -n"
+ execute_process(COMMAND sh -c "ulimit -n"
OUTPUT_VARIABLE ulimitOutput
)
string(REGEX MATCHALL "[0-9]+" limit "${ulimitOutput}")
@@ -1231,7 +1247,7 @@ function(check_for_ulimit)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.21.0")
message(" -- Creating linker launcher")
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/linker_ulimit.sh
- CONTENT "#!/bin/bash\nulimit -n 4096\nexec \"$@\""
+ CONTENT "#!/bin/sh\nulimit -n 4096\nexec \"$@\""
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
)
set(COIN_BUG_699 ON PARENT_SCOPE)

View File

@ -0,0 +1,44 @@
--- configure.cmake.orig 2022-09-26 10:05:50 UTC
+++ configure.cmake
@@ -59,7 +59,7 @@ endif()
endif()
#### Tests
-if(LINUX)
+if(LINUX OR FREEBSD)
check_for_ulimit()
endif()
@@ -403,7 +403,7 @@ qt_feature("webengine-ozone-x11" PRIVATE
qt_feature("webengine-ozone-x11" PRIVATE
LABEL "Support GLX on qpa-xcb"
- CONDITION LINUX
+ CONDITION LINUX OR FREEBSD
AND TARGET Qt::Gui
AND QT_FEATURE_xcb
AND X11_FOUND
@@ -440,12 +440,12 @@ add_check_for_support(
)
add_check_for_support(
MODULES QtWebEngine
- CONDITION LINUX OR (WIN32 AND NOT WIN_ARM_64) OR MACOS
+ CONDITION LINUX OR (WIN32 AND NOT WIN_ARM_64) OR MACOS OR FREEBSD
MESSAGE "Build can be done only on Linux, Windows or macOS."
)
add_check_for_support(
MODULES QtPdf
- CONDITION LINUX OR (WIN32 AND NOT WIN_ARM_64) OR MACOS OR IOS
+ CONDITION LINUX OR (WIN32 AND NOT WIN_ARM_64) OR MACOS OR IOS OR FREEBSD
MESSAGE "Build can be done only on Linux, Windows, macOS or iOS."
)
if(LINUX AND CMAKE_CROSSCOMPILING)
@@ -546,6 +546,8 @@ add_check_for_support(
CONDITION
(LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL GNU) OR
(LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) OR
+ (FREEBSD AND CMAKE_CXX_COMPILER_ID STREQUAL GNU) OR
+ (FREEBSD AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) OR
(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL MSVC) OR
(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND
CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) OR

View File

@ -0,0 +1,56 @@
--- src/3rdparty/chromium/BUILD.gn.orig 2022-11-08 21:18:48 UTC
+++ src/3rdparty/chromium/BUILD.gn
@@ -55,7 +55,7 @@ declare_args() {
qtwebengine_target = "//tools/gn"
}
-if (is_official_build) {
+if (is_official_build && !is_bsd) {
# An official (maximally optimized!) component (optimized for build times)
# build doesn't make sense and usually doesn't work.
assert(!is_component_build)
@@ -451,7 +451,7 @@ group("gn_all") {
]
}
- if (is_linux || is_chromeos || is_android) {
+ if ((is_linux && !is_bsd) || is_chromeos || is_android) {
deps += [
"//third_party/breakpad:breakpad_unittests",
"//third_party/breakpad:core-2-minidump",
@@ -696,7 +696,7 @@ group("gn_all") {
host_os == "win" && !use_qt) {
deps += [ "//chrome/test/mini_installer:mini_installer_tests" ]
}
- } else if (!is_android && !is_ios && !is_fuchsia && !is_win) {
+ } else if (!is_android && !is_ios && !is_fuchsia && !is_win && !is_bsd) {
deps += [ "//third_party/breakpad:symupload($host_toolchain)" ]
}
@@ -1172,7 +1172,7 @@ if (!is_ios && !use_qt) {
data_deps += [ "//content/web_test:web_test_common_mojom_js_data_deps" ]
}
- if (!is_win && !is_android) {
+ if (!is_win && !is_android && !is_bsd) {
data_deps +=
[ "//third_party/breakpad:minidump_stackwalk($host_toolchain)" ]
}
@@ -1181,7 +1181,7 @@ if (!is_ios && !use_qt) {
data_deps += [ "//third_party/breakpad:dump_syms($host_toolchain)" ]
}
- if (is_linux || is_chromeos) {
+ if ((is_linux && !is_bsd) || is_chromeos) {
data_deps += [ "//third_party/breakpad:dump_syms($host_toolchain)" ]
}
@@ -1580,7 +1580,7 @@ group("chromium_builder_perf") {
if (is_win) {
data_deps += [ "//chrome/installer/mini_installer:mini_installer" ]
- } else {
+ } else if (!is_bsd) {
data_deps +=
[ "//third_party/breakpad:minidump_stackwalk($host_toolchain)" ]
}

View File

@ -0,0 +1,148 @@
--- src/3rdparty/chromium/base/BUILD.gn.orig 2022-11-08 21:18:48 UTC
+++ src/3rdparty/chromium/base/BUILD.gn
@@ -1000,7 +1000,7 @@ jumbo_component("base") {
"timer/hi_res_timer_manager_posix.cc",
]
- if (!is_nacl && !is_apple) {
+ if (!is_nacl && !is_apple && !is_bsd) {
sources += [
"cpu_affinity_posix.cc",
"cpu_affinity_posix.h",
@@ -1011,6 +1011,12 @@ jumbo_component("base") {
"profiler/thread_delegate_posix.h",
]
}
+
+ if (is_bsd) {
+ sources += [
+ "profiler/stack_sampler_posix.cc",
+ ]
+ }
}
jumbo_excluded_sources = [
@@ -1360,7 +1366,6 @@ jumbo_component("base") {
"process/process_metrics_linux.cc",
"threading/platform_thread_linux.cc",
]
- jumbo_excluded_sources += [ "process/memory_linux.cc" ]
}
if (is_linux || is_chromeos || is_android || is_fuchsia) {
@@ -1502,6 +1507,18 @@ jumbo_component("base") {
libs += [ "atomic" ]
}
+ # *BSD needs libkvm
+ if (is_bsd) {
+ libs += [ "kvm" ]
+ }
+
+ if (is_freebsd) {
+ libs += [
+ "execinfo",
+ "util",
+ ]
+ }
+
if (use_allocator_shim) {
sources += [
"allocator/allocator_shim.cc",
@@ -1529,7 +1546,7 @@ jumbo_component("base") {
]
configs += [ "//base/allocator:mac_no_default_new_delete_symbols" ]
}
- if (is_chromeos || is_linux) {
+ if (is_chromeos || (is_linux && !is_bsd)) {
sources += [
"allocator/allocator_shim_override_cpp_symbols.h",
"allocator/allocator_shim_override_glibc_weak_symbols.h",
@@ -1585,7 +1602,7 @@ jumbo_component("base") {
# Allow more direct string conversions on platforms with native utf8
# strings
- if (is_apple || is_chromeos || is_chromecast || is_fuchsia) {
+ if (is_apple || is_chromeos || is_chromecast || is_fuchsia || is_bsd) {
defines += [ "SYSTEM_NATIVE_UTF8" ]
}
@@ -2163,6 +2180,42 @@ jumbo_component("base") {
}
}
+ if (is_bsd) {
+ sources -= [
+ "files/file_path_watcher_inotify.cc",
+ "files/file_util_linux.cc",
+ "files/scoped_file_linux.cc",
+ "process/memory_linux.cc",
+ "process/process_linux.cc",
+ "system/sys_info_linux.cc",
+ "process/process_iterator_linux.cc",
+ "process/process_metrics_linux.cc",
+ "process/process_handle_linux.cc"
+ ]
+ sources += [
+ "process/memory_stubs.cc",
+ "files/file_path_watcher_kqueue.cc",
+ "files/file_path_watcher_kqueue.h",
+ "files/file_path_watcher_bsd.cc",
+ ]
+ }
+
+ if (is_openbsd) {
+ sources += [
+ "process/process_handle_openbsd.cc",
+ "process/process_iterator_openbsd.cc",
+ "process/process_metrics_openbsd.cc",
+ "system/sys_info_openbsd.cc",
+ ]
+ } else if (is_freebsd) {
+ sources += [
+ "process/process_handle_freebsd.cc",
+ "process/process_iterator_freebsd.cc",
+ "process/process_metrics_freebsd.cc",
+ "system/sys_info_freebsd.cc",
+ ]
+ }
+
# iOS
if (is_ios) {
sources -= [
@@ -3452,7 +3505,7 @@ test("base_unittests") {
}
}
- if (is_linux || is_chromeos) {
+ if ((is_linux || is_chromeos) && !is_bsd) {
sources += [
"debug/proc_maps_linux_unittest.cc",
"files/scoped_file_linux_unittest.cc",
@@ -3500,7 +3553,7 @@ test("base_unittests") {
"posix/unix_domain_socket_unittest.cc",
"task/thread_pool/task_tracker_posix_unittest.cc",
]
- if (!is_nacl && !is_apple) {
+ if (!is_nacl && !is_apple && !is_bsd) {
sources += [
"cpu_affinity_posix_unittest.cc",
"profiler/stack_copier_signal_unittest.cc",
@@ -3511,7 +3564,7 @@ test("base_unittests") {
# Allow more direct string conversions on platforms with native utf8
# strings
- if (is_apple || is_chromeos || is_chromecast || is_fuchsia) {
+ if (is_apple || is_chromeos || is_chromecast || is_fuchsia || is_bsd) {
defines += [ "SYSTEM_NATIVE_UTF8" ]
}
@@ -3673,7 +3726,7 @@ test("base_unittests") {
}
}
- if (is_fuchsia || is_linux || is_chromeos) {
+ if ((is_fuchsia || is_linux || is_chromeos) && !is_bsd) {
sources += [
"debug/elf_reader_unittest.cc",
"debug/test_elf_image_builder.cc",

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h
@@ -38,7 +38,7 @@ AslrMask(uintptr_t bits) {
#if defined(ARCH_CPU_64_BITS)
- #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
+ #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && !defined(OS_BSD)
// We shouldn't allocate system pages at all for sanitizer builds. However,
// we do, and if random hint addresses interfere with address ranges
@@ -121,7 +121,7 @@ AslrMask(uintptr_t bits) {
return AslrAddress(0x20000000ULL);
}
- #elif BUILDFLAG(IS_LINUX)
+ #elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)
// Linux on arm64 can use 39, 42, 48, or 52-bit user space, depending on
// page size and number of levels of translation pages used. We use

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator.h
@@ -194,7 +194,7 @@ constexpr BASE_EXPORT bool DecommittedMemoryIsAlwaysZe
// Whether decommitted memory is guaranteed to be zeroed when it is
// recommitted. Do not assume that this will not change over time.
constexpr BASE_EXPORT bool DecommittedMemoryIsAlwaysZeroed() {
-#if BUILDFLAG(IS_APPLE)
+#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_BSD)
return false;
#else
return true;

View File

@ -0,0 +1,29 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h
@@ -24,7 +24,7 @@
// elimination.
#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
-#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
+#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64)
// This should work for all POSIX (if needed), but currently all other
// supported OS/architecture combinations use either hard-coded values
// (such as x86) or have means to determine these values without needing
@@ -79,7 +79,7 @@ PageAllocationGranularityShift() {
return 14; // 16kB
#elif BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)
return vm_page_shift;
-#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
+#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64)
// arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16)
// page sizes. Retrieve from or initialize cache.
int shift = page_characteristics.shift.load(std::memory_order_relaxed);
@@ -99,7 +99,7 @@ PageAllocationGranularity() {
// This is literally equivalent to |1 << PageAllocationGranularityShift()|
// below, but was separated out for IS_APPLE to avoid << on a non-constexpr.
return vm_page_size;
-#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
+#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64)
// arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or
// initialize cache.
int size = page_characteristics.size.load(std::memory_order_relaxed);

View File

@ -0,0 +1,16 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_internals_posix.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_internals_posix.h
@@ -352,8 +352,12 @@ void DiscardSystemPagesInternal(uintptr_t address, siz
void DiscardSystemPagesInternal(uintptr_t address, size_t length) {
void* ptr = reinterpret_cast<void*>(address);
-#if BUILDFLAG(IS_APPLE)
+#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_BSD)
+#if BUILDFLAG(IS_BSD)
+ int ret = madvise(ptr, length, MADV_FREE);
+#else
int ret = madvise(ptr, length, MADV_FREE_REUSABLE);
+#endif
if (ret) {
// MADV_FREE_REUSABLE sometimes fails, so fall back to MADV_DONTNEED.
ret = madvise(ptr, length, MADV_DONTNEED);

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc
@@ -184,7 +184,7 @@ void PartitionAddressSpace::UninitConfigurablePoolForT
setup_.configurable_pool_ = 0;
}
-#if BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
+#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64)
PageCharacteristics page_characteristics;

View File

@ -0,0 +1,17 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc.orig 2022-11-06 10:07:10 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc
@@ -63,8 +63,14 @@ void PartitionAllocGlobalInit(OomFunction on_out_of_me
"maximum direct mapped allocation");
// Check that some of our zanier calculations worked out as expected.
+#if defined(__i386__) && defined(OS_FREEBSD)
+ // alignof(std::max_align_t) is only 4 on FreeBSD/i386
+ static_assert(internal::kSmallestBucket >= internal::kAlignment,
+ "generic smallest bucket");
+#else
static_assert(internal::kSmallestBucket == internal::kAlignment,
"generic smallest bucket");
+#endif
static_assert(internal::kMaxBucketed == 917504, "generic max bucketed");
STATIC_ASSERT_OR_PA_CHECK(
internal::MaxSystemPagesPerRegularSlotSpan() <= 16,

View File

@ -0,0 +1,29 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_config.h.orig 2022-11-06 10:11:11 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_config.h
@@ -66,7 +66,7 @@ static_assert(sizeof(void*) != 8, "");
// POSIX is not only UNIX, e.g. macOS and other OSes. We do use Linux-specific
// features such as futex(2).
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
#define PA_HAS_LINUX_KERNEL
#endif
@@ -186,7 +186,7 @@ constexpr bool kUseLazyCommit = false;
// On these platforms, lock all the partitions before fork(), and unlock after.
// This may be required on more platforms in the future.
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
#define PA_HAS_ATFORK_HANDLER
#endif
@@ -225,7 +225,7 @@ constexpr bool kUseLazyCommit = false;
//
// Also enabled on ARM64 macOS, as the 16kiB pages on this platform lead to
// larger slot spans.
-#if BUILDFLAG(IS_LINUX) || (BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64))
+#if BUILDFLAG(IS_LINUX) || (BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)) || BUILDFLAG(IS_BSD)
#define PA_PREFER_SMALLER_SLOT_SPANS
#endif // BUILDFLAG(IS_LINUX)

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h
@@ -80,7 +80,7 @@ PartitionPageShift() {
return 18; // 256 KiB
}
#elif (BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)) || \
- (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64))
+ ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64))
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
PartitionPageShift() {
return PageAllocationGranularityShift() + 2;

View File

@ -0,0 +1,29 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/partition_page.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/partition_page.h
@@ -130,13 +130,14 @@ struct SlotSpanMetadata {
PartitionBucket<thread_safe>* const bucket = nullptr;
// CHECK()ed in AllocNewSlotSpan().
-#if defined(PA_HAS_64_BITS_POINTERS) && BUILDFLAG(IS_APPLE)
+#if (defined(PA_HAS_64_BITS_POINTERS) && BUILDFLAG(IS_APPLE)) || \
+ (BUILDFLAG(IS_FREEBSD) && defined(__i386__))
// System page size is not a constant on Apple OSes, but is either 4 or 16kiB
// (1 << 12 or 1 << 14), as checked in PartitionRoot::Init(). And
// PartitionPageSize() is 4 times the OS page size.
static constexpr size_t kMaxSlotsPerSlotSpan =
4 * (1 << 14) / kSmallestBucket;
-#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
+#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64)
// System page size can be 4, 16, or 64 kiB on Linux on arm64. 64 kiB is
// currently (kMaxSlotsPerSlotSpanBits == 13) not supported by the code,
// so we use the 16 kiB maximum (64 kiB will crash).
@@ -150,7 +151,9 @@ struct SlotSpanMetadata {
#endif // defined(PA_HAS_64_BITS_POINTERS) && BUILDFLAG(IS_APPLE)
// The maximum number of bits needed to cover all currently supported OSes.
static constexpr size_t kMaxSlotsPerSlotSpanBits = 13;
+#if !BUILDFLAG(IS_FREEBSD) && defined(__i386__)
static_assert(kMaxSlotsPerSlotSpan < (1 << kMaxSlotsPerSlotSpanBits), "");
+#endif
// |marked_full| isn't equivalent to being full. Slot span is marked as full
// iff it isn't on the active slot span list (or any other list).

View File

@ -0,0 +1,38 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/partition_root.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/partition_root.cc
@@ -29,7 +29,7 @@
#include "wow64apiset.h"
#endif
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
#include <pthread.h>
#endif
@@ -226,7 +226,7 @@ void PartitionAllocMallocInitOnce() {
if (!g_global_init_called.compare_exchange_strong(expected, true))
return;
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// When fork() is called, only the current thread continues to execute in the
// child process. If the lock is held, but *not* by this thread when fork() is
// called, we have a deadlock.
@@ -305,7 +305,7 @@ static size_t PartitionPurgeSlotSpan(
constexpr size_t kMaxSlotCount =
(PartitionPageSize() * kMaxPartitionPagesPerRegularSlotSpan) /
SystemPageSize();
-#elif BUILDFLAG(IS_APPLE) || (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64))
+#elif BUILDFLAG(IS_APPLE) || ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64))
// It's better for slot_usage to be stack-allocated and fixed-size, which
// demands that its size be constexpr. On IS_APPLE and Linux on arm64,
// PartitionPageSize() is always SystemPageSize() << 2, so regardless of
@@ -648,7 +648,7 @@ void PartitionRoot<thread_safe>::Init(PartitionOptions
// apple OSes.
PA_CHECK((internal::SystemPageSize() == (size_t{1} << 12)) ||
(internal::SystemPageSize() == (size_t{1} << 14)));
-#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
+#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)) && defined(ARCH_CPU_ARM64)
// Check runtime pagesize. Though the code is currently the same, it is
// not merged with the IS_APPLE case above as a 1 << 16 case needs to be
// added here in the future, to allow 64 kiB pagesize. That is only

View File

@ -0,0 +1,47 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/spinning_mutex.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/spinning_mutex.cc
@@ -17,7 +17,15 @@
#if defined(PA_HAS_LINUX_KERNEL)
#include <errno.h>
+#if defined(OS_OPENBSD)
+#include <sys/futex.h>
+#elif defined(OS_FREEBSD)
+#include <sys/types.h>
+#include <sys/thr.h>
+#include <sys/umtx.h>
+#else
#include <linux/futex.h>
+#endif
#include <sys/syscall.h>
#include <unistd.h>
#endif // defined(PA_HAS_LINUX_KERNEL)
@@ -116,8 +124,13 @@ void SpinningMutex::FutexWait() {
// |kLockedContended| anymore. Note that even without spurious wakeups, the
// value of |state_| is not guaranteed when this returns, as another thread
// may get the lock before we get to run.
+#if defined(OS_FREEBSD)
+ int err = _umtx_op(&state_, UMTX_OP_WAIT_UINT_PRIVATE,
+ kLockedContended, nullptr, nullptr);
+#else
int err = syscall(SYS_futex, &state_, FUTEX_WAIT | FUTEX_PRIVATE_FLAG,
kLockedContended, nullptr, nullptr, 0);
+#endif
if (err) {
// These are programming error, check them.
@@ -129,8 +142,14 @@ void SpinningMutex::FutexWake() {
void SpinningMutex::FutexWake() {
int saved_errno = errno;
+#if defined(OS_FREEBSD)
+ long retval = _umtx_op(&state_, UMTX_OP_WAKE_PRIVATE,
+ 1 /* wake up a single waiter */, nullptr, nullptr);
+#else
long retval = syscall(SYS_futex, &state_, FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
1 /* wake up a single waiter */, nullptr, nullptr, 0);
+#endif
+
PA_CHECK(retval != -1);
errno = saved_errno;
}

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/spinning_mutex.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/spinning_mutex.h
@@ -114,7 +114,7 @@ class LOCKABLE BASE_EXPORT SpinningMutex {
#if defined(PA_HAS_FAST_MUTEX)
-#if defined(PA_HAS_LINUX_KERNEL)
+#if defined(PA_HAS_LINUX_KERNEL) || defined(PA_HAS_FREEBSD_KERNEL)
void FutexWait();
void FutexWake();
@@ -166,7 +166,7 @@ inline constexpr SpinningMutex::SpinningMutex() = defa
#if defined(PA_HAS_FAST_MUTEX)
-#if defined(PA_HAS_LINUX_KERNEL)
+#if defined(PA_HAS_LINUX_KERNEL) || defined(PA_HAS_FREEBSD_KERNEL)
ALWAYS_INLINE bool SpinningMutex::Try() {
// Using the weak variant of compare_exchange(), which may fail spuriously. On

View File

@ -0,0 +1,50 @@
--- src/3rdparty/chromium/base/allocator/partition_allocator/starscan/stack/stack.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/allocator/partition_allocator/starscan/stack/stack.cc
@@ -17,6 +17,10 @@
#include <pthread.h>
#endif
+#if defined(OS_BSD)
+#include <pthread_np.h>
+#endif
+
#if defined(LIBC_GLIBC)
extern "C" void* __libc_stack_end;
#endif
@@ -47,6 +51,36 @@ void* GetStackTop() {
void* GetStackTop() {
return pthread_get_stackaddr_np(pthread_self());
+}
+
+#elif defined(OS_OPENBSD)
+
+void* GetStackTop() {
+ stack_t ss;
+ if (pthread_stackseg_np(pthread_self(), &ss) != 0)
+ return nullptr;
+ return reinterpret_cast<uint8_t*>(ss.ss_sp);
+}
+
+#elif defined(OS_FREEBSD)
+
+void* GetStackTop() {
+ pthread_attr_t attr;
+ int error = pthread_attr_init(&attr);
+ if (error) {
+ return nullptr;
+ }
+ error = pthread_attr_get_np(pthread_self(), &attr);
+ if (!error) {
+ void* base;
+ size_t size;
+ error = pthread_attr_getstack(&attr, &base, &size);
+ PA_CHECK(!error);
+ pthread_attr_destroy(&attr);
+ return reinterpret_cast<uint8_t*>(base) + size;
+ }
+ pthread_attr_destroy(&attr);
+ return nullptr;
}
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)

View File

@ -0,0 +1,14 @@
--- src/3rdparty/chromium/base/atomicops.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/atomicops.h
@@ -56,7 +56,11 @@ typedef intptr_t Atomic64;
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
// Atomic64 routines below, depending on your architecture.
+#if !defined(OS_OPENBSD) && defined(__i386__)
+typedef Atomic32 AtomicWord;
+#else
typedef intptr_t AtomicWord;
+#endif
// Atomically execute:
// result = *ptr;

View File

@ -0,0 +1,98 @@
--- src/3rdparty/chromium/base/base_paths_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/base_paths_posix.cc
@@ -15,6 +15,7 @@
#include <ostream>
#include <string>
+#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -25,9 +26,13 @@
#include "base/process/process_metrics.h"
#include "build/build_config.h"
-#if BUILDFLAG(IS_FREEBSD)
+#if BUILDFLAG(IS_BSD)
#include <sys/param.h>
#include <sys/sysctl.h>
+#if BUILDFLAG(IS_OPENBSD)
+#include <kvm.h>
+#define MAXTOKENS 2
+#endif
#elif BUILDFLAG(IS_SOLARIS) || BUILDFLAG(IS_AIX)
#include <stdlib.h>
#endif
@@ -68,13 +73,65 @@ bool PathProviderPosix(int key, FilePath* result) {
*result = FilePath(bin_dir);
return true;
#elif BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_AIX)
- // There is currently no way to get the executable path on OpenBSD
- char* cpath;
- if ((cpath = getenv("CHROME_EXE_PATH")) != NULL)
- *result = FilePath(cpath);
- else
- *result = FilePath("/usr/local/chrome/chrome");
- return true;
+ char *cpath;
+#if !BUILDFLAG(IS_AIX)
+ struct kinfo_file *files;
+ kvm_t *kd = NULL;
+ char errbuf[_POSIX2_LINE_MAX];
+ static char retval[PATH_MAX];
+ int cnt;
+ struct stat sb;
+ pid_t cpid = getpid();
+ bool ret = false;
+
+ const base::CommandLine* command_line =
+ base::CommandLine::ForCurrentProcess();
+
+ VLOG(1) << "PathProviderPosix argv: " << command_line->argv()[0];
+
+ if (realpath(command_line->argv()[0].c_str(), retval) == NULL)
+ goto out;
+
+ if (stat(command_line->argv()[0].c_str(), &sb) < 0)
+ goto out;
+
+ if (!command_line->HasSwitch("no-sandbox")) {
+ ret = true;
+ *result = FilePath(retval);
+ VLOG(1) << "PathProviderPosix (sandbox) result: " << retval;
+ goto out;
+ }
+
+ if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
+ goto out;
+
+ if ((files = kvm_getfiles(kd, KERN_FILE_BYPID, cpid,
+ sizeof(struct kinfo_file), &cnt)) == NULL)
+ goto out;
+
+ for (int i = 0; i < cnt; i++) {
+ if (files[i].fd_fd == KERN_FILE_TEXT &&
+ files[i].va_fsid == static_cast<uint32_t>(sb.st_dev) &&
+ files[i].va_fileid == sb.st_ino) {
+ ret = true;
+ *result = FilePath(retval);
+ VLOG(1) << "PathProviderPosix result: " << retval;
+ }
+ }
+out:
+ if (kd)
+ kvm_close(kd);
+ if (!ret) {
+#endif
+ if ((cpath = getenv("CHROME_EXE_PATH")) != NULL)
+ *result = FilePath(cpath);
+ else
+ *result = FilePath("/usr/local/chrome/chrome");
+ return true;
+#if !BUILDFLAG(IS_AIX)
+ }
+ return ret;
+#endif
#endif
}
case DIR_SRC_TEST_DATA_ROOT: {

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/base_switches.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/base_switches.cc
@@ -170,7 +170,7 @@ const char kForceFieldTrialParams[] = "force-fieldtria
#endif
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// Controls whether or not retired instruction counts are surfaced for threads
// in trace events on Linux.
//

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/base_switches.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/base_switches.h
@@ -60,7 +60,7 @@ extern const char kForceFieldTrialParams[];
extern const char kForceFieldTrialParams[];
#endif
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
extern const char kEnableThreadInstructionCount[];
// TODO(crbug.com/1176772): Remove kEnableCrashpad and IsCrashpadEnabled() when

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/cpu.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/cpu.h
@@ -108,7 +108,7 @@ class BASE_EXPORT CPU final {
const std::string& cpu_brand() const { return cpu_brand_; }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
enum class CoreType {
kUnknown = 0,
kOther,

View File

@ -0,0 +1,68 @@
--- src/3rdparty/chromium/base/debug/debugger_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/debug/debugger_posix.cc
@@ -35,6 +35,10 @@
#include <sys/sysctl.h>
#endif
+#if BUILDFLAG(IS_OPENBSD)
+#include <sys/proc.h>
+#endif
+
#if BUILDFLAG(IS_FREEBSD)
#include <sys/user.h>
#endif
@@ -95,32 +99,51 @@ bool BeingDebugged() {
// Caution: struct kinfo_proc is marked __APPLE_API_UNSTABLE. The source and
// binary interfaces may change.
+#if BUILDFLAG(IS_OPENBSD)
+ struct kinfo_proc *info;
+ size_t info_size;
+#else
struct kinfo_proc info;
size_t info_size = sizeof(info);
+#endif
#if BUILDFLAG(IS_OPENBSD)
if (sysctl(mib, std::size(mib), NULL, &info_size, NULL, 0) < 0)
return -1;
mib[5] = (info_size / sizeof(struct kinfo_proc));
+ if ((info = reinterpret_cast<kinfo_proc*>(malloc(info_size))) == NULL) {
+ is_set = true;
+ being_debugged = false;
+ return being_debugged;
+ }
+
+ int sysctl_result = sysctl(mib, std::size(mib), info, &info_size, NULL, 0);
#endif
+#if !BUILDFLAG(IS_OPENBSD)
int sysctl_result = sysctl(mib, std::size(mib), &info, &info_size, NULL, 0);
+#endif
DCHECK_EQ(sysctl_result, 0);
if (sysctl_result != 0) {
is_set = true;
being_debugged = false;
- return being_debugged;
+ goto out;
}
// This process is being debugged if the P_TRACED flag is set.
is_set = true;
#if BUILDFLAG(IS_FREEBSD)
being_debugged = (info.ki_flag & P_TRACED) != 0;
-#elif BUILDFLAG(IS_BSD)
- being_debugged = (info.p_flag & P_TRACED) != 0;
+#elif BUILDFLAG(IS_OPENBSD)
+ being_debugged = (info->p_psflags & PS_TRACED) != 0;
#else
being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0;
+#endif
+
+out:
+#if BUILDFLAG(IS_OPENBSD)
+ free(info);
#endif
return being_debugged;
}

View File

@ -0,0 +1,18 @@
--- src/3rdparty/chromium/base/debug/elf_reader.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/debug/elf_reader.cc
@@ -76,6 +76,7 @@ size_t ReadElfBuildId(const void* elf_mapped_base,
bool found = false;
while (current_section < section_end) {
current_note = reinterpret_cast<const Nhdr*>(current_section);
+#if !defined(OS_BSD)
if (current_note->n_type == NT_GNU_BUILD_ID) {
StringPiece note_name(current_section + sizeof(Nhdr),
current_note->n_namesz);
@@ -85,6 +86,7 @@ size_t ReadElfBuildId(const void* elf_mapped_base,
break;
}
}
+#endif
size_t section_size = bits::AlignUp(current_note->n_namesz, 4) +
bits::AlignUp(current_note->n_descsz, 4) +

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/debug/proc_maps_linux.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/debug/proc_maps_linux.cc
@@ -13,7 +13,7 @@
#include "base/strings/string_split.h"
#include "build/build_config.h"
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
#include <inttypes.h>
#endif

View File

@ -0,0 +1,38 @@
--- src/3rdparty/chromium/base/debug/stack_trace_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/debug/stack_trace_posix.cc
@@ -38,7 +38,7 @@
#include <AvailabilityMacros.h>
#endif
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
#include "base/debug/proc_maps_linux.h"
#endif
@@ -695,6 +695,9 @@ class SandboxSymbolizeHelper {
// for the modules that are loaded in the current process.
// Returns true on success.
bool CacheMemoryRegions() {
+#if BUILDFLAG(IS_BSD)
+ return false;
+#else
// Reads /proc/self/maps.
std::string contents;
if (!ReadProcMaps(&contents)) {
@@ -712,6 +715,7 @@ class SandboxSymbolizeHelper {
is_initialized_ = true;
return true;
+#endif
}
// Opens all object files and caches their file descriptors.
@@ -868,7 +872,7 @@ size_t CollectStackTrace(void** trace, size_t count) {
// If we do not have unwind tables, then try tracing using frame pointers.
return base::debug::TraceStackFramePointers(const_cast<const void**>(trace),
count, 0);
-#elif !defined(__UCLIBC__) && !defined(_AIX)
+#elif !defined(__UCLIBC__) && !defined(_AIX) && !BUILDFLAG(IS_BSD)
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
return base::saturated_cast<size_t>(backtrace(trace, count));

View File

@ -0,0 +1,57 @@
--- src/3rdparty/chromium/base/files/file_path_watcher_bsd.cc.orig 2022-11-06 10:18:39 UTC
+++ src/3rdparty/chromium/base/files/file_path_watcher_bsd.cc
@@ -0,0 +1,54 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <memory>
+
+#include "base/files/file_path_watcher.h"
+#include "base/files/file_path_watcher_kqueue.h"
+#include "base/memory/ptr_util.h"
+#include "build/build_config.h"
+
+namespace base {
+
+namespace {
+
+class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
+ public:
+ FilePathWatcherImpl() = default;
+ FilePathWatcherImpl(const FilePathWatcherImpl&) = delete;
+ FilePathWatcherImpl& operator=(const FilePathWatcherImpl&) = delete;
+ ~FilePathWatcherImpl() override = default;
+
+ bool Watch(const FilePath& path,
+ Type type,
+ const FilePathWatcher::Callback& callback) override {
+ DCHECK(!impl_.get());
+ if (type == Type::kRecursive) {
+ if (!FilePathWatcher::RecursiveWatchAvailable())
+ return false;
+ } else {
+ impl_ = std::make_unique<FilePathWatcherKQueue>();
+ }
+ DCHECK(impl_.get());
+ return impl_->Watch(path, type, callback);
+ }
+
+ void Cancel() override {
+ if (impl_.get())
+ impl_->Cancel();
+ set_cancelled();
+ }
+
+ private:
+ std::unique_ptr<PlatformDelegate> impl_;
+};
+
+} // namespace
+
+FilePathWatcher::FilePathWatcher() {
+ sequence_checker_.DetachFromSequence();
+ impl_ = std::make_unique<FilePathWatcherImpl>();
+}
+
+} // namespace base

View File

@ -0,0 +1,64 @@
--- src/3rdparty/chromium/base/files/file_path_watcher_freebsd.cc.orig 2022-08-20 09:01:54 UTC
+++ src/3rdparty/chromium/base/files/file_path_watcher_freebsd.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file exists for Unix systems which don't have the inotify headers, and
+// thus cannot build file_watcher_inotify.cc
+
+#include <memory>
+
+#include "base/files/file_path_watcher.h"
+#include "base/files/file_path_watcher_kqueue.h"
+
+#include "base/memory/ptr_util.h"
+#include "build/build_config.h"
+
+namespace base {
+
+namespace {
+
+class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
+ public:
+ FilePathWatcherImpl() = default;
+ FilePathWatcherImpl(const FilePathWatcherImpl&) = delete;
+ FilePathWatcherImpl& operator=(const FilePathWatcherImpl&) = delete;
+ ~FilePathWatcherImpl() override = default;
+
+ bool Watch(const FilePath& path,
+ Type type,
+ const FilePathWatcher::Callback& callback) override {
+ DCHECK(!impl_.get());
+
+ if (type == Type::kRecursive) {
+ return false;
+ } else {
+ impl_ = std::make_unique<FilePathWatcherKQueue>();
+ }
+
+ DCHECK(impl_.get());
+
+ return impl_->Watch(path, type, callback);
+ }
+
+ void Cancel() override {
+ if (impl_.get())
+ impl_->Cancel();
+
+ set_cancelled();
+ }
+
+ private:
+ std::unique_ptr<PlatformDelegate> impl_;
+};
+
+} // namespace
+
+FilePathWatcher::FilePathWatcher() {
+ sequence_checker_.DetachFromSequence();
+ impl_ = std::make_unique<FilePathWatcherImpl>();
+}
+
+} // namespace base

View File

@ -0,0 +1,10 @@
--- src/3rdparty/chromium/base/files/file_path_watcher_kqueue.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/files/file_path_watcher_kqueue.h
@@ -5,6 +5,7 @@
#ifndef BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_
#define BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_
+#include <sys/time.h>
#include <sys/event.h>
#include <memory>

View File

@ -0,0 +1,52 @@
--- src/3rdparty/chromium/base/files/file_util_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/files/file_util_posix.cc
@@ -697,32 +697,34 @@ bool CreateDirectoryAndGetError(const FilePath& full_p
File::Error* error) {
ScopedBlockingCall scoped_blocking_call(
FROM_HERE, BlockingType::MAY_BLOCK); // For call to mkdir().
+ const FilePath kFileSystemRoot("/");
std::vector<FilePath> subpaths;
// Collect a list of all parent directories.
FilePath last_path = full_path;
- subpaths.push_back(full_path);
+ if (full_path != kFileSystemRoot)
+ subpaths.push_back(full_path);
for (FilePath path = full_path.DirName();
- path.value() != last_path.value(); path = path.DirName()) {
+ (path.value() != last_path.value() &&
+ (path != kFileSystemRoot)); path = path.DirName()) {
subpaths.push_back(path);
last_path = path;
}
// Iterate through the parents and create the missing ones.
for (const FilePath& subpath : base::Reversed(subpaths)) {
- if (DirectoryExists(subpath))
- continue;
- if (mkdir(subpath.value().c_str(), 0700) == 0)
- continue;
- // Mkdir failed, but it might have failed with EEXIST, or some other error
- // due to the directory appearing out of thin air. This can occur if
- // two processes are trying to create the same file system tree at the same
- // time. Check to see if it exists and make sure it is a directory.
- int saved_errno = errno;
- if (!DirectoryExists(subpath)) {
- if (error)
- *error = File::OSErrorToFileError(saved_errno);
- return false;
+ if (!PathExists(subpath)) {
+ if ((mkdir(subpath.value().c_str(), 0700) == -1) &&
+ ((full_path != subpath) ? (errno != ENOENT) : (-1))) {
+ int saved_errno = errno;
+ if (error)
+ *error = File::OSErrorToFileError(saved_errno);
+ return false;
+ }
+ } else if (!DirectoryExists(subpath)) {
+ if (error)
+ *error = File::OSErrorToFileError(ENOTDIR);
+ return false;
}
}
return true;

View File

@ -0,0 +1,12 @@
--- src/3rdparty/chromium/base/files/important_file_writer_cleaner.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/files/important_file_writer_cleaner.cc
@@ -25,7 +25,8 @@ base::Time GetUpperBoundTime() {
namespace {
base::Time GetUpperBoundTime() {
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA)
+// needed because of .CreationTime() pledge
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_BSD)
// If process creation time is not available then use instance creation
// time as the upper-bound for old files. Modification times may be
// rounded-down to coarse-grained increments, e.g. FAT has 2s granularity,

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/files/scoped_file.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/files/scoped_file.cc
@@ -31,7 +31,7 @@ void ScopedFDCloseTraits::Free(int fd) {
int ret = IGNORE_EINTR(close(fd));
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_APPLE) || \
- BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_ANDROID)
+ BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
// NB: Some file descriptors can return errors from close() e.g. network
// filesystems such as NFS and Linux input devices. On Linux, macOS, and
// Fuchsia's POSIX layer, errors from close other than EBADF do not indicate

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/i18n/icu_util.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/i18n/icu_util.cc
@@ -52,7 +52,7 @@
#endif
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
- ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
+ ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)) && \
!BUILDFLAG(IS_CHROMECAST))
#include "third_party/icu/source/i18n/unicode/timezone.h"
#endif
@@ -328,7 +328,7 @@ void InitializeIcuTimeZone() {
FuchsiaIntlProfileWatcher::GetPrimaryTimeZoneIdForIcuInitialization();
icu::TimeZone::adoptDefault(
icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(zone_id)));
-#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
+#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)) && \
!BUILDFLAG(IS_CHROMECAST)
// To respond to the time zone change properly, the default time zone
// cache in ICU has to be populated on starting up.

View File

@ -0,0 +1,28 @@
--- src/3rdparty/chromium/base/linux_util.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/linux_util.cc
@@ -15,6 +15,7 @@
#include <iomanip>
#include <memory>
+#include <sstream>
#include "base/base_export.h"
#include "base/files/dir_reader_posix.h"
@@ -135,6 +136,9 @@ bool GetThreadsForProcess(pid_t pid, std::vector<pid_t
}
bool GetThreadsForProcess(pid_t pid, std::vector<pid_t>* tids) {
+#if defined(OS_BSD)
+ return false;
+#else
// 25 > strlen("/proc//task") + strlen(std::to_string(INT_MAX)) + 1 = 22
char buf[25];
strings::SafeSPrintf(buf, "/proc/%d/task", pid);
@@ -154,6 +158,7 @@ bool GetThreadsForProcess(pid_t pid, std::vector<pid_t
}
return true;
+#endif
}
pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data,

View File

@ -0,0 +1,38 @@
--- src/3rdparty/chromium/base/memory/discardable_memory.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/memory/discardable_memory.cc
@@ -25,7 +25,7 @@ const base::Feature kMadvFreeDiscardableMemory{
"MadvFreeDiscardableMemory", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // BUILDFLAG(IS_POSIX)
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
const base::Feature kDiscardableMemoryBackingTrial{
"DiscardableMemoryBackingTrial", base::FEATURE_DISABLED_BY_DEFAULT};
@@ -50,7 +50,7 @@ namespace {
namespace {
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
DiscardableMemoryBacking GetBackingForFieldTrial() {
DiscardableMemoryTrialGroup trial_group =
@@ -69,7 +69,7 @@ DiscardableMemoryBacking GetBackingForFieldTrial() {
} // namespace
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// Probe capabilities of this device to determine whether we should participate
// in the discardable memory backing trial.
@@ -99,7 +99,7 @@ DiscardableMemoryBacking GetDiscardableMemoryBacking()
DiscardableMemory::~DiscardableMemory() = default;
DiscardableMemoryBacking GetDiscardableMemoryBacking() {
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
if (DiscardableMemoryBackingFieldTrialIsEnabled()) {
return GetBackingForFieldTrial();
}

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/memory/discardable_memory_internal.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/memory/discardable_memory_internal.h
@@ -10,7 +10,7 @@
#include "base/metrics/field_trial_params.h"
#include "build/build_config.h"
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
namespace base {

View File

@ -0,0 +1,21 @@
--- src/3rdparty/chromium/base/memory/madv_free_discardable_memory_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/memory/madv_free_discardable_memory_posix.cc
@@ -299,6 +299,10 @@ bool MadvFreeDiscardableMemoryPosix::IsResident() cons
bool MadvFreeDiscardableMemoryPosix::IsResident() const {
DFAKE_SCOPED_RECURSIVE_LOCK(thread_collision_warner_);
+// XXX mincore
+#if BUILDFLAG(IS_BSD)
+ return false;
+#else
#if BUILDFLAG(IS_APPLE)
std::vector<char> vec(allocated_pages_);
#else
@@ -314,6 +318,7 @@ bool MadvFreeDiscardableMemoryPosix::IsResident() cons
return false;
}
return true;
+#endif
}
bool MadvFreeDiscardableMemoryPosix::IsDiscarded() const {

View File

@ -0,0 +1,29 @@
--- src/3rdparty/chromium/base/memory/platform_shared_memory_region.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/memory/platform_shared_memory_region.h
@@ -14,7 +14,7 @@
#include <stdint.h>
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
namespace content {
class SandboxIPCHandler;
}
@@ -81,7 +81,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion {
kMaxValue = GET_SHMEM_TEMP_DIR_FAILURE
};
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// Structure to limit access to executable region creation.
struct ExecutableRegion {
private:
@@ -211,7 +211,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion {
CheckPlatformHandlePermissionsCorrespondToMode);
static PlatformSharedMemoryRegion Create(Mode mode,
size_t size
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
,
bool executable = false
#endif

View File

@ -0,0 +1,29 @@
--- src/3rdparty/chromium/base/memory/platform_shared_memory_region_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/memory/platform_shared_memory_region_posix.cc
@@ -55,7 +55,7 @@ bool CheckFDAccessMode(int fd, int expected_mode) {
} // namespace
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// static
ScopedFD PlatformSharedMemoryRegion::ExecutableRegion::CreateFD(size_t size) {
PlatformSharedMemoryRegion region =
@@ -171,7 +171,7 @@ PlatformSharedMemoryRegion PlatformSharedMemoryRegion:
// static
PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Create(Mode mode,
size_t size
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
,
bool executable
#endif
@@ -200,7 +200,7 @@ PlatformSharedMemoryRegion PlatformSharedMemoryRegion:
// flag.
FilePath directory;
if (!GetShmemTempDir(
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
executable,
#else
false /* executable */,

View File

@ -0,0 +1,28 @@
--- src/3rdparty/chromium/base/message_loop/message_pump_glib.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/message_loop/message_pump_glib.cc
@@ -8,6 +8,11 @@
#include <glib.h>
#include <math.h>
+#if BUILDFLAG(IS_BSD)
+#include <pthread.h>
+#include <pthread_np.h>
+#endif
+
#include "base/logging.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
@@ -50,9 +55,13 @@ bool RunningOnMainThread() {
}
bool RunningOnMainThread() {
+#if BUILDFLAG(IS_BSD)
+ return pthread_main_np();
+#else
auto pid = getpid();
auto tid = PlatformThread::CurrentId();
return pid > 0 && tid > 0 && pid == tid;
+#endif
}
// A brief refresher on GLib:

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/native_library_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/native_library_posix.cc
@@ -33,7 +33,7 @@ NativeLibrary LoadNativeLibraryWithOptions(const FileP
// http://crbug.com/17943, http://crbug.com/17557, http://crbug.com/36892,
// and http://crbug.com/40794.
int flags = RTLD_LAZY;
-#if BUILDFLAG(IS_ANDROID) || !defined(RTLD_DEEPBIND)
+#if BUILDFLAG(IS_ANDROID) || !defined(RTLD_DEEPBIND) || BUILDFLAG(IS_BSD)
// Certain platforms don't define RTLD_DEEPBIND. Android dlopen() requires
// further investigation, as it might vary across versions. Crash here to
// warn developers that they're trying to rely on uncertain behavior.

View File

@ -0,0 +1,16 @@
--- src/3rdparty/chromium/base/posix/can_lower_nice_to.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/posix/can_lower_nice_to.cc
@@ -11,8 +11,12 @@
#include "build/build_config.h"
+#if BUILDFLAG(IS_FREEBSD)
+#include <sys/param.h>
+#endif
+
// Not defined on AIX by default.
-#if BUILDFLAG(IS_AIX)
+#if BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
#if defined(RLIMIT_NICE)
#error Assumption about OS_AIX is incorrect
#endif

View File

@ -0,0 +1,39 @@
--- src/3rdparty/chromium/base/posix/unix_domain_socket.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/posix/unix_domain_socket.cc
@@ -50,7 +50,7 @@ bool UnixDomainSocket::EnableReceiveProcessId(int fd)
// static
bool UnixDomainSocket::EnableReceiveProcessId(int fd) {
-#if !BUILDFLAG(IS_APPLE)
+#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_BSD)
const int enable = 1;
return setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable)) == 0;
#else
@@ -140,7 +140,7 @@ ssize_t UnixDomainSocket::RecvMsgWithFlags(int fd,
const size_t kControlBufferSize =
CMSG_SPACE(sizeof(int) * kMaxFileDescriptors)
-#if !BUILDFLAG(IS_APPLE)
+#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_BSD)
// macOS does not support ucred.
// macOS supports xucred, but this structure is insufficient.
+ CMSG_SPACE(sizeof(struct ucred))
@@ -168,7 +168,7 @@ ssize_t UnixDomainSocket::RecvMsgWithFlags(int fd,
wire_fds = reinterpret_cast<int*>(CMSG_DATA(cmsg));
wire_fds_len = payload_len / sizeof(int);
}
-#if !BUILDFLAG(IS_APPLE)
+#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_BSD)
// macOS does not support SCM_CREDENTIALS.
if (cmsg->cmsg_level == SOL_SOCKET &&
cmsg->cmsg_type == SCM_CREDENTIALS) {
@@ -202,6 +202,9 @@ ssize_t UnixDomainSocket::RecvMsgWithFlags(int fd,
socklen_t pid_size = sizeof(pid);
if (getsockopt(fd, SOL_LOCAL, LOCAL_PEERPID, &pid, &pid_size) != 0)
pid = -1;
+#elif BUILDFLAG(IS_BSD)
+ NOTIMPLEMENTED();
+ pid = -1;
#else
// |pid| will legitimately be -1 if we read EOF, so only DCHECK if we
// actually received a message. Unfortunately, Linux allows sending zero

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/process/kill.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/kill.h
@@ -113,7 +113,7 @@ BASE_EXPORT TerminationStatus GetKnownDeadTerminationS
BASE_EXPORT TerminationStatus GetKnownDeadTerminationStatus(
ProcessHandle handle, int* exit_code);
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// Spawns a thread to wait asynchronously for the child |process| to exit
// and then reaps it.
BASE_EXPORT void EnsureProcessGetsReaped(Process process);

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/process/kill_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/kill_posix.cc
@@ -158,7 +158,7 @@ void EnsureProcessTerminated(Process process) {
0, new BackgroundReaper(std::move(process), Seconds(2)));
}
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
void EnsureProcessGetsReaped(Process process) {
DCHECK(!process.is_current());

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/process/launch.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/launch.h
@@ -199,7 +199,7 @@ struct BASE_EXPORT LaunchOptions {
bool clear_environment = false;
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// If non-zero, start the process using clone(), using flags as provided.
// Unlike in clone, clone_flags may not contain a custom termination signal
// that is sent to the parent when the child dies. The termination signal will

View File

@ -0,0 +1,12 @@
--- src/3rdparty/chromium/base/process/launch_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/launch_posix.cc
@@ -64,6 +64,9 @@
#error "macOS should use launch_mac.cc"
#endif
+#if defined(OS_FREEBSD)
+#pragma weak environ
+#endif
extern char** environ;
namespace base {

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/process/memory.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/memory.cc
@@ -65,14 +65,16 @@ NOINLINE void OnNoMemoryInternal(size_t size) {
} // namespace internal
+#if !BUILDFLAG(IS_BSD)
void TerminateBecauseOutOfMemory(size_t size) {
internal::OnNoMemoryInternal(size);
}
+#endif
// Defined in memory_mac.mm for macOS + use_allocator="none". In case of
// USE_PARTITION_ALLOC_AS_MALLOC, no need to route the call to the system
// default calloc of macOS.
-#if !BUILDFLAG(IS_APPLE) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
+#if (!BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_BSD)) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
const size_t alloc_size = num_items * size;

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/process/process_handle.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_handle.cc
@@ -30,7 +30,7 @@ UniqueProcId GetUniqueIdForProcess() {
: UniqueProcId(GetCurrentProcId());
}
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_AIX)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
void InitUniqueIdForProcessInPidNamespace(ProcessId pid_outside_of_namespace) {
DCHECK(pid_outside_of_namespace != kNullProcessId);

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/process/process_handle.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_handle.h
@@ -106,7 +106,7 @@ BASE_EXPORT UniqueProcId GetUniqueIdForProcess();
// processes may be reused.
BASE_EXPORT UniqueProcId GetUniqueIdForProcess();
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// When a process is started in a different PID namespace from the browser
// process, this function must be called with the process's PID in the browser's
// PID namespace in order to initialize its unique ID. Not thread safe.

View File

@ -0,0 +1,25 @@
--- src/3rdparty/chromium/base/process/process_handle_freebsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_handle_freebsd.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/process/process_handle.h"
+#include "base/files/file_util.h"
#include <limits.h>
#include <stddef.h>
@@ -15,10 +16,13 @@ ProcessId GetParentProcessId(ProcessHandle process) {
ProcessId GetParentProcessId(ProcessHandle process) {
struct kinfo_proc info;
- size_t length;
+ size_t length = sizeof(struct kinfo_proc);
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process };
if (sysctl(mib, std::size(mib), &info, &length, NULL, 0) < 0)
+ return -1;
+
+ if (length < sizeof(struct kinfo_proc))
return -1;
return info.ki_ppid;

View File

@ -0,0 +1,89 @@
--- src/3rdparty/chromium/base/process/process_handle_openbsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_handle_openbsd.cc
@@ -3,8 +3,11 @@
// found in the LICENSE file.
#include "base/process/process_handle.h"
+#include "base/files/file_util.h"
#include <stddef.h>
+#include <sys/param.h>
+#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <unistd.h>
@@ -12,39 +15,59 @@ ProcessId GetParentProcessId(ProcessHandle process) {
namespace base {
ProcessId GetParentProcessId(ProcessHandle process) {
- struct kinfo_proc info;
+ struct kinfo_proc *info;
size_t length;
+ pid_t ppid;
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process,
sizeof(struct kinfo_proc), 0 };
if (sysctl(mib, std::size(mib), NULL, &length, NULL, 0) < 0)
return -1;
+ info = (struct kinfo_proc *)malloc(length);
+
mib[5] = (length / sizeof(struct kinfo_proc));
- if (sysctl(mib, std::size(mib), &info, &length, NULL, 0) < 0)
- return -1;
+ if (sysctl(mib, std::size(mib), info, &length, NULL, 0) < 0) {
+ ppid = -1;
+ goto out;
+ }
- return info.p_ppid;
+ ppid = info->p_ppid;
+
+out:
+ free(info);
+ return ppid;
}
FilePath GetProcessExecutablePath(ProcessHandle process) {
- struct kinfo_proc kp;
- size_t len;
+ struct kinfo_proc *info;
+ size_t length;
+ char *path = NULL;
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process,
sizeof(struct kinfo_proc), 0 };
- if (sysctl(mib, std::size(mib), NULL, &len, NULL, 0) == -1)
+ if (sysctl(mib, std::size(mib), NULL, &length, NULL, 0) == -1)
return FilePath();
- mib[5] = (len / sizeof(struct kinfo_proc));
- if (sysctl(mib, std::size(mib), &kp, &len, NULL, 0) < 0)
- return FilePath();
- if ((kp.p_flag & P_SYSTEM) != 0)
- return FilePath();
- if (strcmp(kp.p_comm, "chrome") == 0)
- return FilePath(kp.p_comm);
- return FilePath();
+ info = (struct kinfo_proc *)malloc(length);
+
+ mib[5] = (length / sizeof(struct kinfo_proc));
+
+ if (sysctl(mib, std::size(mib), info, &length, NULL, 0) < 0)
+ goto out;
+
+ if ((info->p_flag & P_SYSTEM) != 0)
+ goto out;
+
+ if (strcmp(info->p_comm, "chrome") == 0) {
+ path = info->p_comm;
+ goto out;
+ }
+
+out:
+ free(info);
+ return FilePath(path);
}
} // namespace base

View File

@ -0,0 +1,51 @@
--- src/3rdparty/chromium/base/process/process_iterator_freebsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_iterator_freebsd.cc
@@ -20,7 +20,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter*
: index_of_kinfo_proc_(),
filter_(filter) {
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid() };
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) getuid() };
bool done = false;
int try_num = 1;
@@ -39,7 +39,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter*
num_of_kinfo_proc += 16;
kinfo_procs_.resize(num_of_kinfo_proc);
len = num_of_kinfo_proc * sizeof(struct kinfo_proc);
- if (sysctl(mib, std::size(mib), &kinfo_procs_[0], &len, NULL, 0) < 0) {
+ if (sysctl(mib, std::size(mib), kinfo_procs_.data(), &len, NULL, 0) < 0) {
// If we get a mem error, it just means we need a bigger buffer, so
// loop around again. Anything else is a real error and give up.
if (errno != ENOMEM) {
@@ -49,7 +49,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter*
}
} else {
// Got the list, just make sure we're sized exactly right
- size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
+ num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
kinfo_procs_.resize(num_of_kinfo_proc);
done = true;
}
@@ -71,18 +71,13 @@ bool ProcessIterator::CheckForNextProcess() {
for (; index_of_kinfo_proc_ < kinfo_procs_.size(); ++index_of_kinfo_proc_) {
size_t length;
struct kinfo_proc kinfo = kinfo_procs_[index_of_kinfo_proc_];
- int mib[] = { CTL_KERN, KERN_PROC_ARGS, kinfo.ki_pid };
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, kinfo.ki_pid };
if ((kinfo.ki_pid > 0) && (kinfo.ki_stat == SZOMB))
continue;
- length = 0;
- if (sysctl(mib, std::size(mib), NULL, &length, NULL, 0) < 0) {
- LOG(ERROR) << "failed to figure out the buffer size for a command line";
- continue;
- }
-
- data.resize(length);
+ data.resize(ARG_MAX);
+ length = ARG_MAX;
if (sysctl(mib, std::size(mib), &data[0], &length, NULL, 0) < 0) {
LOG(ERROR) << "failed to fetch a commandline";

View File

@ -0,0 +1,45 @@
--- src/3rdparty/chromium/base/process/process_iterator_openbsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_iterator_openbsd.cc
@@ -6,6 +6,9 @@
#include <errno.h>
#include <stddef.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/proc.h>
#include <sys/sysctl.h>
#include "base/logging.h"
@@ -18,12 +21,13 @@ ProcessIterator::ProcessIterator(const ProcessFilter*
: index_of_kinfo_proc_(),
filter_(filter) {
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid(),
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, static_cast<int>(getuid()),
sizeof(struct kinfo_proc), 0 };
bool done = false;
int try_num = 1;
const int max_tries = 10;
+ size_t num_of_kinfo_proc;
do {
size_t len = 0;
@@ -32,7 +36,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter*
kinfo_procs_.resize(0);
done = true;
} else {
- size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
+ num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
// Leave some spare room for process table growth (more could show up
// between when we check and now)
num_of_kinfo_proc += 16;
@@ -48,7 +52,7 @@ ProcessIterator::ProcessIterator(const ProcessFilter*
}
} else {
// Got the list, just make sure we're sized exactly right
- size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
+ num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
kinfo_procs_.resize(num_of_kinfo_proc);
done = true;
}

View File

@ -0,0 +1,47 @@
--- src/3rdparty/chromium/base/process/process_metrics.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_metrics.cc
@@ -18,7 +18,7 @@ namespace {
namespace {
#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
int CalculateEventsPerSecond(uint64_t event_count,
uint64_t* last_event_count,
base::TimeTicks* last_calculated) {
@@ -55,7 +55,7 @@ SystemMetrics SystemMetrics::Sample() {
SystemMetrics system_metrics;
system_metrics.committed_memory_ = GetSystemCommitCharge();
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
GetSystemMemoryInfo(&system_metrics.memory_info_);
GetVmStatInfo(&system_metrics.vmstat_info_);
GetSystemDiskInfo(&system_metrics.disk_info_);
@@ -74,7 +74,7 @@ Value SystemMetrics::ToValue() const {
Value res(Value::Type::DICTIONARY);
res.SetIntKey("committed_memory", static_cast<int>(committed_memory_));
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
Value meminfo = memory_info_.ToValue();
Value vmstat = vmstat_info_.ToValue();
meminfo.MergeDictionary(&vmstat);
@@ -100,7 +100,7 @@ std::unique_ptr<ProcessMetrics> ProcessMetrics::Create
#endif // !BUILDFLAG(IS_MAC)
}
-#if !BUILDFLAG(IS_FREEBSD) || !BUILDFLAG(IS_POSIX)
+#if !BUILDFLAG(IS_BSD) || !BUILDFLAG(IS_POSIX)
double ProcessMetrics::GetPlatformIndependentCPUUsage() {
TimeDelta cumulative_cpu = GetCumulativeCPUUsage();
TimeTicks time = TimeTicks::Now();
@@ -151,7 +151,7 @@ double ProcessMetrics::GetPreciseCPUUsage() {
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
int ProcessMetrics::CalculateIdleWakeupsPerSecond(
uint64_t absolute_idle_wakeups) {
return CalculateEventsPerSecond(absolute_idle_wakeups,

View File

@ -0,0 +1,119 @@
--- src/3rdparty/chromium/base/process/process_metrics.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_metrics.h
@@ -36,7 +36,7 @@
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
#include <string>
#include <utility>
#include <vector>
@@ -52,7 +52,7 @@ struct IoCounters;
// Full declaration is in process_metrics_iocounters.h.
struct IoCounters;
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
// Minor and major page fault counts since the process creation.
// Both counts are process-wide, and exclude child processes.
//
@@ -107,7 +107,7 @@ class BASE_EXPORT ProcessMetrics {
// convenience wrapper for CreateProcessMetrics().
static std::unique_ptr<ProcessMetrics> CreateCurrentProcessMetrics();
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
// Resident Set Size is a Linux/Android specific memory concept. Do not
// attempt to extend this to other platforms.
BASE_EXPORT size_t GetResidentSetSize() const;
@@ -155,7 +155,7 @@ class BASE_EXPORT ProcessMetrics {
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
// Emits the cumulative CPU usage for all currently active threads since they
// were started into the output parameter (replacing its current contents).
// Threads that have already terminated will not be reported. Thus, the sum of
@@ -238,7 +238,7 @@ class BASE_EXPORT ProcessMetrics {
int GetOpenFdSoftLimit() const;
#endif // BUILDFLAG(IS_POSIX)
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
// Bytes of swap as reported by /proc/[pid]/status.
uint64_t GetVmSwapBytes() const;
@@ -259,7 +259,7 @@ class BASE_EXPORT ProcessMetrics {
#endif // !BUILDFLAG(IS_MAC)
#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
int CalculateIdleWakeupsPerSecond(uint64_t absolute_idle_wakeups);
#endif
#if BUILDFLAG(IS_APPLE)
@@ -270,7 +270,7 @@ class BASE_EXPORT ProcessMetrics {
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
CPU::CoreType GetCoreType(int core_index);
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
// BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_AIX)
@@ -294,7 +294,7 @@ class BASE_EXPORT ProcessMetrics {
#endif
#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
// Same thing for idle wakeups.
TimeTicks last_idle_wakeups_time_;
uint64_t last_absolute_idle_wakeups_;
@@ -337,7 +337,7 @@ BASE_EXPORT void IncreaseFdLimitTo(unsigned int max_de
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_LINUX) || \
BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_AIX) || \
- BUILDFLAG(IS_FUCHSIA)
+ BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_BSD)
// Data about system-wide memory consumption. Values are in KB. Available on
// Windows, Mac, Linux, Android and Chrome OS.
//
@@ -372,7 +372,7 @@ struct BASE_EXPORT SystemMemoryInfoKB {
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
// This provides an estimate of available memory as described here:
// https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
// NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always
@@ -387,7 +387,7 @@ struct BASE_EXPORT SystemMemoryInfoKB {
#endif
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
- BUILDFLAG(IS_AIX) || BUILDFLAG(IS_FUCHSIA)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_BSD)
int buffers = 0;
int cached = 0;
int active_anon = 0;
@@ -424,7 +424,7 @@ BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoK
// BUILDFLAG(IS_FUCHSIA)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
// Parse the data found in /proc/<pid>/stat and return the sum of the
// CPU-related ticks. Returns -1 on parse error.
// Exposed for testing.
@@ -611,7 +611,7 @@ class BASE_EXPORT SystemMetrics {
FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics);
size_t committed_memory_;
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)
SystemMemoryInfoKB memory_info_;
VmStatInfo vmstat_info_;
SystemDiskInfo disk_info_;

View File

@ -0,0 +1,290 @@
--- src/3rdparty/chromium/base/process/process_metrics_freebsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_metrics_freebsd.cc
@@ -3,20 +3,39 @@
// found in the LICENSE file.
#include "base/process/process_metrics.h"
+#include "base/notreached.h"
#include <stddef.h>
+#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <unistd.h>
+#include <fcntl.h> /* O_RDONLY */
+#include <kvm.h>
+#include <libutil.h>
+
#include "base/memory/ptr_util.h"
#include "base/process/process_metrics_iocounters.h"
+#include "base/values.h"
namespace base {
+namespace {
+int GetPageShift() {
+ int pagesize = getpagesize();
+ int pageshift = 0;
+ while (pagesize > 1) {
+ pageshift++;
+ pagesize >>= 1;
+ }
+
+ return pageshift;
+}
+}
+
ProcessMetrics::ProcessMetrics(ProcessHandle process)
- : process_(process),
- last_cpu_(0) {}
+ : process_(process) {}
// static
std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics(
@@ -26,17 +45,18 @@ double ProcessMetrics::GetPlatformIndependentCPUUsage(
double ProcessMetrics::GetPlatformIndependentCPUUsage() {
struct kinfo_proc info;
- int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, process_};
- size_t length = sizeof(info);
+ size_t length = sizeof(struct kinfo_proc);
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process_ };
+
if (sysctl(mib, std::size(mib), &info, &length, NULL, 0) < 0)
- return 0;
+ return 0.0;
- return (info.ki_pctcpu / FSCALE) * 100.0;
+ return static_cast<double>((info.ki_pctcpu * 100.0) / FSCALE);
}
TimeDelta ProcessMetrics::GetCumulativeCPUUsage() {
- NOTREACHED();
+ NOTIMPLEMENTED();
return TimeDelta();
}
@@ -67,4 +87,221 @@ size_t GetSystemCommitCharge() {
return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize);
}
+int GetNumberOfThreads(ProcessHandle process) {
+ // Taken from FreeBSD top (usr.bin/top/machine.c)
+
+ kvm_t* kd = kvm_open(NULL, "/dev/null", NULL, O_RDONLY, "kvm_open");
+ if (kd == NULL)
+ return 0;
+
+ struct kinfo_proc* pbase;
+ int nproc;
+ pbase = kvm_getprocs(kd, KERN_PROC_PID, process, &nproc);
+ if (pbase == NULL)
+ return 0;
+
+ if (kvm_close(kd) == -1)
+ return 0;
+
+ return nproc;
+}
+
+bool GetSystemMemoryInfo(SystemMemoryInfoKB *meminfo) {
+ unsigned int mem_total, mem_free, swap_total, swap_used;
+ size_t length;
+ int pagesizeKB;
+
+ pagesizeKB = getpagesize() / 1024;
+
+ length = sizeof(mem_total);
+ if (sysctlbyname("vm.stats.vm.v_page_count", &mem_total,
+ &length, NULL, 0) != 0 || length != sizeof(mem_total))
+ return false;
+
+ length = sizeof(mem_free);
+ if (sysctlbyname("vm.stats.vm.v_free_count", &mem_free, &length, NULL, 0)
+ != 0 || length != sizeof(mem_free))
+ return false;
+
+ length = sizeof(swap_total);
+ if (sysctlbyname("vm.swap_size", &swap_total, &length, NULL, 0)
+ != 0 || length != sizeof(swap_total))
+ return false;
+
+ length = sizeof(swap_used);
+ if (sysctlbyname("vm.swap_anon_use", &swap_used, &length, NULL, 0)
+ != 0 || length != sizeof(swap_used))
+ return false;
+
+ meminfo->total = mem_total * pagesizeKB;
+ meminfo->free = mem_free * pagesizeKB;
+ meminfo->swap_total = swap_total * pagesizeKB;
+ meminfo->swap_free = (swap_total - swap_used) * pagesizeKB;
+
+ return true;
+}
+
+int ProcessMetrics::GetOpenFdCount() const {
+ struct kinfo_file * kif;
+ int cnt;
+
+ if ((kif = kinfo_getfile(process_, &cnt)) == NULL)
+ return -1;
+
+ free(kif);
+
+ return cnt;
+}
+
+int ProcessMetrics::GetOpenFdSoftLimit() const {
+ size_t length;
+ int total_count = 0;
+ int mib[] = { CTL_KERN, KERN_MAXFILESPERPROC };
+
+ length = sizeof(total_count);
+
+ if (sysctl(mib, std::size(mib), &total_count, &length, NULL, 0) < 0) {
+ total_count = -1;
+ }
+
+ return total_count;
+}
+
+size_t ProcessMetrics::GetResidentSetSize() const {
+ kvm_t *kd = kvm_open(nullptr, "/dev/null", nullptr, O_RDONLY, "kvm_open");
+
+ if (kd == nullptr)
+ return 0;
+
+ struct kinfo_proc *pp;
+ int nproc;
+
+ if ((pp = kvm_getprocs(kd, KERN_PROC_PID, process_, &nproc)) == nullptr) {
+ kvm_close(kd);
+ return 0;
+ }
+
+ size_t rss;
+
+ if (nproc > 0) {
+ rss = pp->ki_rssize << GetPageShift();
+ } else {
+ rss = 0;
+ }
+
+ kvm_close(kd);
+ return rss;
+}
+
+uint64_t ProcessMetrics::GetVmSwapBytes() const {
+ kvm_t *kd = kvm_open(nullptr, "/dev/null", nullptr, O_RDONLY, "kvm_open");
+
+ if (kd == nullptr)
+ return 0;
+
+ struct kinfo_proc *pp;
+ int nproc;
+
+ if ((pp = kvm_getprocs(kd, KERN_PROC_PID, process_, &nproc)) == nullptr) {
+ kvm_close(kd);
+ return 0;
+ }
+
+ size_t swrss;
+
+ if (nproc > 0) {
+ swrss = pp->ki_swrss > pp->ki_rssize
+ ? (pp->ki_swrss - pp->ki_rssize) << GetPageShift()
+ : 0;
+ } else {
+ swrss = 0;
+ }
+
+ kvm_close(kd);
+ return swrss;
+}
+
+int ProcessMetrics::GetIdleWakeupsPerSecond() {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+bool GetSystemDiskInfo(SystemDiskInfo* diskinfo) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool GetVmStatInfo(VmStatInfo* vmstat) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+SystemDiskInfo::SystemDiskInfo() {
+ reads = 0;
+ reads_merged = 0;
+ sectors_read = 0;
+ read_time = 0;
+ writes = 0;
+ writes_merged = 0;
+ sectors_written = 0;
+ write_time = 0;
+ io = 0;
+ io_time = 0;
+ weighted_io_time = 0;
+}
+
+SystemDiskInfo::SystemDiskInfo(const SystemDiskInfo& other) = default;
+
+SystemDiskInfo& SystemDiskInfo::operator=(const SystemDiskInfo&) = default;
+
+Value SystemDiskInfo::ToValue() const {
+ Value res(Value::Type::DICTIONARY);
+
+ // Write out uint64_t variables as doubles.
+ // Note: this may discard some precision, but for JS there's no other option.
+ res.SetDoubleKey("reads", static_cast<double>(reads));
+ res.SetDoubleKey("reads_merged", static_cast<double>(reads_merged));
+ res.SetDoubleKey("sectors_read", static_cast<double>(sectors_read));
+ res.SetDoubleKey("read_time", static_cast<double>(read_time));
+ res.SetDoubleKey("writes", static_cast<double>(writes));
+ res.SetDoubleKey("writes_merged", static_cast<double>(writes_merged));
+ res.SetDoubleKey("sectors_written", static_cast<double>(sectors_written));
+ res.SetDoubleKey("write_time", static_cast<double>(write_time));
+ res.SetDoubleKey("io", static_cast<double>(io));
+ res.SetDoubleKey("io_time", static_cast<double>(io_time));
+ res.SetDoubleKey("weighted_io_time", static_cast<double>(weighted_io_time));
+
+ return res;
+}
+
+Value SystemMemoryInfoKB::ToValue() const {
+ Value res(Value::Type::DICTIONARY);
+
+ res.SetIntKey("total", total);
+ res.SetIntKey("free", free);
+ res.SetIntKey("available", available);
+ res.SetIntKey("buffers", buffers);
+ res.SetIntKey("cached", cached);
+ res.SetIntKey("active_anon", active_anon);
+ res.SetIntKey("inactive_anon", inactive_anon);
+ res.SetIntKey("active_file", active_file);
+ res.SetIntKey("inactive_file", inactive_file);
+ res.SetIntKey("swap_total", swap_total);
+ res.SetIntKey("swap_free", swap_free);
+ res.SetIntKey("swap_used", swap_total - swap_free);
+ res.SetIntKey("dirty", dirty);
+ res.SetIntKey("reclaimable", reclaimable);
+
+ return res;
+}
+
+Value VmStatInfo::ToValue() const {
+ Value res(Value::Type::DICTIONARY);
+
+ res.SetIntKey("pswpin", pswpin);
+ res.SetIntKey("pswpout", pswpout);
+ res.SetIntKey("pgmajfault", pgmajfault);
+
+ return res;
+}
} // namespace base

View File

@ -0,0 +1,212 @@
--- src/3rdparty/chromium/base/process/process_metrics_openbsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_metrics_openbsd.cc
@@ -6,14 +6,23 @@
#include <stddef.h>
#include <stdint.h>
+#include <fcntl.h>
#include <sys/param.h>
#include <sys/sysctl.h>
+#include <sys/vmmeter.h>
+#include <kvm.h>
+
#include "base/memory/ptr_util.h"
#include "base/process/process_metrics_iocounters.h"
+#include "base/values.h"
+#include "base/notreached.h"
namespace base {
+ProcessMetrics::ProcessMetrics(ProcessHandle process)
+ : process_(process) {}
+
// static
std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics(
ProcessHandle process) {
@@ -24,49 +33,24 @@ bool ProcessMetrics::GetIOCounters(IoCounters* io_coun
return false;
}
-static int GetProcessCPU(pid_t pid) {
+double ProcessMetrics::GetPlatformIndependentCPUUsage() {
struct kinfo_proc info;
- size_t length;
- int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid,
- sizeof(struct kinfo_proc), 0 };
+ size_t length = sizeof(struct kinfo_proc);
- if (sysctl(mib, std::size(mib), NULL, &length, NULL, 0) < 0)
- return -1;
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process_,
+ sizeof(struct kinfo_proc), 1 };
- mib[5] = (length / sizeof(struct kinfo_proc));
-
if (sysctl(mib, std::size(mib), &info, &length, NULL, 0) < 0)
- return 0;
+ return 0.0;
- return info.p_pctcpu;
+ return static_cast<double>((info.p_pctcpu * 100.0) / FSCALE);
}
-double ProcessMetrics::GetPlatformIndependentCPUUsage() {
- TimeTicks time = TimeTicks::Now();
-
- if (last_cpu_time_.is_zero()) {
- // First call, just set the last values.
- last_cpu_time_ = time;
- return 0;
- }
-
- int cpu = GetProcessCPU(process_);
-
- last_cpu_time_ = time;
- double percentage = static_cast<double>((cpu * 100.0) / FSCALE);
-
- return percentage;
-}
-
TimeDelta ProcessMetrics::GetCumulativeCPUUsage() {
NOTREACHED();
return TimeDelta();
}
-ProcessMetrics::ProcessMetrics(ProcessHandle process)
- : process_(process),
- last_cpu_(0) {}
-
size_t GetSystemCommitCharge() {
int mib[] = { CTL_VM, VM_METER };
int pagesize;
@@ -84,6 +68,129 @@ size_t GetSystemCommitCharge() {
pagesize = getpagesize();
return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize);
+}
+
+int ProcessMetrics::GetOpenFdCount() const {
+ struct kinfo_file *files;
+ kvm_t *kd = NULL;
+ int total_count = 0;
+ char errbuf[_POSIX2_LINE_MAX];
+
+ if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
+ goto out;
+
+ if ((files = kvm_getfiles(kd, KERN_FILE_BYPID, process_,
+ sizeof(struct kinfo_file), &total_count)) == NULL) {
+ total_count = 0;
+ goto out;
+ }
+
+ kvm_close(kd);
+
+out:
+ return total_count;
+}
+
+int ProcessMetrics::GetOpenFdSoftLimit() const {
+ return GetMaxFds();
+}
+
+uint64_t ProcessMetrics::GetVmSwapBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) {
+ NOTIMPLEMENTED_LOG_ONCE();
+ return false;
+}
+
+SystemDiskInfo::SystemDiskInfo() {
+ reads = 0;
+ reads_merged = 0;
+ sectors_read = 0;
+ read_time = 0;
+ writes = 0;
+ writes_merged = 0;
+ sectors_written = 0;
+ write_time = 0;
+ io = 0;
+ io_time = 0;
+ weighted_io_time = 0;
+}
+
+SystemDiskInfo::SystemDiskInfo(const SystemDiskInfo& other) = default;
+
+bool GetSystemDiskInfo(SystemDiskInfo* diskinfo) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool GetVmStatInfo(VmStatInfo* vmstat) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+int ProcessMetrics::GetIdleWakeupsPerSecond() {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+Value SystemMemoryInfoKB::ToValue() const {
+ Value res(Value::Type::DICTIONARY);
+ res.SetIntKey("total", total);
+ res.SetIntKey("free", free);
+ res.SetIntKey("available", available);
+ res.SetIntKey("buffers", buffers);
+ res.SetIntKey("cached", cached);
+ res.SetIntKey("active_anon", active_anon);
+ res.SetIntKey("inactive_anon", inactive_anon);
+ res.SetIntKey("active_file", active_file);
+ res.SetIntKey("inactive_file", inactive_file);
+ res.SetIntKey("swap_total", swap_total);
+ res.SetIntKey("swap_free", swap_free);
+ res.SetIntKey("swap_used", swap_total - swap_free);
+ res.SetIntKey("dirty", dirty);
+ res.SetIntKey("reclaimable", reclaimable);
+
+ NOTIMPLEMENTED();
+
+ return res;
+}
+
+Value VmStatInfo::ToValue() const {
+ Value res(Value::Type::DICTIONARY);
+ res.SetIntKey("pswpin", pswpin);
+ res.SetIntKey("pswpout", pswpout);
+ res.SetIntKey("pgmajfault", pgmajfault);
+
+ NOTIMPLEMENTED();
+
+ return res;
+}
+
+SystemDiskInfo& SystemDiskInfo::operator=(const SystemDiskInfo&) = default;
+
+Value SystemDiskInfo::ToValue() const {
+ Value res(Value::Type::DICTIONARY);
+
+ // Write out uint64_t variables as doubles.
+ // Note: this may discard some precision, but for JS there's no other option.
+ res.SetDoubleKey("reads", static_cast<double>(reads));
+ res.SetDoubleKey("reads_merged", static_cast<double>(reads_merged));
+ res.SetDoubleKey("sectors_read", static_cast<double>(sectors_read));
+ res.SetDoubleKey("read_time", static_cast<double>(read_time));
+ res.SetDoubleKey("writes", static_cast<double>(writes));
+ res.SetDoubleKey("writes_merged", static_cast<double>(writes_merged));
+ res.SetDoubleKey("sectors_written", static_cast<double>(sectors_written));
+ res.SetDoubleKey("write_time", static_cast<double>(write_time));
+ res.SetDoubleKey("io", static_cast<double>(io));
+ res.SetDoubleKey("io_time", static_cast<double>(io_time));
+ res.SetDoubleKey("weighted_io_time", static_cast<double>(weighted_io_time));
+
+ NOTIMPLEMENTED();
+
+ return res;
}
} // namespace base

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/process/process_metrics_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_metrics_posix.cc
@@ -20,6 +20,8 @@
#if BUILDFLAG(IS_APPLE)
#include <malloc/malloc.h>
+#elif BUILDFLAG(IS_OPENBSD)
+#include <stdlib.h>
#else
#include <malloc.h>
#endif
@@ -133,7 +135,7 @@ size_t ProcessMetrics::GetMallocUsage() {
return stats.size_in_use;
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
return GetMallocUsageMallinfo();
-#elif BUILDFLAG(IS_FUCHSIA)
+#elif BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_BSD)
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
return 0;
#endif

View File

@ -0,0 +1,93 @@
--- src/3rdparty/chromium/base/process/process_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/process/process_posix.cc
@@ -25,10 +25,15 @@
#include "build/build_config.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
-#if BUILDFLAG(IS_MAC)
+#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_BSD)
#include <sys/event.h>
#endif
+#if defined(OS_BSD)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
#if BUILDFLAG(CLANG_PROFILING)
#include "base/test/clang_profiling.h"
#endif
@@ -97,7 +102,7 @@ bool WaitpidWithTimeout(base::ProcessHandle handle,
return ret_pid > 0;
}
-#if BUILDFLAG(IS_MAC)
+#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_BSD)
// Using kqueue on Mac so that we can wait on non-child processes.
// We can't use kqueues on child processes because we need to reap
// our own children using wait.
@@ -202,7 +207,7 @@ bool WaitForExitWithTimeoutImpl(base::ProcessHandle ha
const bool exited = (parent_pid < 0);
if (!exited && parent_pid != our_pid) {
-#if BUILDFLAG(IS_MAC)
+#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_BSD)
// On Mac we can wait on non child processes.
return WaitForSingleNonChildProcess(handle, timeout);
#else
@@ -358,7 +363,55 @@ int Process::GetPriority() const {
int Process::GetPriority() const {
DCHECK(IsValid());
+// avoid pledge(2) violation
+#if defined(OS_BSD)
+ return 0;
+#else
return getpriority(PRIO_PROCESS, process_);
+#endif
+}
+
+Time Process::CreationTime() const {
+// avoid ps pledge in the network process
+#if !defined(OS_BSD)
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid(),
+ sizeof(struct kinfo_proc), 0 };
+ struct kinfo_proc *info = nullptr;
+ size_t info_size;
+#endif
+ Time ct = Time();
+
+#if !defined(OS_BSD)
+ if (sysctl(mib, std::size(mib), NULL, &info_size, NULL, 0) < 0)
+ goto out;
+
+ mib[5] = (info_size / sizeof(struct kinfo_proc));
+ if ((info = reinterpret_cast<kinfo_proc*>(malloc(info_size))) == NULL)
+ goto out;
+
+ if (sysctl(mib, std::size(mib), info, &info_size, NULL, 0) < 0)
+ goto out;
+
+ ct = Time::FromTimeT(info->p_ustart_sec);
+
+out:
+ if (info)
+ free(info);
+#endif
+ return ct;
+}
+
+bool Process::IsProcessBackgrounded() const {
+ return false;
+}
+
+bool Process::SetProcessBackgrounded(bool value) {
+ return false;
+}
+
+// static
+bool Process::CanBackgroundProcesses() {
+ return false;
}
} // namespace base

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/profiler/stack_sampling_profiler_test_util.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/profiler/stack_sampling_profiler_test_util.cc
@@ -39,7 +39,7 @@
// Fortunately, it provides _alloca, which functions identically.
#include <malloc.h>
#define alloca _alloca
-#else
+#elif !BUILDFLAG(IS_BSD)
#include <alloca.h>
#endif

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/rand_util.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/rand_util.h
@@ -81,7 +81,7 @@ void RandomShuffle(Itr first, Itr last) {
std::shuffle(first, last, RandomBitGenerator());
}
-#if BUILDFLAG(IS_POSIX)
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_OPENBSD)
BASE_EXPORT int GetUrandomFD();
#endif

View File

@ -0,0 +1,52 @@
--- src/3rdparty/chromium/base/rand_util_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/rand_util_posix.cc
@@ -17,7 +17,7 @@
#include "base/posix/eintr_wrapper.h"
#include "build/build_config.h"
-#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && !BUILDFLAG(IS_NACL)
+#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_BSD)
#include "third_party/lss/linux_syscall_support.h"
#elif BUILDFLAG(IS_MAC)
// TODO(crbug.com/995996): Waiting for this header to appear in the iOS SDK.
@@ -34,6 +34,7 @@ static constexpr int kOpenFlags = O_RDONLY | O_CLOEXEC
static constexpr int kOpenFlags = O_RDONLY | O_CLOEXEC;
#endif
+#if !BUILDFLAG(IS_OPENBSD)
// We keep the file descriptor for /dev/urandom around so we don't need to
// reopen it (which is expensive), and since we may not even be able to reopen
// it if we are later put in a sandbox. This class wraps the file descriptor so
@@ -51,6 +52,7 @@ class URandomFd {
private:
const int fd_;
};
+#endif
} // namespace
@@ -62,6 +64,7 @@ void RandBytes(void* output, size_t output_length) {
// (https://chromium-review.googlesource.com/c/chromium/src/+/1545096) and land
// it or some form of it.
void RandBytes(void* output, size_t output_length) {
+#if !BUILDFLAG(IS_OPENBSD)
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && !BUILDFLAG(IS_NACL)
// We have to call `getrandom` via Linux Syscall Support, rather than through
// the libc wrapper, because we might not have an up-to-date libc (e.g. on
@@ -93,11 +96,16 @@ void RandBytes(void* output, size_t output_length) {
const bool success =
ReadFromFD(urandom_fd, static_cast<char*>(output), output_length);
CHECK(success);
+#else
+ arc4random_buf(static_cast<char*>(output), output_length);
+#endif
}
+#if !BUILDFLAG(IS_OPENBSD)
int GetUrandomFD() {
static NoDestructor<URandomFd> urandom_fd;
return urandom_fd->fd();
}
+#endif
} // namespace base

View File

@ -0,0 +1,23 @@
--- src/3rdparty/chromium/base/synchronization/lock_impl.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/synchronization/lock_impl.h
@@ -106,6 +106,10 @@ void LockImpl::Unlock() {
}
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
+#if BUILDFLAG(IS_FREEBSD)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wthread-safety-analysis"
+#endif
#if DCHECK_IS_ON()
BASE_EXPORT void dcheck_trylock_result(int rv);
@@ -126,6 +130,9 @@ void LockImpl::Unlock() {
dcheck_unlock_result(rv);
#endif
}
+#if BUILDFLAG(IS_FREEBSD)
+#pragma GCC diagnostic pop
+#endif
#endif
// This is an implementation used for AutoLock templated on the lock type.

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/syslog_logging.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/syslog_logging.cc
@@ -15,7 +15,7 @@
#include "base/strings/string_util.h"
#include "base/win/scoped_handle.h"
#include "base/win/win_util.h"
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// <syslog.h> defines LOG_INFO, LOG_WARNING macros that could conflict with
// base::LOG_INFO, base::LOG_WARNING.
#include <syslog.h>
@@ -147,7 +147,7 @@ EventLogMessage::~EventLogMessage() {
if (user_sid != nullptr)
::LocalFree(user_sid);
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
const char kEventSource[] = "chrome";
openlog(kEventSource, LOG_NOWAIT | LOG_PID, LOG_USER);
// We can't use the defined names for the logging severity from syslog.h

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/system/sys_info.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/system/sys_info.cc
@@ -104,7 +104,7 @@ void SysInfo::GetHardwareInfo(base::OnceCallback<void(
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_APPLE)
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {}, base::BindOnce(&GetHardwareInfoSync), std::move(callback));
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock()}, base::BindOnce(&GetHardwareInfoSync),
std::move(callback));

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/system/sys_info.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/system/sys_info.h
@@ -212,6 +212,8 @@ class BASE_EXPORT SysInfo {
// On Desktop this returns true when memory <= 2GB.
static bool IsLowEndDevice();
+ static uint64_t MaxSharedMemorySize();
+
private:
FRIEND_TEST_ALL_PREFIXES(SysInfoTest, AmountOfAvailablePhysicalMemory);
FRIEND_TEST_ALL_PREFIXES(debug::SystemMetricsTest, ParseMeminfo);
@@ -222,7 +224,7 @@ class BASE_EXPORT SysInfo {
static HardwareInfo GetHardwareInfoSync();
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_AIX)
+ BUILDFLAG(IS_AIX) || BUILDFLAG(IS_BSD)
static int64_t AmountOfAvailablePhysicalMemory(
const SystemMemoryInfoKB& meminfo);
#endif

View File

@ -0,0 +1,113 @@
--- src/3rdparty/chromium/base/system/sys_info_freebsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/system/sys_info_freebsd.cc
@@ -9,30 +9,106 @@
#include <sys/sysctl.h>
#include "base/notreached.h"
+#include "base/process/process_metrics.h"
+#include "base/strings/string_util.h"
namespace base {
+int SysInfo::NumberOfProcessors() {
+ int mib[] = {CTL_HW, HW_NCPU};
+ int ncpu;
+ size_t size = sizeof(ncpu);
+ if (sysctl(mib, std::size(mib), &ncpu, &size, NULL, 0) < 0) {
+ NOTREACHED();
+ return 1;
+ }
+ return ncpu;
+}
+
int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
- int pages, page_size;
+ int pages, page_size, r = 0;
size_t size = sizeof(pages);
- sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);
- sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
- if (pages == -1 || page_size == -1) {
+
+ if (r == 0)
+ r = sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);
+ if (r == 0)
+ r = sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
+
+ if (r == -1) {
NOTREACHED();
return 0;
}
+
return static_cast<int64_t>(pages) * page_size;
}
+int64_t SysInfo::AmountOfAvailablePhysicalMemoryImpl() {
+ int page_size, r = 0;
+ unsigned int pgfree, pginact, pgcache;
+ size_t size = sizeof(page_size);
+ size_t szpg = sizeof(pgfree);
+
+ if (r == 0)
+ r = sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
+ if (r == 0)
+ r = sysctlbyname("vm.stats.vm.v_free_count", &pgfree, &szpg, NULL, 0);
+ if (r == 0)
+ r = sysctlbyname("vm.stats.vm.v_inactive_count", &pginact, &szpg, NULL, 0);
+ if (r == 0)
+ r = sysctlbyname("vm.stats.vm.v_cache_count", &pgcache, &szpg, NULL, 0);
+
+ if (r == -1) {
+ NOTREACHED();
+ return 0;
+ }
+
+ return static_cast<int64_t>((pgfree + pginact + pgcache) * page_size);
+}
+
// static
+int64_t SysInfo::AmountOfAvailablePhysicalMemory(const SystemMemoryInfoKB& info) {
+ int64_t res_kb = info.available != 0
+ ? info.available - info.active_file
+ : info.free + info.reclaimable + info.inactive_file;
+ return res_kb * 1024;
+}
+
+// static
+std::string SysInfo::CPUModelName() {
+ int mib[] = { CTL_HW, HW_MODEL };
+ char name[256];
+ size_t size = std::size(name);
+
+ if (sysctl(mib, std::size(mib), &name, &size, NULL, 0) == 0) {
+ return name;
+ }
+
+ return std::string();
+}
+
+// static
uint64_t SysInfo::MaxSharedMemorySize() {
size_t limit;
size_t size = sizeof(limit);
+
if (sysctlbyname("kern.ipc.shmmax", &limit, &size, NULL, 0) < 0) {
NOTREACHED();
return 0;
}
+
return static_cast<uint64_t>(limit);
+}
+
+SysInfo::HardwareInfo SysInfo::GetHardwareInfoSync() {
+ HardwareInfo info;
+
+ info.manufacturer = "FreeBSD";
+ info.model = HardwareModelName();
+
+ DCHECK(IsStringUTF8(info.manufacturer));
+ DCHECK(IsStringUTF8(info.model));
+
+ return info;
}
} // namespace base

View File

@ -0,0 +1,94 @@
--- src/3rdparty/chromium/base/system/sys_info_openbsd.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/system/sys_info_openbsd.cc
@@ -11,6 +11,7 @@
#include <sys/sysctl.h>
#include "base/notreached.h"
+#include "base/strings/string_util.h"
namespace {
@@ -28,9 +29,15 @@ namespace base {
namespace base {
+// pledge(2)
+int64_t aofpmem = 0;
+int64_t aofapmem = 0;
+int64_t shmmax = 0;
+char cpumodel[256];
+
// static
int SysInfo::NumberOfProcessors() {
- int mib[] = {CTL_HW, HW_NCPU};
+ int mib[] = {CTL_HW, HW_NCPUONLINE};
int ncpu;
size_t size = sizeof(ncpu);
if (sysctl(mib, std::size(mib), &ncpu, &size, NULL, 0) < 0) {
@@ -42,10 +49,26 @@ int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
// static
int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
- return AmountOfMemory(_SC_PHYS_PAGES);
+ // pledge(2)
+ if (!aofpmem)
+ aofpmem = AmountOfMemory(_SC_PHYS_PAGES);
+ return aofpmem;
}
// static
+std::string SysInfo::CPUModelName() {
+ int mib[] = {CTL_HW, HW_MODEL};
+ size_t len = std::size(cpumodel);
+
+ if (cpumodel[0] == '\0') {
+ if (sysctl(mib, std::size(mib), cpumodel, &len, NULL, 0) < 0)
+ return std::string();
+ }
+
+ return std::string(cpumodel, len - 1);
+}
+
+// static
int64_t SysInfo::AmountOfAvailablePhysicalMemoryImpl() {
// We should add inactive file-backed memory also but there is no such
// information from OpenBSD unfortunately.
@@ -57,23 +80,28 @@ uint64_t SysInfo::MaxSharedMemorySize() {
int mib[] = {CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX};
size_t limit;
size_t size = sizeof(limit);
+ // pledge(2)
+ if (shmmax)
+ goto out;
if (sysctl(mib, std::size(mib), &limit, &size, NULL, 0) < 0) {
NOTREACHED();
return 0;
}
- return static_cast<uint64_t>(limit);
+ shmmax = static_cast<uint64_t>(limit);
+out:
+ return shmmax;
}
// static
-std::string SysInfo::CPUModelName() {
- int mib[] = {CTL_HW, HW_MODEL};
- char name[256];
- size_t len = std::size(name);
- if (sysctl(mib, std::size(mib), name, &len, NULL, 0) < 0) {
- NOTREACHED();
- return std::string();
- }
- return name;
+SysInfo::HardwareInfo SysInfo::GetHardwareInfoSync() {
+ HardwareInfo info;
+ // Set the manufacturer to "OpenBSD" and the model to
+ // an empty string.
+ info.manufacturer = "OpenBSD";
+ info.model = HardwareModelName();
+ DCHECK(IsStringUTF8(info.manufacturer));
+ DCHECK(IsStringUTF8(info.model));
+ return info;
}
} // namespace base

View File

@ -0,0 +1,43 @@
--- src/3rdparty/chromium/base/system/sys_info_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/system/sys_info_posix.cc
@@ -37,7 +37,7 @@ namespace {
namespace {
-#if !BUILDFLAG(IS_OPENBSD)
+#if !BUILDFLAG(IS_BSD)
int NumberOfProcessors() {
// sysconf returns the number of "logical" (not "physical") processors on both
// Mac and Linux. So we get the number of max available "logical" processors.
@@ -77,7 +77,7 @@ base::LazyInstance<base::internal::LazySysInfoValue<in
base::LazyInstance<base::internal::LazySysInfoValue<int, NumberOfProcessors>>::
Leaky g_lazy_number_of_processors = LAZY_INSTANCE_INITIALIZER;
-#endif // !BUILDFLAG(IS_OPENBSD)
+#endif // !BUILDFLAG(IS_BSD)
int64_t AmountOfVirtualMemory() {
struct rlimit limit;
@@ -143,11 +143,11 @@ namespace base {
namespace base {
-#if !BUILDFLAG(IS_OPENBSD)
+#if !BUILDFLAG(IS_BSD)
int SysInfo::NumberOfProcessors() {
return g_lazy_number_of_processors.Get().value();
}
-#endif // !BUILDFLAG(IS_OPENBSD)
+#endif // !BUILDFLAG(IS_BSD)
// static
int64_t SysInfo::AmountOfVirtualMemory() {
@@ -239,6 +239,8 @@ std::string SysInfo::OperatingSystemArchitecture() {
arch = "x86";
} else if (arch == "amd64") {
arch = "x86_64";
+ } else if (arch == "arm64") {
+ arch = "aarch64";
} else if (std::string(info.sysname) == "AIX") {
arch = "ppc64";
}

View File

@ -0,0 +1,13 @@
--- src/3rdparty/chromium/base/test/test_file_util_linux.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/test/test_file_util_linux.cc
@@ -54,8 +54,10 @@ bool EvictFileFromSystemCache(const FilePath& file) {
return false;
if (fdatasync(fd.get()) != 0)
return false;
+#if !defined(OS_BSD)
if (posix_fadvise(fd.get(), 0, 0, POSIX_FADV_DONTNEED) != 0)
return false;
+#endif
return true;
}

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/test/test_file_util_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/test/test_file_util_posix.cc
@@ -88,7 +88,7 @@ void SyncPageCacheToDisk() {
}
#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_APPLE) && \
- !BUILDFLAG(IS_ANDROID)
+ !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_BSD)
bool EvictFileFromSystemCache(const FilePath& file) {
// There doesn't seem to be a POSIX way to cool the disk cache.
NOTIMPLEMENTED();

View File

@ -0,0 +1,14 @@
--- src/3rdparty/chromium/base/third_party/libevent/event.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/third_party/libevent/event.h
@@ -1,3 +1,6 @@
+#if defined(USE_SYSTEM_LIBEVENT)
+#include <event.h>
+#else
/*
* Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -1210,3 +1213,4 @@ int evtag_unmarshal_timeval(struct evbuffer *evbuf, ev
#endif
#endif /* _EVENT_H_ */
+#endif

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/third_party/symbolize/symbolize.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/third_party/symbolize/symbolize.cc
@@ -114,7 +114,7 @@ _END_GOOGLE_NAMESPACE_
#if defined(HAVE_DLFCN_H)
#include <dlfcn.h>
#endif
-#if BUILDFLAG(IS_OPENBSD)
+#if defined(__OpenBSD__)
#include <sys/exec_elf.h>
#else
#include <elf.h>

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/threading/platform_thread.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/threading/platform_thread.h
@@ -211,7 +211,7 @@ class BASE_EXPORT PlatformThread {
// Returns a realtime period provided by `delegate`.
static TimeDelta GetRealtimePeriod(Delegate* delegate);
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD)
// Toggles a specific thread's priority at runtime. This can be used to
// change the priority of a thread in a different process and will fail
// if the calling process does not have proper permissions. The

View File

@ -0,0 +1,77 @@
--- src/3rdparty/chromium/base/threading/platform_thread_linux.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/threading/platform_thread_linux.cc
@@ -30,7 +30,9 @@
#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_AIX)
#include <pthread.h>
+#if !BUILDFLAG(IS_BSD)
#include <sys/prctl.h>
+#endif
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -133,7 +135,7 @@ int sched_setattr(pid_t pid,
#endif // !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_AIX)
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
-#if !BUILDFLAG(IS_NACL)
+#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_BSD)
const FilePath::CharType kCgroupDirectory[] =
FILE_PATH_LITERAL("/sys/fs/cgroup");
@@ -287,7 +289,7 @@ namespace {
namespace internal {
namespace {
-#if !BUILDFLAG(IS_NACL)
+#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_BSD)
const struct sched_param kRealTimePrio = {8};
#endif
} // namespace
@@ -300,7 +302,7 @@ bool CanSetThreadPriorityToRealtimeAudio() {
};
bool CanSetThreadPriorityToRealtimeAudio() {
-#if !BUILDFLAG(IS_NACL)
+#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_BSD)
// A non-zero soft-limit on RLIMIT_RTPRIO is required to be allowed to invoke
// pthread_setschedparam in SetCurrentThreadPriorityForPlatform().
struct rlimit rlim;
@@ -311,7 +313,7 @@ bool SetCurrentThreadPriorityForPlatform(ThreadPriorit
}
bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) {
-#if !BUILDFLAG(IS_NACL)
+#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_BSD)
// For legacy schedtune interface
SetThreadCgroupsForThreadPriority(PlatformThread::CurrentId(), priority);
@@ -329,7 +331,7 @@ absl::optional<ThreadPriority> GetCurrentThreadPriorit
}
absl::optional<ThreadPriority> GetCurrentThreadPriorityForPlatform() {
-#if !BUILDFLAG(IS_NACL)
+#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_BSD)
int maybe_sched_rr = 0;
struct sched_param maybe_realtime_prio = {0};
if (pthread_getschedparam(pthread_self(), &maybe_sched_rr,
@@ -348,7 +350,7 @@ void PlatformThread::SetName(const std::string& name)
void PlatformThread::SetName(const std::string& name) {
ThreadIdNameManager::GetInstance()->SetName(name);
-#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_AIX)
+#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_AIX) && !BUILDFLAG(IS_BSD)
// On linux we can get the thread names to show up in the debugger by setting
// the process name for the LWP. We don't want to do this for the main
// thread because that would rename the process, causing tools like killall
@@ -378,8 +380,10 @@ void PlatformThread::SetThreadPriority(ProcessId proce
// priority.
CHECK_NE(thread_id, process_id);
+#if !BUILDFLAG(IS_BSD)
// For legacy schedtune interface
SetThreadCgroupsForThreadPriority(thread_id, priority);
+#endif
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
// For upstream uclamp interface. We try both legacy (schedtune, as done

View File

@ -0,0 +1,21 @@
--- src/3rdparty/chromium/base/threading/platform_thread_posix.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/threading/platform_thread_posix.cc
@@ -76,7 +76,7 @@ void* ThreadFunc(void* params) {
if (!thread_params->joinable)
base::DisallowSingleton();
-#if !BUILDFLAG(IS_NACL)
+#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_BSD)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
internal::PCScan::NotifyThreadCreated(internal::GetStackPointer());
#endif
@@ -365,6 +365,9 @@ void PlatformThread::SetCurrentThreadPriorityImpl(Thre
// static
void PlatformThread::SetCurrentThreadPriorityImpl(ThreadPriority priority) {
#if BUILDFLAG(IS_NACL)
+ NOTIMPLEMENTED();
+// avoid pledge(2) violation
+#elif BUILDFLAG(IS_BSD)
NOTIMPLEMENTED();
#else
if (internal::SetCurrentThreadPriorityForPlatform(priority))

View File

@ -0,0 +1,26 @@
--- src/3rdparty/chromium/base/threading/thread_task_runner_handle.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/threading/thread_task_runner_handle.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/check_op.h"
#include "base/dcheck_is_on.h"
#include "base/lazy_instance.h"
@@ -40,6 +41,7 @@ const scoped_refptr<SingleThreadTaskRunner>& ThreadTas
return current->task_runner_;
}
+#if defined(OS_BSD)
// static
bool ThreadTaskRunnerHandle::IsSet() {
return !!thread_task_runner_tls.Pointer()->Get();
@@ -89,6 +91,7 @@ ThreadTaskRunnerHandleOverride::ThreadTaskRunnerHandle
std::make_unique<ScopedDisallowRunningRunLoop>();
}
}
+#endif
ThreadTaskRunnerHandleOverride::~ThreadTaskRunnerHandleOverride() {
if (task_runner_to_restore_) {

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/time/time.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/time/time.cc
@@ -6,7 +6,7 @@
#include "build/build_config.h"
-#if BUILDFLAG(IS_LINUX)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)
// time.h is a widely included header and its size impacts build time.
// Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md

View File

@ -0,0 +1,31 @@
--- src/3rdparty/chromium/base/trace_event/malloc_dump_provider.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/trace_event/malloc_dump_provider.cc
@@ -23,6 +23,8 @@
#if BUILDFLAG(IS_APPLE)
#include <malloc/malloc.h>
+#elif defined(OS_BSD)
+#include <stdlib.h>
#else
#include <malloc.h>
#endif
@@ -174,7 +176,8 @@ void ReportAppleAllocStats(size_t* total_virtual_size,
#if (BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(IS_ANDROID)) || \
(!BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && !BUILDFLAG(IS_WIN) && \
- !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_FUCHSIA))
+ !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_FUCHSIA) && \
+ !BUILDFLAG(IS_BSD))
void ReportMallinfoStats(ProcessMemoryDump* pmd,
size_t* total_virtual_size,
size_t* resident_size,
@@ -339,6 +342,9 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDump
&allocated_objects_count);
#elif BUILDFLAG(IS_FUCHSIA)
// TODO(fuchsia): Port, see https://crbug.com/706592.
+#elif defined(OS_BSD)
+ total_virtual_size = 0;
+ allocated_objects_size = 0;
#else
ReportMallinfoStats(/*pmd=*/nullptr, &total_virtual_size, &resident_size,
&allocated_objects_size, &allocated_objects_count);

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/trace_event/memory_dump_manager.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/trace_event/memory_dump_manager.cc
@@ -82,7 +82,7 @@ const char* const MemoryDumpManager::kSystemAllocatorP
#if defined(MALLOC_MEMORY_TRACING_SUPPORTED)
MallocDumpProvider::kAllocatedObjects;
#else
- nullptr;
+ "";
#endif
// static

View File

@ -0,0 +1,20 @@
--- src/3rdparty/chromium/base/trace_event/process_memory_dump.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/trace_event/process_memory_dump.cc
@@ -105,7 +105,7 @@ absl::optional<size_t> ProcessMemoryDump::CountResiden
#if BUILDFLAG(IS_WIN)
std::unique_ptr<PSAPI_WORKING_SET_EX_INFORMATION[]> vec(
new PSAPI_WORKING_SET_EX_INFORMATION[max_vec_size]);
-#elif BUILDFLAG(IS_APPLE)
+#elif BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_BSD)
std::unique_ptr<char[]> vec(new char[max_vec_size]);
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
std::unique_ptr<unsigned char[]> vec(new unsigned char[max_vec_size]);
@@ -130,7 +130,7 @@ absl::optional<size_t> ProcessMemoryDump::CountResiden
for (size_t i = 0; i < page_count; i++)
resident_page_count += vec[i].VirtualAttributes.Valid;
-#elif BUILDFLAG(IS_FUCHSIA)
+#elif BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_BSD)
// TODO(fuchsia): Port, see https://crbug.com/706592.
#elif BUILDFLAG(IS_APPLE)
// mincore in MAC does not fail with EAGAIN.

View File

@ -0,0 +1,28 @@
--- src/3rdparty/chromium/base/tracing/trace_time.cc.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/tracing/trace_time.cc
@@ -8,13 +8,17 @@
#include "build/build_config.h"
#include "third_party/perfetto/include/perfetto/base/time.h"
+#if BUILDFLAG(IS_FREEBSD)
+#define CLOCK_BOOTTIME CLOCK_UPTIME
+#endif
+
namespace base {
namespace tracing {
int64_t TraceBootTicksNow() {
// On Windows and Mac, TRACE_TIME_TICKS_NOW() behaves like boottime already.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_FUCHSIA)
+ BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_BSD)
struct timespec ts;
int res = clock_gettime(CLOCK_BOOTTIME, &ts);
if (res != -1)
@@ -24,4 +28,4 @@ int64_t TraceBootTicksNow() {
}
} // namespace tracing
-} // namespace base
\ No newline at end of file
+} // namespace base

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/base/tracing/trace_time.h.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/base/tracing/trace_time.h
@@ -12,7 +12,7 @@ namespace tracing {
namespace tracing {
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \
- BUILDFLAG(IS_FUCHSIA)
+ BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_BSD)
// Linux, Android, and Fuchsia all use CLOCK_MONOTONIC. See crbug.com/166153
// about efforts to unify base::TimeTicks across all platforms.
constexpr perfetto::protos::pbzero::BuiltinClock kTraceClockId =

View File

@ -0,0 +1,22 @@
--- src/3rdparty/chromium/build/config/BUILD.gn.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/BUILD.gn
@@ -222,13 +222,17 @@ config("default_libs") {
"CoreText.framework",
"Foundation.framework",
]
- } else if (is_linux || is_chromeos) {
+ } else if ((is_linux && !is_bsd) || is_chromeos) {
libs = [
"dl",
"pthread",
"rt",
]
- }
+ } else if (is_bsd) {
+ libs = [
+ "pthread",
+ ]
+ }
}
group("common_deps") {

View File

@ -0,0 +1,45 @@
--- src/3rdparty/chromium/build/config/BUILDCONFIG.gn.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/BUILDCONFIG.gn
@@ -136,7 +136,8 @@ declare_args() {
is_official_build = false
# Set to true when compiling with the Clang compiler.
- is_clang = current_os != "linux" ||
+ is_clang = current_os != "linux" || current_os == "openbsd" ||
+ current_os == "freebsd" ||
(current_cpu != "s390x" && current_cpu != "s390" &&
current_cpu != "ppc64" && current_cpu != "ppc" &&
current_cpu != "mips" && current_cpu != "mips64" &&
@@ -225,6 +226,10 @@ if (host_toolchain == "") {
host_toolchain = "//build/toolchain/aix:$host_cpu"
} else if (host_os == "zos") {
host_toolchain = "//build/toolchain/zos:$host_cpu"
+ } else if (host_os == "openbsd") {
+ host_toolchain = "//build/toolchain/openbsd:clang_$host_cpu"
+ } else if (host_os == "freebsd") {
+ host_toolchain = "//build/toolchain/freebsd:clang_$host_cpu"
} else {
assert(false, "Unsupported host_os: $host_os")
}
@@ -269,6 +274,8 @@ if (target_os == "android") {
_default_toolchain = "//build/toolchain/aix:$target_cpu"
} else if (target_os == "zos") {
_default_toolchain = "//build/toolchain/zos:$target_cpu"
+} else if (target_os == "openbsd" || target_os == "freebsd") {
+ _default_toolchain = host_toolchain
} else {
assert(false, "Unsupported target_os: $target_os")
}
@@ -303,7 +310,11 @@ is_ios = current_os == "ios"
is_chromeos = current_os == "chromeos"
is_fuchsia = current_os == "fuchsia"
is_ios = current_os == "ios"
-is_linux = current_os == "linux"
+is_linux = current_os == "linux" || current_os == "openbsd" ||
+ current_os == "freebsd"
+is_openbsd = current_os == "openbsd"
+is_freebsd = current_os == "freebsd"
+is_bsd = current_os == "openbsd" || current_os == "freebsd"
is_mac = current_os == "mac"
is_nacl = current_os == "nacl"
is_win = current_os == "win" || current_os == "winuwp"

View File

@ -0,0 +1,94 @@
--- src/3rdparty/chromium/build/config/compiler/BUILD.gn.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/compiler/BUILD.gn
@@ -237,13 +237,16 @@ config("no_unresolved_symbols") {
# Compiler instrumentation can introduce dependencies in DSOs to symbols in
# the executable they are loaded into, so they are unresolved at link-time.
config("no_unresolved_symbols") {
- if (!using_sanitizer &&
+ if (!using_sanitizer && !is_bsd &&
(is_linux || is_chromeos || is_android || is_fuchsia)) {
ldflags = [
"-Wl,-z,defs",
"-Wl,--as-needed",
]
}
+ if (current_cpu == "x86" && is_openbsd) {
+ ldflags = [ "-Wl,-z,notext" ]
+ }
}
# compiler ---------------------------------------------------------------------
@@ -487,6 +490,10 @@ config("compiler") {
}
}
+ if (is_openbsd) {
+ ldflags += [ "-Wl,-z,wxneeded" ]
+ }
+
# Linux-specific compiler flags setup.
# ------------------------------------
if (use_gold) {
@@ -952,7 +959,7 @@ config("compiler_cpu_abi") {
]
}
} else if (current_cpu == "arm") {
- if (is_clang && !is_android && !is_nacl) {
+ if (is_clang && !is_android && !is_nacl && !is_bsd) {
cflags += [ "--target=arm-linux-gnueabihf" ]
ldflags += [ "--target=arm-linux-gnueabihf" ]
}
@@ -969,7 +976,7 @@ config("compiler_cpu_abi") {
cflags += [ "-mtune=$arm_tune" ]
}
} else if (current_cpu == "arm64") {
- if (is_clang && !is_android && !is_nacl && !is_fuchsia) {
+ if (is_clang && !is_android && !is_nacl && !is_fuchsia && !is_bsd) {
cflags += [ "--target=aarch64-linux-gnu" ]
ldflags += [ "--target=aarch64-linux-gnu" ]
}
@@ -1290,7 +1297,7 @@ config("compiler_deterministic") {
# different build directory like "out/feature_a" and "out/feature_b" if
# we build same files with same compile flag.
# Other paths are already given in relative, no need to normalize them.
- if (is_nacl) {
+ if (is_nacl || is_bsd) {
# TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here.
cflags += [
"-Xclang",
@@ -1745,7 +1752,7 @@ config("default_warnings") {
"-Wno-ignored-pragma-optimize",
]
- if (!is_nacl) {
+ if (!is_nacl && !is_bsd) {
# TODO(https://crbug.com/1300731) Clean up and enable.
cflags += [ "-Wno-unqualified-std-cast-call" ]
@@ -1929,7 +1936,7 @@ config("no_chromium_code") {
# third-party libraries.
"-Wno-c++11-narrowing",
]
- if (!is_nacl) {
+ if (!is_nacl && !is_freebsd) {
cflags += [
# Disabled for similar reasons as -Wunused-variable.
"-Wno-unused-but-set-variable",
@@ -2451,7 +2458,7 @@ config("afdo") {
# There are some targeted places that AFDO regresses, so we provide a separate
# config to allow AFDO to be disabled per-target.
config("afdo") {
- if (is_clang) {
+ if (is_clang && !is_bsd) {
cflags = []
if (clang_emit_debug_info_for_profiling) {
# Add the following flags to generate debug info for profiling.
@@ -2467,7 +2474,7 @@ config("afdo") {
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
inputs = [ _clang_sample_profile ]
}
- } else if (auto_profile_path != "" && is_a_target_toolchain) {
+ } else if (auto_profile_path != "" && is_a_target_toolchain && !is_bsd) {
cflags = [ "-fauto-profile=${auto_profile_path}" ]
inputs = [ auto_profile_path ]
}

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/build/config/compiler/pgo/pgo.gni.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/compiler/pgo/pgo.gni
@@ -16,7 +16,7 @@ declare_args() {
# TODO(crbug.com/1052397): Remove chromeos_is_browser_only once
# target_os switch for lacros-chrome is completed.
(is_win || is_mac ||
- (is_linux && !chromeos_is_browser_only && !is_chromecast))) {
+ (is_linux && !chromeos_is_browser_only && !is_chromecast && !is_bsd))) {
chrome_pgo_phase = 2
}

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/build/config/linux/pkg-config.py.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/linux/pkg-config.py
@@ -109,7 +109,7 @@ def main():
# If this is run on non-Linux platforms, just return nothing and indicate
# success. This allows us to "kind of emulate" a Linux build from other
# platforms.
- if "linux" not in sys.platform:
+ if not sys.platform.startswith(tuple(['linux', 'openbsd', 'freebsd'])):
print("[[],[],[],[],[]]")
return 0

View File

@ -0,0 +1,19 @@
--- src/3rdparty/chromium/build/config/ozone.gni.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/ozone.gni
@@ -94,7 +94,15 @@ declare_args() {
} else if (is_chromeos_lacros) {
ozone_platform = "wayland"
ozone_platform_wayland = true
- } else if (is_linux) {
+ } else if (is_linux && !is_bsd) {
+ ozone_platform = "x11"
+ ozone_platform_wayland = true
+ ozone_platform_x11 = true
+ } else if (is_openbsd) {
+ ozone_platform = "x11"
+ ozone_platform_wayland = false
+ ozone_platform_x11 = true
+ } else if (is_freebsd) {
ozone_platform = "x11"
ozone_platform_wayland = true
ozone_platform_x11 = true

View File

@ -0,0 +1,11 @@
--- src/3rdparty/chromium/build/config/rust.gni.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/rust.gni
@@ -116,7 +116,7 @@ if (enable_rust) {
rust_sysroot = "//third_party/rust-toolchain"
use_unverified_rust_toolchain = false
} else {
- if (host_os != "linux") {
+ if (host_os != "linux" && host_os != "openbsd" && host_os != "freebsd") {
assert(false,
"Attempt to use Android Rust toolchain on an unsupported platform")
}

View File

@ -0,0 +1,13 @@
--- src/3rdparty/chromium/build/config/v8_target_cpu.gni.orig 2022-09-26 10:05:50 UTC
+++ src/3rdparty/chromium/build/config/v8_target_cpu.gni
@@ -36,6 +36,10 @@ if (v8_target_cpu == "") {
if (v8_target_cpu == "") {
if (current_toolchain == "//build/toolchain/linux:clang_x64_v8_arm64") {
v8_target_cpu = "arm64"
+ } else if (current_toolchain == "//build/toolchain/openbsd:clang_arm64") {
+ v8_target_cpu = "arm64"
+ } else if (current_toolchain == "//build/toolchain/freebsd:clang_arm64") {
+ v8_target_cpu = "arm64"
} else if (current_toolchain == "//build/toolchain/linux:clang_x86_v8_arm") {
v8_target_cpu = "arm"
} else if (current_toolchain ==

Some files were not shown because too many files have changed in this diff Show More