Mesa (staging/20.1): radv: restrict exported symbols with static llvm

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 25 13:04:22 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 69bad283b962817cc1811ed9820450172b26b5fd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=69bad283b962817cc1811ed9820450172b26b5fd

Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Thu Aug  6 09:14:07 2020 +0100

radv: restrict exported symbols with static llvm

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 at collabora.com>
Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6203>
(cherry picked from commit 41bb6459d3a7dba21ff811069dc4757d7789fd12)

---

 .pick_status.json          |  2 +-
 src/amd/vulkan/meson.build | 13 ++++++++++++-
 src/amd/vulkan/vulkan.sym  | 11 +++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 5c0b608b155..979f9fb497b 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1948,7 +1948,7 @@
         "description": "radv: restrict exported symbols with static llvm",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
index efcf2dd6c89..eec026e8f60 100644
--- a/src/amd/vulkan/meson.build
+++ b/src/amd/vulkan/meson.build
@@ -157,6 +157,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, radv_gfx10_format_table_h],
@@ -173,7 +183,8 @@ libvulkan_radeon = shared_library(
   ],
   c_args : [c_vis_args, no_override_init_args, radv_flags],
   cpp_args : [cpp_vis_args, radv_flags],
-  link_args : [ld_args_bsymbolic, ld_args_gc_sections],
+  link_args : [ld_args_bsymbolic, ld_args_gc_sections, libvulkan_radeon_ld_args],
+  link_depends : [libvulkan_radeon_link_depends,],
   install : true,
 )
 
diff --git a/src/amd/vulkan/vulkan.sym b/src/amd/vulkan/vulkan.sym
new file mode 100644
index 00000000000..c85a22e905a
--- /dev/null
+++ b/src/amd/vulkan/vulkan.sym
@@ -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.
+		*;
+};



More information about the mesa-commit mailing list