From d38f3deaed52e592d9915e1b7970988ccb28eb7f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sun, 11 Jun 2017 14:32:39 +0530 Subject: gnome: Work around GNU ld bug with -rpath,$ORIGIN g-ir-scanner doesn't understand -rpath, so we use -L instead which has the same effect. Closes https://github.com/mesonbuild/meson/issues/1911 --- mesonbuild/modules/gnome.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 6644ba7..1822179 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -288,15 +288,23 @@ class GnomeModule(ExtensionModule): def _get_link_args(self, state, lib, depends=None, include_rpath=False, use_gir_args=False): + # Construct link args if gir_has_extra_lib_arg() and use_gir_args: - link_command = ['--extra-library=%s' % lib.name] + link_command = ['--extra-library=' + lib.name] else: - link_command = ['-l%s' % lib.name] + link_command = ['-l' + lib.name] if isinstance(lib, build.SharedLibrary): - libdir = os.path.join(state.environment.get_build_dir(), lib.subdir) - link_command += ['-L%s' % libdir] + libdir = state.backend.get_target_dir(lib) + link_command.append('-L' + libdir) + # Needed for the following binutils bug: + # https://github.com/mesonbuild/meson/issues/1911 + # However, g-ir-scanner does not understand -Wl,-rpath + # so we need to use -L instead + for d in state.backend.determine_rpath_dirs(lib): + d = os.path.join(state.environment.get_build_dir(), d) + link_command.append('-L' + d) if include_rpath: - link_command += ['-Wl,-rpath %s' % libdir] + link_command.append('-Wl,-rpath,' + libdir) if depends: depends.append(lib) return link_command @@ -536,6 +544,13 @@ class GnomeModule(ExtensionModule): scan_command += ['--program', girtarget] elif isinstance(girtarget, build.SharedLibrary): libname = girtarget.get_basename() + # Needed for the following binutils bug: + # https://github.com/mesonbuild/meson/issues/1911 + # However, g-ir-scanner does not understand -Wl,-rpath + # so we need to use -L instead + for d in state.backend.determine_rpath_dirs(girtarget): + d = os.path.join(state.environment.get_build_dir(), d) + scan_command.append('-L' + d) scan_command += ['--library', libname] scankwargs = {'output': girfile, 'input': libsources, -- cgit v1.1 From 1e42241ef3c9f4d7be70b7c44703cf8856a85ddd Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sun, 11 Jun 2017 14:36:33 +0530 Subject: gnome: Don't assume that a C compiler is being used --- mesonbuild/modules/gnome.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'mesonbuild/modules/gnome.py') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 1822179..84ea679 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -443,12 +443,18 @@ class GnomeModule(ExtensionModule): 'Gir includes must be str, GirTarget, or list of them') cflags = [] - if state.global_args.get('c'): - cflags += state.global_args['c'] - if state.project_args.get('c'): - cflags += state.project_args['c'] - if 'c' in state.compilers: - compiler = state.compilers['c'] + 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'): + break + else: + lang = None + compiler = None + if lang and compiler: + if state.global_args.get(lang): + cflags += state.global_args[lang] + if state.project_args.get(lang): + cflags += state.project_args[lang] sanitize = compiler.get_options().get('b_sanitize') if sanitize: cflags += compilers.sanitizer_compile_args(sanitize) -- cgit v1.1