From a04535b0964d2bd40d08e4b3d16ff27b6ee7262c Mon Sep 17 00:00:00 2001 From: Alex Samorukov Date: Thu, 31 Oct 2019 08:14:49 +0100 Subject: [PATCH] Fix darwin/clang map --- babl/meson.build | 17 ++++++++++++++--- babl/test-clang.map | 1 + babl/test-gnu.map | 6 ++++++ gen_babl_map.py | 6 ++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 babl/test-clang.map create mode 100644 babl/test-gnu.map diff --git a/babl/meson.build b/babl/meson.build index b551c9a8d..16e1c569f 100644 --- babl/meson.build +++ babl/meson.build @@ -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 index 000000000..2ad252630 --- /dev/null +++ babl/test-clang.map @@ -0,0 +1 @@ +babl_* diff --git a/babl/test-gnu.map b/babl/test-gnu.map new file mode 100644 index 000000000..c27b37d66 --- /dev/null +++ babl/test-gnu.map @@ -0,0 +1,6 @@ +{ + global: + babl_*; + local: + *; +}; diff --git a/gen_babl_map.py b/gen_babl_map.py index 644ea619b..80a2d3ea3 100644 --- gen_babl_map.py +++ gen_babl_map.py @@ -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())) -- 2.22.0