Add patch from PR #3463 to distinguish between internal and external

linker flags.
This commit is contained in:
ajacoutot 2018-05-02 11:51:24 +00:00
parent f1ff236f34
commit f5d85216b2
3 changed files with 165 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.26 2018/04/23 22:45:40 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.27 2018/05/02 11:51:24 ajacoutot Exp $
COMMENT= next-generation build system
@ -6,6 +6,7 @@ MODPY_EGG_VERSION= ${GH_TAGNAME}
GH_ACCOUNT= mesonbuild
GH_PROJECT= meson
GH_TAGNAME= 0.46.0
REVISION= 0
CATEGORIES= devel

View File

@ -1,6 +1,6 @@
# $OpenBSD: meson.port.mk,v 1.19 2018/04/23 22:45:40 ajacoutot Exp $
# $OpenBSD: meson.port.mk,v 1.20 2018/05/02 11:51:24 ajacoutot Exp $
BUILD_DEPENDS += devel/meson>=0.46.0
BUILD_DEPENDS += devel/meson>=0.46.0p0
SEPARATE_BUILD ?= Yes
MODMESON_WANTCOLOR ?= No

View File

@ -0,0 +1,161 @@
$OpenBSD: patch-mesonbuild_modules_gnome_py,v 1.1 2018/05/02 11:51:24 ajacoutot Exp $
https://github.com/mesonbuild/meson/pull/3463
Index: mesonbuild/modules/gnome.py
--- mesonbuild/modules/gnome.py.orig
+++ mesonbuild/modules/gnome.py
@@ -316,7 +316,8 @@ class GnomeModule(ExtensionModule):
def _get_dependencies_flags(self, deps, state, depends=None, include_rpath=False,
use_gir_args=False):
cflags = OrderedSet()
- ldflags = OrderedSet()
+ internal_ldflags = OrderedSet()
+ external_ldflags = OrderedSet()
gi_includes = OrderedSet()
deps = mesonlib.listify(deps, unholder=True)
@@ -326,17 +327,19 @@ class GnomeModule(ExtensionModule):
for lib in dep.libraries:
if hasattr(lib, 'held_object'):
lib = lib.held_object
- ldflags.update(self._get_link_args(state, lib, depends, include_rpath))
+ internal_ldflags.update(self._get_link_args(state, lib, depends, include_rpath))
libdepflags = self._get_dependencies_flags(lib.get_external_deps(), state, depends, include_rpath,
use_gir_args)
cflags.update(libdepflags[0])
- ldflags.update(libdepflags[1])
- gi_includes.update(libdepflags[2])
+ internal_ldflags.update(libdepflags[1])
+ external_ldflags.update(libdepflags[2])
+ gi_includes.update(libdepflags[3])
extdepflags = self._get_dependencies_flags(dep.ext_deps, state, depends, include_rpath,
use_gir_args)
cflags.update(extdepflags[0])
- ldflags.update(extdepflags[1])
- gi_includes.update(extdepflags[2])
+ internal_ldflags.update(extdepflags[1])
+ external_ldflags.update(extdepflags[2])
+ gi_includes.update(extdepflags[3])
for source in dep.sources:
if hasattr(source, 'held_object'):
source = source.held_object
@@ -351,9 +354,9 @@ class GnomeModule(ExtensionModule):
# For PkgConfigDependency only:
getattr(dep, 'is_libtool', False)):
lib_dir = os.path.dirname(lib)
- ldflags.update(["-L%s" % lib_dir])
+ external_ldflags.update(["-L%s" % lib_dir])
if include_rpath:
- ldflags.update(['-Wl,-rpath {}'.format(lib_dir)])
+ external_ldflags.update(['-Wl,-rpath {}'.format(lib_dir)])
libname = os.path.basename(lib)
if libname.startswith("lib"):
libname = libname[3:]
@@ -362,7 +365,7 @@ class GnomeModule(ExtensionModule):
# Hack to avoid passing some compiler options in
if lib.startswith("-W"):
continue
- ldflags.update([lib])
+ external_ldflags.update([lib])
if isinstance(dep, PkgConfigDependency):
girdir = dep.get_pkgconfig_variable("girdir", {'default': ''})
@@ -375,14 +378,17 @@ class GnomeModule(ExtensionModule):
continue
if gir_has_extra_lib_arg(self.interpreter) and use_gir_args:
- fixed_ldflags = OrderedSet()
- for ldflag in ldflags:
- if ldflag.startswith("-l"):
- fixed_ldflags.add(ldflag.replace('-l', '--extra-library=', 1))
- else:
- fixed_ldflags.add(ldflag)
- ldflags = fixed_ldflags
- return cflags, ldflags, gi_includes
+ def fix_ldflags(ldflags):
+ fixed_ldflags = OrderedSet()
+ for ldflag in ldflags:
+ if ldflag.startswith("-l"):
+ fixed_ldflags.add(ldflag.replace('-l', '--extra-library=', 1))
+ else:
+ fixed_ldflags.add(ldflag)
+ return fixed_ldflags
+ internal_ldflags = fix_ldflags(internal_ldflags)
+ external_ldflags = fix_ldflags(external_ldflags)
+ return cflags, internal_ldflags, external_ldflags, gi_includes
@permittedKwargs({'sources', 'nsversion', 'namespace', 'symbol_prefix', 'identifier_prefix',
'export_packages', 'includes', 'dependencies', 'link_with', 'include_directories',
@@ -484,7 +490,8 @@ class GnomeModule(ExtensionModule):
'Gir includes must be str, GirTarget, or list of them')
cflags = []
- ldflags = []
+ internal_ldflags = []
+ external_ldflags = []
for lang, compiler in girtarget.compilers.items():
# XXX: Can you use g-i with any other language?
if lang in ('c', 'cpp', 'objc', 'objcpp', 'd'):
@@ -501,7 +508,7 @@ class GnomeModule(ExtensionModule):
sanitize = state.environment.coredata.base_options['b_sanitize'].value
cflags += compilers.sanitizer_compile_args(sanitize)
if 'address' in sanitize.split(','):
- ldflags += ['-lasan']
+ external_ldflags += ['-lasan']
# FIXME: Linking directly to libasan is not recommended but g-ir-scanner
# does not understand -f LDFLAGS. https://bugzilla.gnome.org/show_bug.cgi?id=783892
# ldflags += compilers.sanitizer_link_args(sanitize)
@@ -562,10 +569,11 @@ class GnomeModule(ExtensionModule):
# ldflags will be misinterpreted by gir scanner (showing
# spurious dependencies) but building GStreamer fails if they
# are not used here.
- dep_cflags, dep_ldflags, gi_includes = self._get_dependencies_flags(deps, state, depends,
- use_gir_args=True)
+ dep_cflags, dep_internal_ldflags, dep_external_ldflags, gi_includes = \
+ self._get_dependencies_flags(deps, state, depends, use_gir_args=True)
cflags += list(dep_cflags)
- ldflags += list(dep_ldflags)
+ internal_ldflags += list(dep_internal_ldflags)
+ external_ldflags += list(dep_external_ldflags)
scan_command += ['--cflags-begin']
scan_command += cflags
scan_command += state.environment.coredata.external_args[lang]
@@ -575,7 +583,7 @@ class GnomeModule(ExtensionModule):
# ones.
if isinstance(girtarget, build.SharedLibrary):
scan_command += ["-L@PRIVATE_OUTDIR_ABS_%s@" % girtarget.get_id()]
- scan_command += list(ldflags)
+ scan_command += list(internal_ldflags)
for i in gi_includes:
scan_command += ['--add-include-path=%s' % i]
@@ -603,6 +611,7 @@ class GnomeModule(ExtensionModule):
for link_arg in state.environment.coredata.external_link_args[lang]:
if link_arg.startswith('-L'):
scan_command.append(link_arg)
+ scan_command += list(external_ldflags)
scankwargs = {'output': girfile,
'command': scan_command,
@@ -825,7 +834,8 @@ This will become a hard error in the future.''')
def _get_build_args(self, kwargs, state):
args = []
deps = extract_as_list(kwargs, 'dependencies', unholder=True)
- cflags, ldflags, gi_includes = self._get_dependencies_flags(deps, state, include_rpath=True)
+ cflags, internal_ldflags, external_ldflags, gi_includes = \
+ self._get_dependencies_flags(deps, state, include_rpath=True)
inc_dirs = mesonlib.extract_as_list(kwargs, 'include_directories')
for incd in inc_dirs:
if not isinstance(incd.held_object, (str, build.IncludeDirs)):
@@ -833,7 +843,10 @@ This will become a hard error in the future.''')
'Gir include dirs should be include_directories().')
cflags.update(get_include_args(inc_dirs))
cflags.update(state.environment.coredata.external_args['c'])
+ ldflags = OrderedSet()
+ ldflags.update(internal_ldflags)
ldflags.update(state.environment.coredata.external_link_args['c'])
+ ldflags.update(external_ldflags)
if cflags:
args += ['--cflags=%s' % ' '.join(cflags)]
if ldflags: