commit 470381d40e6804b9c5de13556c9e60a6b9685a89 from: shrub date: Tue Mar 31 12:29:36 2026 UTC orcjit + stop dlopening commit - ac9b16a522f0c2fb288fd3c55d10b58f95f7be84 commit + 470381d40e6804b9c5de13556c9e60a6b9685a89 blob - ec37b14710614e0f31d454727768b4533db211e9 blob + 1583df7c5ad89ffbbc1674d99a20661f1f47555e --- lib/mesa/0001-static-lavapipe.patch +++ lib/mesa/0001-static-lavapipe.patch @@ -1,5 +1,5 @@ diff --git a/meson.build b/meson.build -index 5eaae977f67..f9023c9b402 100644 +index 5eaae97..f9023c9 100644 --- a/meson.build +++ b/meson.build @@ -1928,8 +1928,7 @@ if dep_llvm.found() @@ -48,21 +48,48 @@ index 5eaae977f67..f9023c9b402 100644 endif # Even if we find OpenMP, Gitlab CI fails to link with gcc/i386 and clang/anyarch. -diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c -index 6bd9f58a1d1..c09dd709eb4 100644 ---- a/src/gallium/auxiliary/draw/draw_context.c -+++ b/src/gallium/auxiliary/draw/draw_context.c -@@ -57,7 +57,7 @@ bool - draw_get_option_use_llvm(void) - { - #if DRAW_LLVM_AVAILABLE -- return debug_get_bool_option("DRAW_USE_LLVM", true); -+ return debug_get_bool_option("DRAW_USE_LLVM", false); - #else - return false; - #endif +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp +index 16357fb..0e1f520 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp ++++ b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp +@@ -320,6 +320,26 @@ LLVMErrorRef module_transform_wrapper( + return LLVMOrcThreadSafeModuleWithModuleDo(*ModInOut, *module_transform, Ctx); + } + ++static llvm::Expected ++lpjit_create_static_process_symbols_jd(llvm::orc::LLJIT &J) ++{ ++ using llvm::orc::JITDylibSP; ++ ++ auto &ES = J.getExecutionSession(); ++ auto &JD = ES.createBareJITDylib("process_symbols"); ++ ++ /* ok, so lljit normally wires the process-symbols jitdylib to a ++ * DynamicLibrarySearchGenerator, which resolves the symbold through dlopen(NULL) ++ * for static we still need the process symbols jitdylib itself ++ * but we need definitions to come from explicit add_mapping_to_jd() ++ * calls instead of the host process loader ++ * ++ * this might mean we have to defin some external symbols in the future, ++ * if some new helper is called, and no one maps it ++ */ ++ return JITDylibSP(&JD); ++} ++ + LPJit::LPJit() :jit_dylib_count(0) { + using namespace llvm::orc; + +@@ -337,6 +357,8 @@ LPJit::LPJit() :jit_dylib_count(0) { + lljit = ExitOnErr( + LLJITBuilder() + .setJITTargetMachineBuilder(std::move(JTMB)) ++ .setLinkProcessSymbolsByDefault(true) ++ .setProcessSymbolsJITDylibSetup(*lpjit_create_static_process_symbols_jd) + #ifdef USE_JITLINK + .setObjectLinkingLayerCreator( + #if LLVM_VERSION_MAJOR >= 21 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp -index ce8ca02bf74..5689dcfeb4a 100644 +index ce8ca02..5689dcf 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -599,6 +599,9 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, @@ -96,21 +123,8 @@ index ce8ca02bf74..5689dcfeb4a 100644 *OutError = strdup(Error.c_str()); return 1; } -diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c -index 2b71e1bfffb..4a23ff7dd05 100644 ---- a/src/gallium/drivers/llvmpipe/lp_screen.c -+++ b/src/gallium/drivers/llvmpipe/lp_screen.c -@@ -140,7 +140,7 @@ llvmpipe_init_shader_caps(struct pipe_screen *screen) - case MESA_SHADER_GEOMETRY: - draw_init_shader_caps(caps); - -- if (debug_get_bool_option("DRAW_USE_LLVM", true)) { -+ if (debug_get_bool_option("DRAW_USE_LLVM", false)) { - caps->max_const_buffers = LP_MAX_TGSI_CONST_BUFFERS; - } else { - /* At this time, the draw module and llvmpipe driver only diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c -index 187f17ccf1b..51b67409311 100644 +index 187f17c..42de27a 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -27,6 +27,7 @@ @@ -179,17 +193,7 @@ index 187f17ccf1b..51b67409311 100644 result = vk_physical_device_init(&device->vk, &instance->vk, NULL, NULL, NULL, &dispatch_table); if (result != VK_SUCCESS) { -@@ -1598,9 +1644,6 @@ static struct drisw_loader_funcs lvp_sw_lf = { - static VkResult - lvp_enumerate_physical_devices(struct vk_instance *vk_instance) - { -- if (!draw_get_option_use_llvm()) -- return VK_SUCCESS; -- - struct lvp_instance *instance = - container_of(vk_instance, struct lvp_instance, vk); - -@@ -1642,6 +1685,13 @@ lvp_device_get_cache_uuid(void *uuid) +@@ -1642,6 +1688,13 @@ lvp_device_get_cache_uuid(void *uuid) memcpy(uuid, PACKAGE_VERSION, MIN2(strlen(PACKAGE_VERSION), VK_UUID_SIZE)); } @@ -203,7 +207,7 @@ index 187f17ccf1b..51b67409311 100644 VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceQueueFamilyProperties2( VkPhysicalDevice physicalDevice, uint32_t* pCount, -@@ -1745,6 +1795,41 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL lvp_GetInstanceProcAddr( +@@ -1745,6 +1798,41 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL lvp_GetInstanceProcAddr( pName); } @@ -245,7 +249,7 @@ index 187f17ccf1b..51b67409311 100644 /* The loader wants us to expose a second GetInstanceProcAddr function * to work around certain LD_PRELOAD issues seen in apps. */ -@@ -1756,6 +1841,14 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr( +@@ -1756,6 +1844,14 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr( return lvp_GetInstanceProcAddr(instance, pName); } @@ -260,7 +264,7 @@ index 187f17ccf1b..51b67409311 100644 static void destroy_pipelines(struct lvp_queue *queue) { -@@ -1887,12 +1980,43 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice( +@@ -1887,12 +1983,43 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice( device->poison_mem = debug_get_bool_option("LVP_POISON_MEMORY", false); device->print_cmds = debug_get_bool_option("LVP_CMD_DEBUG", false); @@ -306,7 +310,7 @@ index 187f17ccf1b..51b67409311 100644 &physical_device->vk, &dispatch_table, pCreateInfo, diff --git a/src/gallium/frontends/lavapipe/lvp_wsi.c b/src/gallium/frontends/lavapipe/lvp_wsi.c -index 83e96597033..5d439a7a80f 100644 +index 83e9659..5d439a7 100644 --- a/src/gallium/frontends/lavapipe/lvp_wsi.c +++ b/src/gallium/frontends/lavapipe/lvp_wsi.c @@ -44,7 +44,7 @@ lvp_init_wsi(struct lvp_physical_device *physical_device) @@ -318,97 +322,9 @@ index 83e96597033..5d439a7a80f 100644 physical_device->vk.wsi_device = &physical_device->wsi_device; return VK_SUCCESS; -diff --git a/src/gallium/targets/lavapipe/meson.build b/src/gallium/targets/lavapipe/meson.build -index 41de1e5a0f1..8b1697f571d 100644 ---- a/src/gallium/targets/lavapipe/meson.build -+++ b/src/gallium/targets/lavapipe/meson.build -@@ -1,4 +1,48 @@ - -+static_lvp_shim = custom_target( -+ 'lvp_static_shim', -+ input : [files('lvp_static_shim_gen.py'), vk_api_xml], -+ output : 'lvp_static_shim.c', -+ command : [ -+ prog_python, '@INPUT0@', '--xml', '@INPUT1@', -+ '--out-c', '@OUTPUT@', -+ '--beta', with_vulkan_beta.to_string(), -+ ], -+ depend_files : vk_entrypoints_gen_depend_files, -+) -+ -+libvulkan_lvp_static = static_library( -+ 'vulkan_lvp_static', -+ [ 'lavapipe_target.c', static_lvp_shim ], -+ include_directories : [ inc_include, inc_src, inc_util, inc_gallium, inc_gallium_aux, inc_gallium_winsys, inc_gallium_drivers, inc_llvmpipe, include_directories('../../frontends/lavapipe') ], -+ link_whole : [ -+ liblavapipe_st, -+ libpipe_loader_static, -+ libloader, -+ _libmesa_util, -+ libmesa_util_clflush, -+ libmesa_util_clflushopt, -+ libmesa_util_simd, -+ blake3, -+ _libmesa_util_c11, -+ _libxmlconfig, -+ libgallium, -+ _libnir, -+ libcompiler, -+ libwsw, -+ libws_null, -+ libllvmpipe, -+ libvulkan_util, -+ libloader_wayland_helper, -+ libvtn, -+ ], -+ gnu_symbol_visibility : 'hidden', -+ override_options : ['b_lundef=@0@'.format(host_machine.system() == 'darwin' ? 'false' : get_option('b_lundef').to_string())], -+ dependencies : [ driver_llvmpipe, idep_mesautil, idep_nir, idep_vulkan_util, -+ idep_vulkan_wsi, idep_vulkan_runtime, lvp_deps ], -+ install : false, -+) -+ - - libvulkan_lvp = shared_library( - 'vulkan_lvp', -diff --git a/src/loader/meson.build b/src/loader/meson.build -index a8603ad5767..e070c059b8c 100644 ---- a/src/loader/meson.build -+++ b/src/loader/meson.build -@@ -4,14 +4,15 @@ - inc_loader = include_directories('.') - - if with_platform_wayland -+ wp_dir = '/usr/share/wayland-protocols' - wp_protos = { -- 'fifo-v1': mod_wl.find_protocol('fifo', state : 'staging', version : 1), -- 'commit-timing-v1': mod_wl.find_protocol('commit-timing', state : 'staging', version : 1), -- 'linux-dmabuf-unstable-v1': mod_wl.find_protocol('linux-dmabuf', state : 'unstable', version : 1), -- 'presentation-time': mod_wl.find_protocol('presentation-time'), -- 'tearing-control-v1': mod_wl.find_protocol('tearing-control', state : 'staging', version : 1), -- 'linux-drm-syncobj-v1': mod_wl.find_protocol('linux-drm-syncobj', state : 'staging', version : 1), -- 'color-management-v1': mod_wl.find_protocol('color-management', state : 'staging', version : 1) -+ 'fifo-v1': join_paths(wp_dir, 'staging', 'fifo', 'fifo-v1.xml'), -+ 'commit-timing-v1': join_paths(wp_dir, 'staging', 'commit-timing', 'commit-timing-v1.xml'), -+ 'linux-dmabuf-unstable-v1': join_paths(wp_dir, 'unstable', 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'), -+ 'presentation-time': join_paths(wp_dir, 'stable', 'presentation-time', 'presentation-time.xml'), -+ 'tearing-control-v1': join_paths(wp_dir, 'staging', 'tearing-control', 'tearing-control-v1.xml'), -+ 'linux-drm-syncobj-v1': join_paths(wp_dir, 'staging', 'linux-drm-syncobj', 'linux-drm-syncobj-v1.xml'), -+ 'color-management-v1': join_paths(wp_dir, 'staging', 'color-management', 'color-management-v1.xml') - } - wp_files = {} - foreach name, xml : wp_protos -@@ -21,7 +22,6 @@ if with_platform_wayland - libloader_wayland_helper = static_library( - 'loader_wayland_helper', - 'loader_wayland_helper.c', -- wp_files['presentation-time'], - gnu_symbol_visibility : 'hidden', - include_directories : [inc_include, inc_src, inc_gallium], - dependencies : [ diff --git a/src/gallium/targets/lavapipe/lvp_static_shim_gen.py b/src/gallium/targets/lavapipe/lvp_static_shim_gen.py new file mode 100644 -index 00000000000..1a7c6fe24c4 +index 0000000..1a7c6fe --- /dev/null +++ b/src/gallium/targets/lavapipe/lvp_static_shim_gen.py @@ -0,0 +1,172 @@ @@ -584,3 +500,91 @@ index 00000000000..1a7c6fe24c4 + +if __name__ == "__main__": + main() +diff --git a/src/gallium/targets/lavapipe/meson.build b/src/gallium/targets/lavapipe/meson.build +index 41de1e5..8b1697f 100644 +--- a/src/gallium/targets/lavapipe/meson.build ++++ b/src/gallium/targets/lavapipe/meson.build +@@ -1,4 +1,48 @@ + ++static_lvp_shim = custom_target( ++ 'lvp_static_shim', ++ input : [files('lvp_static_shim_gen.py'), vk_api_xml], ++ output : 'lvp_static_shim.c', ++ command : [ ++ prog_python, '@INPUT0@', '--xml', '@INPUT1@', ++ '--out-c', '@OUTPUT@', ++ '--beta', with_vulkan_beta.to_string(), ++ ], ++ depend_files : vk_entrypoints_gen_depend_files, ++) ++ ++libvulkan_lvp_static = static_library( ++ 'vulkan_lvp_static', ++ [ 'lavapipe_target.c', static_lvp_shim ], ++ include_directories : [ inc_include, inc_src, inc_util, inc_gallium, inc_gallium_aux, inc_gallium_winsys, inc_gallium_drivers, inc_llvmpipe, include_directories('../../frontends/lavapipe') ], ++ link_whole : [ ++ liblavapipe_st, ++ libpipe_loader_static, ++ libloader, ++ _libmesa_util, ++ libmesa_util_clflush, ++ libmesa_util_clflushopt, ++ libmesa_util_simd, ++ blake3, ++ _libmesa_util_c11, ++ _libxmlconfig, ++ libgallium, ++ _libnir, ++ libcompiler, ++ libwsw, ++ libws_null, ++ libllvmpipe, ++ libvulkan_util, ++ libloader_wayland_helper, ++ libvtn, ++ ], ++ gnu_symbol_visibility : 'hidden', ++ override_options : ['b_lundef=@0@'.format(host_machine.system() == 'darwin' ? 'false' : get_option('b_lundef').to_string())], ++ dependencies : [ driver_llvmpipe, idep_mesautil, idep_nir, idep_vulkan_util, ++ idep_vulkan_wsi, idep_vulkan_runtime, lvp_deps ], ++ install : false, ++) ++ + + libvulkan_lvp = shared_library( + 'vulkan_lvp', +diff --git a/src/loader/meson.build b/src/loader/meson.build +index a8603ad..e070c05 100644 +--- a/src/loader/meson.build ++++ b/src/loader/meson.build +@@ -4,14 +4,15 @@ + inc_loader = include_directories('.') + + if with_platform_wayland ++ wp_dir = '/usr/share/wayland-protocols' + wp_protos = { +- 'fifo-v1': mod_wl.find_protocol('fifo', state : 'staging', version : 1), +- 'commit-timing-v1': mod_wl.find_protocol('commit-timing', state : 'staging', version : 1), +- 'linux-dmabuf-unstable-v1': mod_wl.find_protocol('linux-dmabuf', state : 'unstable', version : 1), +- 'presentation-time': mod_wl.find_protocol('presentation-time'), +- 'tearing-control-v1': mod_wl.find_protocol('tearing-control', state : 'staging', version : 1), +- 'linux-drm-syncobj-v1': mod_wl.find_protocol('linux-drm-syncobj', state : 'staging', version : 1), +- 'color-management-v1': mod_wl.find_protocol('color-management', state : 'staging', version : 1) ++ 'fifo-v1': join_paths(wp_dir, 'staging', 'fifo', 'fifo-v1.xml'), ++ 'commit-timing-v1': join_paths(wp_dir, 'staging', 'commit-timing', 'commit-timing-v1.xml'), ++ 'linux-dmabuf-unstable-v1': join_paths(wp_dir, 'unstable', 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'), ++ 'presentation-time': join_paths(wp_dir, 'stable', 'presentation-time', 'presentation-time.xml'), ++ 'tearing-control-v1': join_paths(wp_dir, 'staging', 'tearing-control', 'tearing-control-v1.xml'), ++ 'linux-drm-syncobj-v1': join_paths(wp_dir, 'staging', 'linux-drm-syncobj', 'linux-drm-syncobj-v1.xml'), ++ 'color-management-v1': join_paths(wp_dir, 'staging', 'color-management', 'color-management-v1.xml') + } + wp_files = {} + foreach name, xml : wp_protos +@@ -21,7 +22,6 @@ if with_platform_wayland + libloader_wayland_helper = static_library( + 'loader_wayland_helper', + 'loader_wayland_helper.c', +- wp_files['presentation-time'], + gnu_symbol_visibility : 'hidden', + include_directories : [inc_include, inc_src, inc_gallium], + dependencies : [ blob - 5306217480cdad23f7f55989d0dfd37309eedf5b blob + 5ff3d602ebd997f39b4cfe843d17b0ed63f5fd7f --- lib/mesa/ndmake.sh +++ lib/mesa/ndmake.sh @@ -8,6 +8,7 @@ BUILD_OPT=" -Dplatforms=wayland -Dvu