pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Import swiftshader



Module Name:	pkgsrc-wip
Committed By:	kikadf <kikadf.01%gmail.com@localhost>
Pushed By:	kikadf
Date:		Thu Nov 20 16:42:45 2025 +0100
Changeset:	e122bdaa19c789ae832a16baf6d2306823d2e4b2

Modified Files:
	Makefile
Added Files:
	swiftshader/DESCR
	swiftshader/Makefile
	swiftshader/PLIST
	swiftshader/distinfo
	swiftshader/patches/patch-CMakeLists.txt
	swiftshader/patches/patch-src_Reactor_Debug.cpp
	swiftshader/patches/patch-src_System_Configurator.cpp
	swiftshader/patches/patch-src_System_Linux_MemFd.cpp
	swiftshader/patches/patch-src_Vulkan_CMakeLists.txt
	swiftshader/patches/patch-src_Vulkan_VkSemaphoreExternalLinux.hpp
	swiftshader/patches/patch-src_WSI_libXCB.cpp
	swiftshader/patches/patch-third__party_llvm-10.0_CMakeLists.txt
	swiftshader/patches/patch-third__party_llvm-10.0_configs_linux_include_llvm_Config_config.h
	swiftshader/patches/patch-third__party_llvm-subzero_build_Linux_include_llvm_Config_config.h
	swiftshader/patches/patch-third__party_marl_src_memory.cpp
	swiftshader/patches/patch-third__party_marl_src_thread.cpp

Log Message:
Import swiftshader

SwiftShader is a high-performance CPU-based implementation
of the Vulkan graphics API. Its goal is to provide hardware
independence for advanced 3D graphics.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=e122bdaa19c789ae832a16baf6d2306823d2e4b2

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                           |   1 +
 swiftshader/DESCR                                  |   3 +
 swiftshader/Makefile                               |  61 ++++++++
 swiftshader/PLIST                                  |   3 +
 swiftshader/distinfo                               |  38 +++++
 swiftshader/patches/patch-CMakeLists.txt           |  15 ++
 swiftshader/patches/patch-src_Reactor_Debug.cpp    |  16 +++
 .../patches/patch-src_System_Configurator.cpp      |  16 +++
 .../patches/patch-src_System_Linux_MemFd.cpp       |  41 ++++++
 .../patches/patch-src_Vulkan_CMakeLists.txt        |  15 ++
 .../patch-src_Vulkan_VkSemaphoreExternalLinux.hpp  |  24 ++++
 swiftshader/patches/patch-src_WSI_libXCB.cpp       |  24 ++++
 .../patch-third__party_llvm-10.0_CMakeLists.txt    |  16 +++
 ...10.0_configs_linux_include_llvm_Config_config.h | 154 +++++++++++++++++++++
 ...ubzero_build_Linux_include_llvm_Config_config.h |  51 +++++++
 .../patches/patch-third__party_marl_src_memory.cpp |  16 +++
 .../patches/patch-third__party_marl_src_thread.cpp |  25 ++++
 17 files changed, 519 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index accd77b91c..fa02727cd0 100644
--- a/Makefile
+++ b/Makefile
@@ -5601,6 +5601,7 @@ SUBDIR+=	swfmill
 SUBDIR+=	swftools
 SUBDIR+=	swift
 SUBDIR+=	swift-git
+SUBDIR+=	swiftshader
 SUBDIR+=	swig4
 SUBDIR+=	swinehub
 SUBDIR+=	swisseph
