Fix darwin/clang map
authorAlex Samorukov <samm@os2.kiev.ua>
Thu, 31 Oct 2019 07:14:49 +0000 (08:14 +0100)
committerØyvind Kolås <pippin@gimp.org>
Thu, 31 Oct 2019 08:36:33 +0000 (09:36 +0100)
babl/meson.build
babl/test-clang.map [new file with mode: 0644]
babl/test-gnu.map [new file with mode: 0644]
gen_babl_map.py

index b551c9a8d3b0a8a3e029a78556ee87635f8b719a..16e1c569fd13275faeeefcf7523b19cd8cf0822f 100644 (file)
@@ -4,6 +4,12 @@ subdir('base')
 python = import('python').find_installation()
 
 version_script = 'babl.map'
+version_script_clang = 'babl.map.clang'
+
+babl_gnu_sym_path = join_paths(meson.current_source_dir(), 'test-gnu.map')
+babl_clang_sym_path = join_paths(meson.current_source_dir(), 'test-clang.map')
+
+
 export_symbols = join_paths(meson.source_root(), 'export-symbols')
 version_script_target = custom_target(version_script,
   input : [ export_symbols, ] ,
@@ -24,9 +30,14 @@ babl_c_args = [
 ]
 
 # Linker arguments
-babl_link_args = [
-  '-Wl,--version-script,' + version_script,
-]
+if cc.links('', name: '-Wl,--version-script', args: ['-shared', '-Wl,--version-script=' + babl_gnu_sym_path])
+  babl_link_args = ['-Wl,--version-script,' + version_script]
+elif host_machine.system() == 'darwin' and cc.has_multi_link_arguments('-Wl,-exported_symbols_list', babl_clang_sym_path)
+       # Clang on Darwin
+  babl_link_args = ['-Wl,-exported_symbols_list',version_script_clang]
+else
+       error('Linker doesn\'t support --version-script or -exported_symbols_list')
+endif
 if platform_win32
   babl_link_args += '-Wl,--no-undefined'
 endif
diff --git a/babl/test-clang.map b/babl/test-clang.map
new file mode 100644 (file)
index 0000000..2ad2526
--- /dev/null
@@ -0,0 +1 @@
+babl_*
diff --git a/babl/test-gnu.map b/babl/test-gnu.map
new file mode 100644 (file)
index 0000000..c27b37d
--- /dev/null
@@ -0,0 +1,6 @@
+{
+       global:
+               babl_*;
+       local:
+               *;
+};
index 644ea619bbb5af50b57acd86f51c1aed3fa4f74b..80a2d3ea3e4da325a3c0e300ed1fda1f74fb0638 100644 (file)
@@ -2,6 +2,7 @@ import sys
 
 export_symbols=sys.argv[1]
 version_file=sys.argv[2]
+version_file_clang=sys.argv[2] + ".clang"
 
 with open(export_symbols, 'r') as syms, \
      open(version_file, 'w') as version:
@@ -9,3 +10,8 @@ with open(export_symbols, 'r') as syms, \
      for sym in syms:
         version.write("        {};\n".format(sym.strip()))
      version.write("    local:\n        *;\n};\n")
+
+with open(export_symbols, 'r') as syms, \
+     open(version_file_clang, 'w') as version:
+     for sym in syms:
+        version.write("_{}\n".format(sym.strip()))