radv: restrict exported symbols with static llvm
authorEmil Velikov <emil.velikov@collabora.com>
Thu, 6 Aug 2020 08:14:07 +0000 (09:14 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 19 Aug 2020 11:19:18 +0000 (11:19 +0000)
Like the gallium --version-script magic but for radv.

The long term goal is to make LLVM support optional, remove it even, so
let's keep the hunk in an if block.

v2: fold if checks (Eric)
v3 (Tomeu): Remove spaces within [] (Dylan)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6203>

src/amd/vulkan/meson.build
src/amd/vulkan/vulkan.sym [new file with mode: 0644]

index 907e45cc0e711a42e72002c7202982d12c18eea6..d1557799671194ee413e3a37249fa6050528820c 100644 (file)
@@ -148,6 +148,16 @@ if with_platform_android
   ]
 endif
 
+# When static linking LLVM, all its symbols are public API.
+# That may cause symbol collision, so explicitly demote everything.
+libvulkan_radeon_ld_args = []
+libvulkan_radeon_link_depends = []
+
+if with_llvm and with_ld_version_script
+  libvulkan_radeon_ld_args += ['-Wl,--version-script', join_paths(meson.current_source_dir(), 'vulkan.sym')]
+  libvulkan_radeon_link_depends += files('vulkan.sym')
+endif
+
 libvulkan_radeon = shared_library(
   'vulkan_radeon',
   [libradv_files, radv_entrypoints, radv_extensions_c, amd_vk_format_table_c, sha1_h],
@@ -164,7 +174,10 @@ libvulkan_radeon = shared_library(
   ],
   c_args : [no_override_init_args, radv_flags],
   cpp_args : [radv_flags],
-  link_args : [ld_args_build_id, ld_args_bsymbolic, ld_args_gc_sections],
+  link_args : [
+    ld_args_build_id, ld_args_bsymbolic, ld_args_gc_sections, libvulkan_radeon_ld_args,
+  ],
+  link_depends : [libvulkan_radeon_link_depends,],
   gnu_symbol_visibility : 'hidden',
   install : true,
 )
diff --git a/src/amd/vulkan/vulkan.sym b/src/amd/vulkan/vulkan.sym
new file mode 100644 (file)
index 0000000..c85a22e
--- /dev/null
@@ -0,0 +1,11 @@
+{
+       global:
+               vk_icdGetInstanceProcAddr;
+               vk_icdGetPhysicalDeviceProcAddr;
+               vk_icdNegotiateLoaderICDInterfaceVersion;
+
+       local:
+               # When static linking LLVM, all its symbols are public API.
+               # That may cause symbol collision, so explicitly demote everything.
+               *;
+};