diff --git a/swiftshader/DESCR b/swiftshader/DESCR
new file mode 100644
index 0000000000..bbd51887dd
--- /dev/null
+++ b/swiftshader/DESCR
@@ -0,0 +1,3 @@
+SwiftShader is a high-performance CPU-based implementation
+of the Vulkan graphics API. Its goal is to provide hardware
+independence for advanced 3D graphics.
diff --git a/swiftshader/Makefile b/swiftshader/Makefile
new file mode 100644
index 0000000000..b39acd8911
--- /dev/null
+++ b/swiftshader/Makefile
@@ -0,0 +1,61 @@
+# $NetBSD$
+
+DISTNAME=	swiftshader-20251119
+CATEGORIES=	graphics
+MASTER_SITES=	${MASTER_SITE_GITHUB:=google/}
+GITHUB_TAG=	d7bc95730bdda6c88b45c00b1bfece8a5cd99ea5
+
+DISTFILES+=	${DISTNAME}-${GITHUB_TAG}${EXTRACT_SUFX}
+
+#CPPDAP_VER=	1fd23dda91e01550be1a421de307e6fedb2035a9
+#GTEST_VER=	e2239ee6043f73722e7aa812a459f54a28552929
+#NJSON_VER=	ed5541440a36bf7dc1a544f9a84fa3e5ae97b71f
+#LIBBT_VER=	5a99ff7fed66b8ea8f09c9805c138524a7035ece
+#NSDK_VER=	409c9d54fdaffe68565283e38dcbbe6c58535925
+#BENCHM_VER=	dfc8a92abc88a9d630a9f8e01c678fedde4c3090
+#GLSLANG_VER=	2b2523fb951f63f072cfba514c26f2feea5f4329
+
+#GITHUB_SUBMODULES=	google cppdap ${CPPDAP_VER} third_party/cppdap
+#GITHUB_SUBMODULES+=	google googletest ${GTEST_VER} third_party/googletest
+#GITHUB_SUBMODULES+=	nlohmann json ${NJSON_VER} third_party/json
+#GITHUB_SUBMODULES+=	ianlancetaylor libbacktrace ${LIBBT_VER} third_party/libbacktrace/src
+#GITHUB_SUBMODULES+=	powervr-graphics Native_SDK ${NSDK_VER} third_party/PowerVR_Examples
+#GITHUB_SUBMODULES+=	google benchmark ${BENCHM_VER} third_party/benchmark
+#GITHUB_SUBMODULES+=	KhronosGroup glslang ${GLSLANG_VER} third_party/glslang
+
+MAINTAINER=	kikadf.01%gmail.com@localhost
+HOMEPAGE=	https://swiftshader.googlesource.com/SwiftShader
+COMMENT=	High-performance CPU-based implementation of the Vulkan graphics API
+LICENSE=	apache-2.0
+
+USE_LANGUAGES=	c c++
+WRKSRC=		${WRKDIR}/swiftshader-${GITHUB_TAG}
+
+SUBST_CLASSES+=		path
+SUBST_STAGE.path=	pre-configure
+SUBST_MESSAGE.path=	Fixing pathes
+SUBST_FILES.path+=	src/Vulkan/CMakeLists.txt
+SUBST_VARS.path+=	PREFIX
+
+# To use ninja
+CMAKE_GENERATORS_INCOMPATIBLE=	make
+CMAKE_CONFIGURE_ARGS+=		-DCMAKE_BUILD_TYPE=Release
+CMAKE_CONFIGURE_ARGS+=		-DCMAKE_POLICY_VERSION_MINIMUM=3.5
+CMAKE_CONFIGURE_ARGS+=		-DSWIFTSHADER_WARNINGS_AS_ERRORS=false
+CMAKE_CONFIGURE_ARGS+=		-DSWIFTSHADER_BUILD_TESTS=false
+
+INSTALLATION_DIRS+=	lib
+INSTALLATION_DIRS+=	share/vulkan/icd.d
+
+.include "../../mk/bsd.prefs.mk"
+
+do-install:
+	${INSTALL_LIB} ${WRKSRC}/${CMAKE_BUILD_DIR}/${OPSYS}/libvk_swiftshader.so \
+		${DESTDIR}${PREFIX}/lib
+	${INSTALL_DATA} ${WRKSRC}/${CMAKE_BUILD_DIR}/${OPSYS}/vk_swiftshader_icd.json \
+		${DESTDIR}${PREFIX}/share/vulkan/icd.d
+
+.include "../../mk/dlopen.buildlink3.mk"
+BUILDLINK_TRANSFORM+=	opt:-ldl:${BUILDLINK_LDADD.dl:Q}
+.include "../../devel/cmake/build.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/swiftshader/PLIST b/swiftshader/PLIST
new file mode 100644
index 0000000000..7f48b02acc
--- /dev/null
+++ b/swiftshader/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD$
+lib/libvk_swiftshader.so
+share/vulkan/icd.d/vk_swiftshader_icd.json
diff --git a/swiftshader/distinfo b/swiftshader/distinfo
new file mode 100644
index 0000000000..438b6be64a
--- /dev/null
+++ b/swiftshader/distinfo
@@ -0,0 +1,38 @@
+$NetBSD$
+
+BLAKE2s (KhronosGroup-glslang-2b2523fb951f63f072cfba514c26f2feea5f4329.tar.gz) = dabd3ff6efe0def092fc137ea5bb7128a8672190dac27f6ab554cdf04a60eec8
+SHA512 (KhronosGroup-glslang-2b2523fb951f63f072cfba514c26f2feea5f4329.tar.gz) = 6ffac5302b175a15faaac10408c27ad8cd9e58a795e5786d6fdad0badcf8d7113db9b52c6fc4af76617d308da9d61adfe5b9542b2f52053db64cd58a8deeb57f
+Size (KhronosGroup-glslang-2b2523fb951f63f072cfba514c26f2feea5f4329.tar.gz) = 3662063 bytes
+BLAKE2s (google-benchmark-dfc8a92abc88a9d630a9f8e01c678fedde4c3090.tar.gz) = 34c88875d3d023c1a09e8745bf4a63dc5252b4adceecfb37555ad14d25eb3ab7
+SHA512 (google-benchmark-dfc8a92abc88a9d630a9f8e01c678fedde4c3090.tar.gz) = d0b6af2b3673053cd4faa90d0d086b0b8cfb3aba5b49a82b219d92773668a4e40353b3cfe7ccbf3e572082761765fd075de3adad2fbc9f9c79518a075c4a4180
+Size (google-benchmark-dfc8a92abc88a9d630a9f8e01c678fedde4c3090.tar.gz) = 250231 bytes
+BLAKE2s (google-cppdap-1fd23dda91e01550be1a421de307e6fedb2035a9.tar.gz) = 26f1c526d172e296fa7dfb9515723d97088ee0580ea2086f7e24bd7172030f02
+SHA512 (google-cppdap-1fd23dda91e01550be1a421de307e6fedb2035a9.tar.gz) = dcdcf25696d76f876395a41d010d4a0d846072ad19f0151e90ff53b2edb5ae2e7f34bf3f6712b65072658fe3b84530b816bf640a5ff2b24af0d79d948347f28b
+Size (google-cppdap-1fd23dda91e01550be1a421de307e6fedb2035a9.tar.gz) = 77131 bytes
+BLAKE2s (google-googletest-e2239ee6043f73722e7aa812a459f54a28552929.tar.gz) = 11ab61e24f977f6f0362c041680b277503ee476da4624d8a164ff951ca835ba7
+SHA512 (google-googletest-e2239ee6043f73722e7aa812a459f54a28552929.tar.gz) = cf9e7f3fd3e31ce6677eac355fb8bfe19c5b56a8ec3af8b9417d0904cdf5da92f99f7411a08131cc9fa4fc7d38e6a71fcfac993648e47b269a74a27de7607f7a
+Size (google-googletest-e2239ee6043f73722e7aa812a459f54a28552929.tar.gz) = 887296 bytes
+BLAKE2s (ianlancetaylor-libbacktrace-5a99ff7fed66b8ea8f09c9805c138524a7035ece.tar.gz) = d0f929300c5416717b3a0433699c44b35e7660b4375ee1221e4477710cba59b4
+SHA512 (ianlancetaylor-libbacktrace-5a99ff7fed66b8ea8f09c9805c138524a7035ece.tar.gz) = e168600b674a1a9bc44bd75d0187a152331bb72cd933b0d52af5a61a22cf2457cab6ae774c547a3a24d342c76146ede34bf41378e6168c544db298bdcdfce22a
+Size (ianlancetaylor-libbacktrace-5a99ff7fed66b8ea8f09c9805c138524a7035ece.tar.gz) = 509600 bytes
+BLAKE2s (nlohmann-json-ed5541440a36bf7dc1a544f9a84fa3e5ae97b71f.tar.gz) = f93fa894dcdd17bcd0e455ebed7c37ca0446045c467287e3dafc41d4970e543a
+SHA512 (nlohmann-json-ed5541440a36bf7dc1a544f9a84fa3e5ae97b71f.tar.gz) = d03140c32667909a03e1447a80d1937eef4ee0806528518d890edc5e3678c21a052918f3580be7854aa5b1f7b7e4eff73eb7cee972a7d4fc7ee68dc5be3dea4e
+Size (nlohmann-json-ed5541440a36bf7dc1a544f9a84fa3e5ae97b71f.tar.gz) = 118990514 bytes
+BLAKE2s (powervr-graphics-Native_SDK-409c9d54fdaffe68565283e38dcbbe6c58535925.tar.gz) = 0bbb87030322e5f8b1a5436aaa2bb524e5ec0b21a7c96bd6e5fa8cd5318c2ee5
+SHA512 (powervr-graphics-Native_SDK-409c9d54fdaffe68565283e38dcbbe6c58535925.tar.gz) = 8ab471450ea490965e196c788fd7092c1f7087caee718225891704ecf4b9637c96511018b79051aeea14652d4fb26301ee70ac5b8723b1d9339ced1380688236
+Size (powervr-graphics-Native_SDK-409c9d54fdaffe68565283e38dcbbe6c58535925.tar.gz) = 296095047 bytes
+BLAKE2s (swiftshader-20251119-d7bc95730bdda6c88b45c00b1bfece8a5cd99ea5.tar.gz) = 81b6f2e68d5e7014d89309ec44a59e7acf7e4830c3f6690e1e53dec0f6f26e24
+SHA512 (swiftshader-20251119-d7bc95730bdda6c88b45c00b1bfece8a5cd99ea5.tar.gz) = fd921a84bb2886428c01dc34e378bb440040920799bba9e9bd770d6c8d6308ab2f0c4b83b3f89fbbe4d0bb869dbff1963614f83329ec9eedd760bce7017d0442
+Size (swiftshader-20251119-d7bc95730bdda6c88b45c00b1bfece8a5cd99ea5.tar.gz) = 99114919 bytes
+SHA1 (patch-CMakeLists.txt) = 249d4a39306750e4fde1b0fec830f47fb146a362
+SHA1 (patch-src_Reactor_Debug.cpp) = 025e6dd2a8ffac25483e76784a76adcbee754e96
+SHA1 (patch-src_System_Configurator.cpp) = dc4a3b371638560baaeee4ced33495e2f6edbc24
+SHA1 (patch-src_System_Linux_MemFd.cpp) = 9ed4c6c879cc0b79f950e4fd8fa811d6a98f2b02
+SHA1 (patch-src_Vulkan_CMakeLists.txt) = 4e22a65f84ffd2b64cf71a73ff0940b10d6345f1
+SHA1 (patch-src_Vulkan_VkSemaphoreExternalLinux.hpp) = a234a2a9c5dad37eb2c7a595b5e0ae7c22d58a70
+SHA1 (patch-src_WSI_libXCB.cpp) = caf8a549eb70ac0ab37c63bec8ad2fea7f56211d
+SHA1 (patch-third__party_llvm-10.0_CMakeLists.txt) = 3b6c216ef2d7de4da9fa9d0f990e70d0124aa663
+SHA1 (patch-third__party_llvm-10.0_configs_linux_include_llvm_Config_config.h) = 15fb9fe9d6805ceb241ddd63fd40fe49549922fb
+SHA1 (patch-third__party_llvm-subzero_build_Linux_include_llvm_Config_config.h) = 95d78da586b99481e076689fd6bd111522cc6417
+SHA1 (patch-third__party_marl_src_memory.cpp) = b1948b3a49a16253c8dddb498de151d25dd25114
+SHA1 (patch-third__party_marl_src_thread.cpp) = 48b4e539ce12660b22e6d1d7ea7e1f6c3da15e9a
diff --git a/swiftshader/patches/patch-CMakeLists.txt b/swiftshader/patches/patch-CMakeLists.txt
new file mode 100644
index 0000000000..a198d14c60
--- /dev/null
+++ b/swiftshader/patches/patch-CMakeLists.txt
@@ -0,0 +1,15 @@
+$NetBSD$
+
+* Add NetBSD support
+
+--- CMakeLists.txt.orig	2025-11-19 18:07:41.038317875 +0000
++++ CMakeLists.txt
+@@ -27,7 +27,7 @@ endif()
+ # Detect system
+ ###########################################################
+ 
+-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
++if(CMAKE_SYSTEM_NAME MATCHES "Linux|NetBSD")
+     set(LINUX TRUE)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+     set(ANDROID TRUE)
diff --git a/swiftshader/patches/patch-src_Reactor_Debug.cpp b/swiftshader/patches/patch-src_Reactor_Debug.cpp
new file mode 100644
index 0000000000..7e7bb3dbfd
--- /dev/null
+++ b/swiftshader/patches/patch-src_Reactor_Debug.cpp
@@ -0,0 +1,16 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- src/Reactor/Debug.cpp.orig	2025-11-19 17:24:16.492389802 +0000
++++ src/Reactor/Debug.cpp
+@@ -46,7 +46,8 @@ namespace {
+ 
+ bool IsUnderDebugger()
+ {
+-#if defined(PTRACE) && !defined(__APPLE__) && !defined(__MACH__)
++#if defined(PTRACE) && !defined(__APPLE__) && !defined(__MACH__)&& !defined(__OpenBSD__) && !defined(__FreeBSD__) && \
++    !defined(__NetBSD__)
+ 	static bool checked = false;
+ 	static bool res = false;
+ 
diff --git a/swiftshader/patches/patch-src_System_Configurator.cpp b/swiftshader/patches/patch-src_System_Configurator.cpp
new file mode 100644
index 0000000000..ce02987b3e
--- /dev/null
+++ b/swiftshader/patches/patch-src_System_Configurator.cpp
@@ -0,0 +1,16 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- src/System/Configurator.cpp.orig	2025-11-19 17:47:26.155139655 +0000
++++ src/System/Configurator.cpp
+@@ -38,6 +38,9 @@ namespace sw {
+ 
+ Configurator::Configurator(const std::string &filePath)
+ {
++#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
++	return;
++#endif
+ 	std::fstream file(filePath, std::ios::in);
+ 	if(file.fail())
+ 	{
diff --git a/swiftshader/patches/patch-src_System_Linux_MemFd.cpp b/swiftshader/patches/patch-src_System_Linux_MemFd.cpp
new file mode 100644
index 0000000000..84b7ac1148
--- /dev/null
+++ b/swiftshader/patches/patch-src_System_Linux_MemFd.cpp
@@ -0,0 +1,41 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- src/System/Linux/MemFd.cpp.orig	2025-11-19 17:30:21.163918341 +0000
++++ src/System/Linux/MemFd.cpp
+@@ -25,6 +25,7 @@
+ #	define MFD_CLOEXEC 0x0001U
+ #endif
+ 
++#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
+ #if __aarch64__
+ #	define __NR_memfd_create 279
+ #elif __arm__
+@@ -36,6 +37,7 @@
+ #elif __x86_64__
+ #	define __NR_memfd_create 319
+ #endif /* __NR_memfd_create__ */
++#endif
+ 
+ LinuxMemFd::~LinuxMemFd()
+ {
+@@ -63,13 +65,17 @@ bool LinuxMemFd::allocate(const char *na
+ {
+ 	close();
+ 
+-#ifndef __NR_memfd_create
++#if !defined(__NR_memfd_create) || defined(__OpenBSD__)
+ 	TRACE("memfd_create() not supported on this system!");
+ 	return false;
+ #else
+ 	// In the event of no system call this returns -1 with errno set
+ 	// as ENOSYS.
++#if defined(__FreeBSD__) ||  defined(__NetBSD__)
++	fd_ = memfd_create(name, MFD_CLOEXEC);
++#else
+ 	fd_ = syscall(__NR_memfd_create, name, MFD_CLOEXEC);
++#endif
+ 	if(fd_ < 0)
+ 	{
+ 		TRACE("memfd_create() returned %d: %s", errno, strerror(errno));
diff --git a/swiftshader/patches/patch-src_Vulkan_CMakeLists.txt b/swiftshader/patches/patch-src_Vulkan_CMakeLists.txt
new file mode 100644
index 0000000000..4853ea6c5f
--- /dev/null
+++ b/swiftshader/patches/patch-src_Vulkan_CMakeLists.txt
@@ -0,0 +1,15 @@
+$NetBSD$
+
+* Fix lib path in the icd.json file
+
+--- src/Vulkan/CMakeLists.txt.orig	2025-11-20 15:17:35.162469765 +0000
++++ src/Vulkan/CMakeLists.txt
+@@ -252,7 +252,7 @@ if(WIN32)
+     # The path is output to a JSON file, which requires backslashes to be escaped.
+     set(ICD_LIBRARY_PATH ".\\\\${ICD_LIBRARY_PATH}")
+ else()
+-    set(ICD_LIBRARY_PATH "./${ICD_LIBRARY_PATH}")
++    set(ICD_LIBRARY_PATH "@PREFIX@/lib/${ICD_LIBRARY_PATH}")
+ endif()
+ configure_file(
+     "vk_swiftshader_icd.json.tmpl"
diff --git a/swiftshader/patches/patch-src_Vulkan_VkSemaphoreExternalLinux.hpp b/swiftshader/patches/patch-src_Vulkan_VkSemaphoreExternalLinux.hpp
new file mode 100644
index 0000000000..59b31b49bd
--- /dev/null
+++ b/swiftshader/patches/patch-src_Vulkan_VkSemaphoreExternalLinux.hpp
@@ -0,0 +1,24 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- src/Vulkan/VkSemaphoreExternalLinux.hpp.orig	2025-11-19 17:28:04.673283748 +0000
++++ src/Vulkan/VkSemaphoreExternalLinux.hpp
+@@ -50,13 +50,17 @@ public:
+ 	{
+ 		pthread_mutexattr_t mattr;
+ 		pthread_mutexattr_init(&mattr);
++#if 0
+ 		pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
++#endif
+ 		pthread_mutex_init(&mutex, &mattr);
+ 		pthread_mutexattr_destroy(&mattr);
+ 
+ 		pthread_condattr_t cattr;
+ 		pthread_condattr_init(&cattr);
++#if 0
+ 		pthread_condattr_setpshared(&cattr, PTHREAD_PROCESS_SHARED);
++#endif
+ 		pthread_cond_init(&cond, &cattr);
+ 		pthread_condattr_destroy(&cattr);
+ 	}
diff --git a/swiftshader/patches/patch-src_WSI_libXCB.cpp b/swiftshader/patches/patch-src_WSI_libXCB.cpp
new file mode 100644
index 0000000000..f04c279142
--- /dev/null
+++ b/swiftshader/patches/patch-src_WSI_libXCB.cpp
@@ -0,0 +1,24 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- src/WSI/libXCB.cpp.orig	2025-11-19 17:10:14.033018166 +0000
++++ src/WSI/libXCB.cpp
+@@ -57,7 +57,7 @@ LibXcbExports *LibXCB::loadExports()
+ 		}
+ 		else
+ 		{
+-			libxcb = loadLibrary("libxcb.so.1");
++			libxcb = loadLibrary("libxcb.so");
+ 		}
+ 
+ 		if(getProcAddress(RTLD_DEFAULT, "xcb_shm_query_version"))  // Search the global scope for pre-loaded XCB library.
+@@ -66,7 +66,7 @@ LibXcbExports *LibXCB::loadExports()
+ 		}
+ 		else
+ 		{
+-			libshm = loadLibrary("libxcb-shm.so.0");
++			libshm = loadLibrary("libxcb-shm.so");
+ 		}
+ 
+ 		return LibXcbExports(libxcb, libshm);
diff --git a/swiftshader/patches/patch-third__party_llvm-10.0_CMakeLists.txt b/swiftshader/patches/patch-third__party_llvm-10.0_CMakeLists.txt
new file mode 100644
index 0000000000..568858e75a
--- /dev/null
+++ b/swiftshader/patches/patch-third__party_llvm-10.0_CMakeLists.txt
@@ -0,0 +1,16 @@
+$NetBSD$
+
+* Fix link:
+undefined reference to llvm::sys::CompareAndSwap(unsigned int volatile*, unsigned int, unsigned int)' 
+undefined reference to llvm::sys::MemoryFence()' 
+
+--- third_party/llvm-10.0/CMakeLists.txt.orig	2025-11-20 13:42:02.031324847 +0000
++++ third_party/llvm-10.0/CMakeLists.txt
+@@ -563,6 +563,7 @@ set(LLVM_LIST
+     ${LLVM_DIR}/lib/Support/ABIBreak.cpp
+     ${LLVM_DIR}/lib/Support/APFloat.cpp
+     ${LLVM_DIR}/lib/Support/APInt.cpp
++    ${LLVM_DIR}/lib/Support/Atomic.cpp
+     ${LLVM_DIR}/lib/Support/ARMAttributeParser.cpp
+     ${LLVM_DIR}/lib/Support/ARMBuildAttrs.cpp
+     ${LLVM_DIR}/lib/Support/ARMTargetParser.cpp
diff --git a/swiftshader/patches/patch-third__party_llvm-10.0_configs_linux_include_llvm_Config_config.h b/swiftshader/patches/patch-third__party_llvm-10.0_configs_linux_include_llvm_Config_config.h
new file mode 100644
index 0000000000..ac3939743f
--- /dev/null
+++ b/swiftshader/patches/patch-third__party_llvm-10.0_configs_linux_include_llvm_Config_config.h
@@ -0,0 +1,154 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h.orig	2025-11-19 17:12:15.677207316 +0000
++++ third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h
+@@ -29,7 +29,7 @@
+ 
+ /* Define to 1 if you have the declaration of `arc4random', and to 0 if you
+    don't. */
+-#define HAVE_DECL_ARC4RANDOM 0
++#define HAVE_DECL_ARC4RANDOM 1
+ 
+ /* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you
+    don't. */
+@@ -53,7 +53,7 @@
+ #define HAVE_DLOPEN 1
+ 
+ /* Define if dladdr() is available on this platform. */
+-/* #undef HAVE_DLADDR */
++#define HAVE_DLADDR 1
+ 
+ /* Define to 1 if you have the <errno.h> header file. */
+ #define HAVE_ERRNO_H 1
+@@ -92,7 +92,7 @@
+ #define HAVE_ISATTY 1
+ 
+ /* Define to 1 if you have the `edit' library (-ledit). */
+-/* #undef HAVE_LIBEDIT */
++#define HAVE_LIBEDIT 1
+ 
+ /* Define to 1 if you have the `pfm' library (-lpfm). */
+ /* #undef HAVE_LIBPFM */
+@@ -110,13 +110,13 @@
+ /* #undef HAVE_PTHREAD_SETNAME_NP */
+ 
+ /* Define to 1 if you have the `z' library (-lz). */
+-/* #undef HAVE_LIBZ */
++#define HAVE_LIBZ 1
+ 
+ /* Define to 1 if you have the <link.h> header file. */
+-#define HAVE_LINK_H 1
++/* #undef HAVE_LINK_H */
+ 
+ /* Define to 1 if you have the `lseek64' function. */
+-#define HAVE_LSEEK64 1
++/* #undef HAVE_LSEEK64 */
+ 
+ /* Define to 1 if you have the <mach/mach.h> header file. */
+ /* #undef HAVE_MACH_MACH_H */
+@@ -125,7 +125,7 @@
+ /* #undef HAVE_MALLCTL */
+ 
+ /* Define to 1 if you have the `mallinfo' function. */
+-#define HAVE_MALLINFO 1
++/* #undef HAVE_MALLINFO */
+ 
+ /* Define to 1 if you have the <malloc/malloc.h> header file. */
+ /* #undef HAVE_MALLOC_MALLOC_H */
+@@ -134,10 +134,10 @@
+ /* #undef HAVE_MALLOC_ZONE_STATISTICS */
+ 
+ /* Define to 1 if you have the `posix_fallocate' function. */
+-#define HAVE_POSIX_FALLOCATE 1
++/* #undef HAVE_POSIX_FALLOCATE */
+ 
+ /* Define to 1 if you have the `posix_spawn' function. */
+-/* #undef HAVE_POSIX_SPAWN */
++#define HAVE_POSIX_SPAWN 1
+ 
+ /* Define to 1 if you have the `pread' function. */
+ #define HAVE_PREAD 1
+@@ -161,10 +161,10 @@
+ #define HAVE_SETENV 1
+ 
+ /* Define to 1 if you have the `sched_getaffinity' function. */
+-#define HAVE_SCHED_GETAFFINITY 1
++/* #undef HAVE_SCHED_GETAFFINITY */
+ 
+ /* Define to 1 if you have the `CPU_COUNT' macro. */
+-#define HAVE_CPU_COUNT 1
++/* #undef HAVE_CPU_COUNT */
+ 
+ /* Define to 1 if you have the `setrlimit' function. */
+ #define HAVE_SETRLIMIT 1
+@@ -182,7 +182,7 @@
+ #define HAVE_STRERROR_R 1
+ 
+ /* Define to 1 if you have the `sysconf' function. */
+-#define HAVE_SYSCONF 1
++/* #undef HAVE_SYSCONF */
+ 
+ /* Define to 1 if you have the <sys/ioctl.h> header file. */
+ #define HAVE_SYS_IOCTL_H 1
+@@ -209,7 +209,7 @@
+ #define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
+ 
+ /* Define to 1 if you have the <sys/types.h> header file. */
+-#define HAVE_SYS_TYPES_H 1
++/* #undef HAVE_SYS_TYPES_H */
+ 
+ /* Define if the setupterm() function is supported this platform. */
+ /* #undef HAVE_TERMINFO */
+@@ -227,7 +227,7 @@
+ /* #undef HAVE_VALGRIND_VALGRIND_H */
+ 
+ /* Define to 1 if you have the <zlib.h> header file. */
+-/* #undef HAVE_ZLIB_H */
++#define HAVE_ZLIB_H 1
+ 
+ /* Have host's _alloca */
+ /* #undef HAVE__ALLOCA */
+@@ -292,30 +292,8 @@
+ /* Linker version detected at compile time. */
+ /* #undef HOST_LINK_VERSION */
+ 
+-/* Target triple LLVM will generate code for by default */
+-/* Doesn't use `cmakedefine` because it is allowed to be empty. */
+-#if defined(__x86_64__)
+-#define LLVM_DEFAULT_TARGET_TRIPLE "x86_64-unknown-linux-gnu"
+-#elif defined(__i386__)
+-#define LLVM_DEFAULT_TARGET_TRIPLE "i686-pc-linux-gnu"
+-#elif defined(__arm__)
+-#define LLVM_DEFAULT_TARGET_TRIPLE "armv7-linux-gnueabihf"
+-#elif defined(__aarch64__)
+-#define LLVM_DEFAULT_TARGET_TRIPLE "aarch64-linux-gnu"
+-#elif defined(__mips__)
+-#define LLVM_DEFAULT_TARGET_TRIPLE "mipsel-linux-gnu"
+-#elif defined(__mips64)
+-#define LLVM_DEFAULT_TARGET_TRIPLE "mips64el-linux-gnuabi64"
+-#elif defined(__powerpc64__)
+-#define LLVM_DEFAULT_TARGET_TRIPLE "powerpc64le-unknown-linux-gnu"
+-#elif defined(__riscv) && __riscv_xlen == 64
+-#define LLVM_DEFAULT_TARGET_TRIPLE "riscv64-unknown-linux-gnu"
+-#else
+-#error "unknown architecture"
+-#endif
+-
+ /* Define if zlib compression is available */
+-#define LLVM_ENABLE_ZLIB 0
++/* #undef LLVM_ENABLE_ZLIB */
+ 
+ /* Define if overriding target triple is enabled */
+ /* #undef LLVM_TARGET_TRIPLE_ENV */
+@@ -362,9 +340,6 @@
+ /* Whether GlobalISel rule coverage is being collected */
+ #define LLVM_GISEL_COV_ENABLED 0
+ 
+-/* Define if we have z3 and want to build it */
+-#define LLVM_WITH_Z3 1
+-
+ /* Define to the default GlobalISel coverage file prefix */
+ /* #undef LLVM_GISEL_COV_PREFIX */
+ 
diff --git a/swiftshader/patches/patch-third__party_llvm-subzero_build_Linux_include_llvm_Config_config.h b/swiftshader/patches/patch-third__party_llvm-subzero_build_Linux_include_llvm_Config_config.h
new file mode 100644
index 0000000000..ac99a5a406
--- /dev/null
+++ b/swiftshader/patches/patch-third__party_llvm-subzero_build_Linux_include_llvm_Config_config.h
@@ -0,0 +1,51 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h.orig	2025-11-19 17:43:16.724253275 +0000
++++ third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
+@@ -5,7 +5,7 @@
+ #include "llvm/Config/llvm-config.h"
+ 
+ /* For detecting __GLIBC__ usage */
+-#include <features.h>
++//#include <features.h>
+ 
+ /* Bug report URL. */
+ #define BUG_REPORT_URL "http://llvm.org/bugs/";
+@@ -27,7 +27,7 @@
+ 
+ /* Define to 1 if you have the declaration of `arc4random', and to 0 if you
+    don't. */
+-#define HAVE_DECL_ARC4RANDOM 0
++#define HAVE_DECL_ARC4RANDOM 1
+ 
+ /* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you
+    don't. */
+@@ -124,7 +124,7 @@
+ #define HAVE_LINK_H 1
+ 
+ /* Define to 1 if you have the `lseek64' function. */
+-#define HAVE_LSEEK64 1
++/* #define HAVE_LSEEK64 1 */
+ 
+ /* Define to 1 if you have the <mach/mach.h> header file. */
+ /* #undef HAVE_MACH_MACH_H */
+@@ -133,7 +133,7 @@
+ /* #undef HAVE_MALLCTL */
+ 
+ /* Define to 1 if you have the `mallinfo' function. */
+-#define HAVE_MALLINFO 1
++/* #define HAVE_MALLINFO 1 */
+ 
+ /* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
+ /* so we need to check glibc version for the new API to be safe */
+@@ -163,7 +163,7 @@
+ /* #undef HAVE_NDIR_H */
+ 
+ /* Define to 1 if you have the `posix_fallocate' function. */
+-#define HAVE_POSIX_FALLOCATE 1
++/* #define HAVE_POSIX_FALLOCATE 1 */
+ 
+ /* Define to 1 if you have the `posix_spawn' function. */
+ #define HAVE_POSIX_SPAWN 1
diff --git a/swiftshader/patches/patch-third__party_marl_src_memory.cpp b/swiftshader/patches/patch-third__party_marl_src_memory.cpp
new file mode 100644
index 0000000000..38c756f66f
--- /dev/null
+++ b/swiftshader/patches/patch-third__party_marl_src_memory.cpp
@@ -0,0 +1,16 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- third_party/marl/src/memory.cpp.orig	2025-11-19 17:33:29.579484646 +0000
++++ third_party/marl/src/memory.cpp
+@@ -19,7 +19,8 @@
+ 
+ #include <cstring>
+ 
+-#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__EMSCRIPTEN__)
++#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__OpenBSD__) || \
++    defined(__NetBSD__)
+ #include <sys/mman.h>
+ #include <unistd.h>
+ namespace {
diff --git a/swiftshader/patches/patch-third__party_marl_src_thread.cpp b/swiftshader/patches/patch-third__party_marl_src_thread.cpp
new file mode 100644
index 0000000000..e4b001f4ad
--- /dev/null
+++ b/swiftshader/patches/patch-third__party_marl_src_thread.cpp
@@ -0,0 +1,25 @@
+$NetBSD$
+
+* Import patch from chromium
+
+--- third_party/marl/src/thread.cpp.orig	2025-11-19 17:20:56.859996246 +0000
++++ third_party/marl/src/thread.cpp
+@@ -45,6 +45,9 @@
+ #include <pthread.h>
+ #include <unistd.h>
+ #include <thread>
++#if defined(__NetBSD__)
++#include <stdarg.h>
++#endif
+ #endif
+ 
+ namespace {
+@@ -444,6 +447,8 @@ void Thread::setName(const char* fmt, ..
+   pthread_setname_np(name);
+ #elif defined(__FreeBSD__)
+   pthread_set_name_np(pthread_self(), name);
++#elif defined(__NetBSD__)
++  pthread_setname_np(pthread_self(), "%s", (void *)name);
+ #elif !defined(__Fuchsia__) && !defined(__EMSCRIPTEN__)
+   pthread_setname_np(pthread_self(), name);
+ #endif


Home | Main Index | Thread Index | Old Index