From 2ac4222022ee261269994ce4eaf4d7c070152492 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 10 May 2020 14:20:27 +0430 Subject: [PATCH] [meson] specify preferred linker to avoid stdc++ linking --- meson_options.txt | 2 ++ src/meson.build | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index 6fe06dfec..c76ccaf71 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -28,6 +28,8 @@ option('introspection', type : 'feature', value : 'disabled', yield : true, option('icu-builtin', type: 'boolean', value: false, description: 'Don\'t separate ICU support as harfbuzz-icu module') +option('with-libstdcxx', type: 'boolean', value: false, + description: 'Allow linking with libstdc++ (ignored and always enabled in Windows)') option('experimental-api', type: 'boolean', value: false, description: 'Enable experimental APIs') option('amalgam', type : 'boolean', value : false, diff --git a/src/meson.build b/src/meson.build index 36804ea45..361f45307 100644 --- a/src/meson.build +++ b/src/meson.build @@ -334,6 +334,16 @@ if have_icu and have_icu_builtin deps += [icu_dep] endif +if host_machine.system() == 'windows' or get_option('with-libstdcxx') + chosen_linker = 'cpp' +else + # our autotools port was limiting this to HAVE_GCC as https://github.com/harfbuzz/harfbuzz/commit/e784632 + # let's see if that is needed anymore + + # Use a C linker, not C++; Don't link to libstdc++ + chosen_linker = 'c' +endif + # harfbuzz gen_def = find_program('gen-def.py') @@ -369,6 +379,7 @@ libharfbuzz = library('harfbuzz', hb_sources, soversion: hb_so_version, version: version, install: true, + link_language: chosen_linker, name_prefix: hb_lib_prefix) libharfbuzz_dep = declare_dependency( @@ -390,6 +401,7 @@ libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, soversion: hb_so_version, version: version, install: true, + link_language: chosen_linker, name_prefix: hb_lib_prefix) libharfbuzz_subset_dep = declare_dependency( @@ -471,7 +483,9 @@ if get_option('tests').enabled() if not get_option('amalgam') dist_check_script += 'check-includes.sh' endif - if false # !WITH_LIBSTDCXX + if false and not get_option('with-libstdcxx') + # enable this once https://github.com/mesonbuild/meson/pull/6838 hits a release + # and make that version (i.e. 0.55) our minimum build requirement dist_check_script += 'check-libstdc++.sh' # See https://github.com/harfbuzz/harfbuzz/issues/2276 endif @@ -515,6 +529,8 @@ if have_icu and not have_icu_builtin soversion: hb_so_version, version: version, install: true, + # ICU links to stdc++ anyway so the default linker is good + # link_language: chosen_linker, name_prefix: hb_lib_prefix) libharfbuzz_icu_dep = declare_dependency( @@ -598,6 +614,7 @@ if have_gobject soversion: hb_so_version, version: version, install: true, + link_language: chosen_linker, name_prefix: hb_lib_prefix) gir = find_program('g-ir-scanner', required: get_option('introspection'))