From a54ec373a69ed8369a508cfd0a6ec616f46b0cc4 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 1 Jun 2026 00:11:44 +0100 Subject: [PATCH] depends: Build `qt` and `qrencode` packages for OpenBSD hosts --- depends/README.md | 4 +++ depends/packages/freetype.mk | 4 ++- depends/packages/packages.mk | 2 ++ depends/packages/qt.mk | 10 ++++-- .../patches/freetype/openbsd_versioning.patch | 31 +++++++++++++++++++ .../qt/fix_openbsd_network_kernel.patch | 31 +++++++++++++++++++ .../qt/fix_openbsd_plugin_qelfparser.patch | 20 ++++++++++++ depends/toolchain.cmake.in | 2 +- src/qt/CMakeLists.txt | 2 +- 9 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 depends/patches/freetype/openbsd_versioning.patch create mode 100644 depends/patches/qt/fix_openbsd_network_kernel.patch create mode 100644 depends/patches/qt/fix_openbsd_plugin_qelfparser.patch diff --git a/depends/README.md b/depends/README.md index b12df1354e5..bdb9279440b 100644 --- a/depends/README.md +++ b/depends/README.md @@ -53,6 +53,10 @@ To build dependencies for the current arch+OS: pkg_add bash cmake curl gmake gtar +Skip the following packages if you don't intend to use the GUI and will build with [`NO_QT=1`](#dependency-options): + + pkg_add bison ninja + To build dependencies for the current arch+OS: gmake diff --git a/depends/packages/freetype.mk b/depends/packages/freetype.mk index b34edc6034c..74d5e42a64f 100644 --- a/depends/packages/freetype.mk +++ b/depends/packages/freetype.mk @@ -5,6 +5,7 @@ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=f8db94d307e9c54961b39a1cc799a67d46681480696ed72ecf78d4473770f09b $(package)_build_subdir=build $(package)_patches += cmake_minimum.patch +$(package)_patches += openbsd_versioning.patch define $(package)_set_vars $(package)_config_opts := -DCMAKE_BUILD_TYPE=None -DBUILD_SHARED_LIBS=TRUE @@ -14,7 +15,8 @@ define $(package)_set_vars endef define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch + patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch && \ + patch -p1 < $($(package)_patch_dir)/openbsd_versioning.patch endef define $(package)_config_cmds diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 22ae4787fe7..b77c3ecacad 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -6,11 +6,13 @@ libevent_packages = libevent qrencode_linux_packages = qrencode qrencode_freebsd_packages = qrencode +qrencode_openbsd_packages = qrencode qrencode_darwin_packages = qrencode qrencode_mingw32_packages = qrencode qt_linux_packages:=qt expat libxcb xcb_proto libXau xproto freetype fontconfig libxkbcommon libxcb_util libxcb_util_cursor libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm qt_freebsd_packages:=$(qt_linux_packages) +qt_openbsd_packages:=$(qt_linux_packages) qt_darwin_packages=qt qt_mingw32_packages=qt ifneq ($(host),$(build)) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 9b7cec341d6..500a2729faa 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -9,6 +9,7 @@ $(package)_dependencies := native_$(package) endif $(package)_linux_dependencies := freetype fontconfig libxcb libxkbcommon libxcb_util libxcb_util_cursor libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm $(package)_freebsd_dependencies := $($(package)_linux_dependencies) +$(package)_openbsd_dependencies := $($(package)_linux_dependencies) $(package)_patches_path := $(qt_details_patches_path) $(package)_patches := cocoa_compat.patch $(package)_patches += dont_hardcode_pwd.patch @@ -26,6 +27,8 @@ $(package)_patches += fix-gcc16-sfinae-qbitarray.patch $(package)_patches += fix-gcc16-sfinae-qanystringview.patch $(package)_patches += fix-macos26-qyield.patch $(package)_patches += fix-qbytearray-include.patch +$(package)_patches += fix_openbsd_network_kernel.patch +$(package)_patches += fix_openbsd_plugin_qelfparser.patch $(package)_qttranslations_file_name=$(qt_details_qttranslations_file_name) $(package)_qttranslations_sha256_hash=$(qt_details_qttranslations_sha256_hash) @@ -158,6 +161,7 @@ $(package)_config_opts_linux += -ltcg endif $(package)_config_opts_freebsd := $$($(package)_config_opts_linux) $(package)_config_opts_freebsd += -no-feature-inotify +$(package)_config_opts_openbsd := $$($(package)_config_opts_linux) $(package)_config_opts_mingw32 := -no-dbus $(package)_config_opts_mingw32 += -no-feature-freetype @@ -208,7 +212,7 @@ $(package)_cmake_opts += -DCMAKE_DISABLE_FIND_PACKAGE_WrapSystemDoubleConversion $(package)_cmake_opts += -DCMAKE_DISABLE_FIND_PACKAGE_WrapSystemMd4c=TRUE $(package)_cmake_opts += -DCMAKE_DISABLE_FIND_PACKAGE_WrapZSTD=TRUE endif -ifeq ($(host_os),linux) +ifneq (,$(filter linux openbsd,$(host_os))) # The `-dbus-runtime` configure option does not work # https://qt-project.atlassian.net/browse/QTBUG-144864 $(package)_cmake_opts += -DINPUT_dbus=runtime @@ -284,7 +288,9 @@ define $(package)_preprocess_cmds patch -p1 -i $($(package)_patch_dir)/fix-gcc16-sfinae-qbitarray.patch && \ patch -p1 -i $($(package)_patch_dir)/fix-gcc16-sfinae-qanystringview.patch && \ patch -p1 -i $($(package)_patch_dir)/fix-macos26-qyield.patch && \ - patch -p1 -i $($(package)_patch_dir)/fix-qbytearray-include.patch + patch -p1 -i $($(package)_patch_dir)/fix-qbytearray-include.patch && \ + patch -p1 -i $($(package)_patch_dir)/fix_openbsd_network_kernel.patch && \ + patch -p1 -i $($(package)_patch_dir)/fix_openbsd_plugin_qelfparser.patch endef ifeq ($(host),$(build)) $(package)_preprocess_cmds += && patch -p1 -i $($(package)_patch_dir)/qttools_skip_dependencies.patch diff --git a/depends/patches/freetype/openbsd_versioning.patch b/depends/patches/freetype/openbsd_versioning.patch new file mode 100644 index 00000000000..ea5cffef6ed --- /dev/null +++ b/depends/patches/freetype/openbsd_versioning.patch @@ -0,0 +1,31 @@ +[cmake] Fix shared library versioning on OpenBSD. + +This emulates Libtool to make sure Libtool and CMake agree on the ABI +version. Specifically, for OpenBSD, `builds/unix/configure` defines +`version_type=sunos` and skips defining `soname_spec`. + +See upstream MR: https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/433. + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -458,9 +458,17 @@ if (WIN32) + endif () + + if (BUILD_SHARED_LIBS) +- set_target_properties(freetype PROPERTIES +- VERSION ${LIBRARY_VERSION} +- SOVERSION ${LIBRARY_SOVERSION}) ++ if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") ++ # For OpenBSD, libtool follows `sunos` version type. ++ set_target_properties(freetype PROPERTIES ++ # libtool does not define its internal `soname_spec` variable ++ # for OpenBSD. So skipping the SOVERSION option. ++ VERSION ${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}) ++ else () ++ set_target_properties(freetype PROPERTIES ++ VERSION ${LIBRARY_VERSION} ++ SOVERSION ${LIBRARY_SOVERSION}) ++ endif () + endif () + + # Pick up ftconfig.h and ftoption.h generated above, first. diff --git a/depends/patches/qt/fix_openbsd_network_kernel.patch b/depends/patches/qt/fix_openbsd_network_kernel.patch new file mode 100644 index 00000000000..2a5a4ac290a --- /dev/null +++ b/depends/patches/qt/fix_openbsd_network_kernel.patch @@ -0,0 +1,31 @@ +Fix compiling on OpenBSD + +1. The `net/if_types.h` header does not define the `IFT_STF` symbol. +2. The `netinet6/in6_var.h` header defines some of the used symbols. + +For the reference, see: + - https://codeberg.org/OpenBSD/ports/src/commit/f8f1aedbe8aff550c69930b5d92b9c392e298382/x11/qt6/qtbase/patches/patch-src_network_kernel_qnetworkinterface_unix_cpp + + +--- a/qtbase/src/network/kernel/qnetworkinterface_unix.cpp ++++ b/qtbase/src/network/kernel/qnetworkinterface_unix.cpp +@@ -392,6 +392,9 @@ QT_BEGIN_INCLUDE_NAMESPACE + # include + # include + # include ++# ifdef Q_OS_OPENBSD ++# include ++# endif + #endif // QT_PLATFORM_UIKIT + QT_END_INCLUDE_NAMESPACE + +@@ -419,7 +422,9 @@ static QNetworkInterface::InterfaceType probeIfType(int socket, int iftype, stru + return QNetworkInterface::Ieee1394; + + case IFT_GIF: ++#ifndef Q_OS_OPENBSD + case IFT_STF: ++#endif + return QNetworkInterface::Virtual; + } + diff --git a/depends/patches/qt/fix_openbsd_plugin_qelfparser.patch b/depends/patches/qt/fix_openbsd_plugin_qelfparser.patch new file mode 100644 index 00000000000..1b32e45ff70 --- /dev/null +++ b/depends/patches/qt/fix_openbsd_plugin_qelfparser.patch @@ -0,0 +1,20 @@ +Fix compiling on OpenBSD + +Avoid use of undeclared identifier `ELFOSABI_AIX`. + +For the reference, see: + - https://codeberg.org/OpenBSD/ports/src/commit/c5e4088b89277b96d840492f9961b1593182b99c/x11/qt6/qtbase/patches/patch-src_corelib_plugin_qelfparser_p_cpp + + +--- a/qtbase/src/corelib/plugin/qelfparser_p.cpp ++++ b/qtbase/src/corelib/plugin/qelfparser_p.cpp +@@ -341,7 +341,9 @@ Q_DECL_UNUSED Q_DECL_COLD_FUNCTION static QDebug &operator<<(QDebug &d, ElfHeade + case ELFOSABI_NETBSD: d << " (NetBSD"; break; + case ELFOSABI_LINUX: d << " (GNU/Linux"; break; + case ELFOSABI_SOLARIS: d << " (Solaris"; break; ++#ifndef Q_OS_OPENBSD + case ELFOSABI_AIX: d << " (AIX"; break; ++#endif + case ELFOSABI_IRIX: d << " (IRIX"; break; + case ELFOSABI_FREEBSD: d << " (FreeBSD"; break; + case ELFOSABI_OPENBSD: d << " (OpenBSD"; break; diff --git a/depends/toolchain.cmake.in b/depends/toolchain.cmake.in index 87189efa1cb..9d9f9e49338 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -117,7 +117,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE) endif() -if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD)$") +if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD|OpenBSD)$") # Customize pkg-config behavior for finding dependencies # of the xcb QPA platform plugin: # 1. Restrict search paths to the depends. diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 58fa08b56ab..b5ad93dc82e 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -16,7 +16,7 @@ get_target_property(qt_lib_type Qt6::Core TYPE) function(import_plugins target) if(qt_lib_type STREQUAL "STATIC_LIBRARY") set(plugins Qt6::QMinimalIntegrationPlugin) - if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD)$") + if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD|OpenBSD)$") list(APPEND plugins Qt6::QXcbIntegrationPlugin) elseif(WIN32) list(APPEND plugins Qt6::QWindowsIntegrationPlugin Qt6::QModernWindowsStylePlugin)