From 4b30f93762bc63fd4e729076e8c18e652864d7a7 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 12 Jan 2021 19:01:04 +0000 Subject: [PATCH] Add the correct rpath to use Swiftshader / Vulkan on macOS Previously the @executable_path rpath was only added when doing component builds and non-component builds failed to find Vulkan and Swiftshader on macOS. Bug: None Change-Id: I0277566e4bf181703dff26bb1bf3e57858864009 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37442 Commit-Queue: Corentin Wallez Commit-Queue: Austin Eng Auto-Submit: Corentin Wallez Reviewed-by: Stephen White Reviewed-by: Austin Eng --- src/dawn_native/BUILD.gn | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dawn_native/BUILD.gn b/src/dawn_native/BUILD.gn index f39643326a..b98708c69d 100644 --- a/src/dawn_native/BUILD.gn +++ b/src/dawn_native/BUILD.gn @@ -77,6 +77,17 @@ config("dawn_native_weak_framework") { } } +# Config that adds the @executable_path rpath if needed so that Swiftshader or the Vulkan loader are found. +config("dawn_native_vulkan_rpath") { + if (is_mac && dawn_enable_vulkan && + (use_swiftshader || enable_vulkan_loader)) { + ldflags = [ + "-rpath", + "@executable_path/", + ] + } +} + dawn_json_generator("dawn_native_utils_gen") { target = "dawn_native_utils" outputs = [ @@ -633,7 +644,10 @@ dawn_component("dawn_native") { ] sources = [ "DawnNative.cpp" ] configs = [ ":dawn_native_internal" ] - public_configs = [ ":dawn_native_weak_framework" ] + public_configs = [ + ":dawn_native_weak_framework", + ":dawn_native_vulkan_rpath", + ] if (dawn_enable_d3d12) { sources += [ "d3d12/D3D12Backend.cpp" ]