From ef60814ad0587ab0700d909abb5e6b40a92c9e2f Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: May 04 2018 10:13:05 +0000 Subject: Backport upstream fixes Signed-off-by: Igor Gnatenko --- diff --git a/0001-guess_external_link_dependencies-deduplicate-search-.patch b/0001-guess_external_link_dependencies-deduplicate-search-.patch new file mode 100644 index 0000000..e1bbe13 --- /dev/null +++ b/0001-guess_external_link_dependencies-deduplicate-search-.patch @@ -0,0 +1,59 @@ +From 507ba31cfa4c33d5e853d8be57cbe42374aa7acf Mon Sep 17 00:00:00 2001 +From: Martin Hostettler +Date: Thu, 26 Apr 2018 20:49:44 +0200 +Subject: [PATCH 01/16] guess_external_link_dependencies: deduplicate search + dirs and libraries. + +Reduce speed impact of duplicated libs and pathes in the link command +line. (fixes #3465) +--- + mesonbuild/backend/ninjabackend.py | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py +index eeac388c..267f0301 100644 +--- a/mesonbuild/backend/ninjabackend.py ++++ b/mesonbuild/backend/ninjabackend.py +@@ -2429,8 +2429,8 @@ rule FORTRAN_DEP_HACK%s + # https://sourceware.org/bugzilla/show_bug.cgi?id=22843 + # * Meson optimizes libraries from the same build using the symbol extractor. + # Just letting ninja use ld generated dependencies would undo this optimization. +- search_dirs = [] +- libs = [] ++ search_dirs = OrderedSet() ++ libs = OrderedSet() + absolute_libs = [] + + build_dir = self.environment.get_build_dir() +@@ -2451,23 +2451,24 @@ rule FORTRAN_DEP_HACK%s + break + if not os.path.isabs(path): + path = os.path.join(build_dir, path) +- search_dirs.append(path) ++ search_dirs.add(path) + elif item.startswith('-l'): + if len(item) > 2: +- libs.append(item[2:]) ++ lib = item[2:] + else: + try: +- libs.append(next(it)) ++ lib = next(it) + except StopIteration: + mlog.warning("Generated linker command has '-l' argument without following library name") + break ++ libs.add(lib) + elif os.path.isabs(item) and self.environment.is_library(item) and os.path.isfile(item): + absolute_libs.append(item) + + guessed_dependencies = [] + # TODO The get_library_naming requirement currently excludes link targets that use d or fortran as their main linker + if hasattr(linker, 'get_library_naming'): +- search_dirs += linker.get_library_dirs() ++ search_dirs = list(search_dirs) + linker.get_library_dirs() + prefixes_static, suffixes_static = linker.get_library_naming(self.environment, 'static', strict=True) + prefixes_shared, suffixes_shared = linker.get_library_naming(self.environment, 'shared', strict=True) + for libname in libs: +-- +2.17.0 + diff --git a/0002-CCompiler-Cache-result-of-get_library_dirs.patch b/0002-CCompiler-Cache-result-of-get_library_dirs.patch new file mode 100644 index 0000000..9bc2de8 --- /dev/null +++ b/0002-CCompiler-Cache-result-of-get_library_dirs.patch @@ -0,0 +1,48 @@ +From 32dfddd1d42bd64d63b0a8b116e1419e053e7297 Mon Sep 17 00:00:00 2001 +From: Martin Hostettler +Date: Thu, 26 Apr 2018 21:11:52 +0200 +Subject: [PATCH 02/16] CCompiler: Cache result of get_library_dirs(). + +It is repeatedly used by e.g. guess_external_link_dependencies. +--- + mesonbuild/compilers/c.py | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py +index 91c9a166..88571a3c 100644 +--- a/mesonbuild/compilers/c.py ++++ b/mesonbuild/compilers/c.py +@@ -44,6 +44,8 @@ from .compilers import ( + + + class CCompiler(Compiler): ++ library_dirs_cache = {} ++ + def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs): + # If a child ObjC or CPP class has already set it, don't set it ourselves + if not hasattr(self, 'language'): +@@ -157,7 +159,7 @@ class CCompiler(Compiler): + def get_std_shared_lib_link_args(self): + return ['-shared'] + +- def get_library_dirs(self): ++ def get_library_dirs_real(self): + env = os.environ.copy() + env['LC_ALL'] = 'C' + stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=env)[1] +@@ -167,6 +169,12 @@ class CCompiler(Compiler): + return libstr.split(':') + return [] + ++ def get_library_dirs(self): ++ key = tuple(self.exelist) ++ if key not in self.library_dirs_cache: ++ self.library_dirs_cache[key] = self.get_library_dirs_real() ++ return self.library_dirs_cache[key][:] ++ + def get_pic_args(self): + return ['-fPIC'] + +-- +2.17.0 + diff --git a/0003-New-argument-profile-self-for-profiling-performance.patch b/0003-New-argument-profile-self-for-profiling-performance.patch new file mode 100644 index 0000000..96744f8 --- /dev/null +++ b/0003-New-argument-profile-self-for-profiling-performance.patch @@ -0,0 +1,69 @@ +From 12d988a668651e1cae570f1be83ae4f3bdb7120c Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan +Date: Wed, 25 Apr 2018 00:02:44 +0530 +Subject: [PATCH 03/16] New argument: --profile-self for profiling performance + +Outputs two profile logs: one for the interpreter run and another for +the backend-specific build file generation. Both are stored in +meson-private in the build directory. +--- + mesonbuild/mesonmain.py | 19 ++++++++++++++++--- + 1 file changed, 16 insertions(+), 3 deletions(-) + +diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py +index 613e953d..f4fec95a 100644 +--- a/mesonbuild/mesonmain.py ++++ b/mesonbuild/mesonmain.py +@@ -15,10 +15,12 @@ + import sys, stat, traceback, argparse + import datetime + import os.path ++import platform ++import cProfile as profile ++ + from . import environment, interpreter, mesonlib + from . import build + from . import mconf, mintro, mtest, rewriter, minit +-import platform + from . import mlog, coredata + from .mesonlib import MesonException + from .wrap import WrapMode, wraptool +@@ -38,6 +40,8 @@ def create_parser(): + p.add_argument('--wrap-mode', default=WrapMode.default, + type=wrapmodetype, choices=WrapMode, + help='Special wrap mode to use') ++ p.add_argument('--profile-self', action='store_true', dest='profile', ++ help=argparse.SUPPRESS) + p.add_argument('directories', nargs='*') + return p + +@@ -176,7 +180,11 @@ class MesonApp: + mlog.log('Target machine cpu:', mlog.bold(intr.builtin['target_machine'].cpu_method([], {}))) + mlog.log('Build machine cpu family:', mlog.bold(intr.builtin['build_machine'].cpu_family_method([], {}))) + mlog.log('Build machine cpu:', mlog.bold(intr.builtin['build_machine'].cpu_method([], {}))) +- intr.run() ++ if self.options.profile: ++ fname = os.path.join(self.build_dir, 'meson-private', 'profile-interpreter.log') ++ profile.runctx('intr.run()', globals(), locals(), filename=fname) ++ else: ++ intr.run() + try: + dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat') + # We would like to write coredata as late as possible since we use the existence of +@@ -186,7 +194,12 @@ class MesonApp: + # sync with the time that gets applied to any files. Thus, we dump this file as late as + # possible, but before build files, and if any error occurs, delete it. + cdf = env.dump_coredata() +- g.generate(intr) ++ if self.options.profile: ++ fname = 'profile-{}-backend.log'.format(self.options.backend) ++ fname = os.path.join(self.build_dir, 'meson-private', fname) ++ profile.runctx('g.generate(intr)', globals(), locals(), filename=fname) ++ else: ++ g.generate(intr) + build.save(b, dumpfile) + # Post-conf scripts must be run after writing coredata or else introspection fails. + g.run_postconf_scripts() +-- +2.17.0 + diff --git a/0004-Install-generated-gdbus-header-with-old-glib-version.patch b/0004-Install-generated-gdbus-header-with-old-glib-version.patch new file mode 100644 index 0000000..13b4e6c --- /dev/null +++ b/0004-Install-generated-gdbus-header-with-old-glib-version.patch @@ -0,0 +1,60 @@ +From 1b6adbfa07d9926c2312f05562bb91d535c9c182 Mon Sep 17 00:00:00 2001 +From: Jussi Pakkanen +Date: Fri, 27 Apr 2018 23:07:30 +0300 +Subject: [PATCH 04/16] Install generated gdbus header with old glib version + too. + +--- + mesonbuild/modules/gnome.py | 6 +++++- + test cases/frameworks/7 gnome/gdbus/meson.build | 4 +++- + test cases/frameworks/7 gnome/installed_files.txt | 1 + + 3 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py +index abefe057..9003bc75 100644 +--- a/mesonbuild/modules/gnome.py ++++ b/mesonbuild/modules/gnome.py +@@ -959,11 +959,15 @@ This will become a hard error in the future.''') + self._print_gdbus_warning() + cmd += ['--generate-c-code', '@OUTDIR@/' + namebase, '@INPUT@'] + outputs = [namebase + '.c', namebase + '.h'] ++ install = kwargs.get('install_header', False) + custom_kwargs = {'input': xml_files, + 'output': outputs, + 'command': cmd, +- 'build_by_default': build_by_default ++ 'build_by_default': build_by_default, ++ 'install' : install, + } ++ if install and 'install_dir' in kwargs: ++ custom_kwargs['install_dir'] = [False, kwargs['install_dir']] + ct = build.CustomTarget(target_name, state.subdir, state.subproject, custom_kwargs) + # Ensure that the same number (and order) of arguments are returned + # regardless of the gdbus-codegen (glib) version being used +diff --git a/test cases/frameworks/7 gnome/gdbus/meson.build b/test cases/frameworks/7 gnome/gdbus/meson.build +index 68ad706f..46259318 100644 +--- a/test cases/frameworks/7 gnome/gdbus/meson.build ++++ b/test cases/frameworks/7 gnome/gdbus/meson.build +@@ -14,7 +14,9 @@ gdbus_src = gnome.gdbus_codegen('generated-gdbus', + annotations : [ + ['com.example.Hello()', 'org.freedesktop.DBus.Deprecated', 'true'] + ], +- docbook : 'generated-gdbus-doc' ++ docbook : 'generated-gdbus-doc', ++ install_header : true, ++ install_dir : get_option('includedir') + ) + assert(gdbus_src.length() == 3, 'expected 3 targets') + +diff --git a/test cases/frameworks/7 gnome/installed_files.txt b/test cases/frameworks/7 gnome/installed_files.txt +index ac132efb..7502888d 100644 +--- a/test cases/frameworks/7 gnome/installed_files.txt ++++ b/test cases/frameworks/7 gnome/installed_files.txt +@@ -15,3 +15,4 @@ usr/share/gir-1.0/MesonDep2-1.0.gir + usr/share/glib-2.0/schemas/com.github.meson.gschema.xml + usr/share/simple-resources.gresource + usr/include/simple-resources.h ++usr/include/generated-gdbus.h +-- +2.17.0 + diff --git a/0005-has_multi_link_arguments-Some-compilers-needs-Wl-fat.patch b/0005-has_multi_link_arguments-Some-compilers-needs-Wl-fat.patch new file mode 100644 index 0000000..9f6d72f --- /dev/null +++ b/0005-has_multi_link_arguments-Some-compilers-needs-Wl-fat.patch @@ -0,0 +1,57 @@ +From 8456014be8cf0ee3397dc5318ce452f17f241eba Mon Sep 17 00:00:00 2001 +From: Xavier Claessens +Date: Tue, 24 Apr 2018 16:27:43 -0400 +Subject: [PATCH 05/16] has_multi_link_arguments: Some compilers needs + -Wl,--fatal-warnings + +ld does not treat wrong -z options as fatal by default. +--- + mesonbuild/compilers/c.py | 14 ++++++++++++++ + test cases/common/191 has link arg/meson.build | 2 ++ + 2 files changed, 16 insertions(+) + +diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py +index 88571a3c..e8110969 100644 +--- a/mesonbuild/compilers/c.py ++++ b/mesonbuild/compilers/c.py +@@ -59,6 +59,9 @@ class CCompiler(Compiler): + else: + self.exe_wrapper = exe_wrapper + ++ # Set to None until we actually need to check this ++ self.has_fatal_warnings_link_arg = None ++ + def needs_static_linker(self): + return True # When compiling static libraries, so yes. + +@@ -871,6 +874,17 @@ class CCompiler(Compiler): + return self.has_arguments(args, env, code, mode='compile') + + def has_multi_link_arguments(self, args, env): ++ # First time we check for link flags we need to first check if we have ++ # --fatal-warnings, otherwise some linker checks could give some ++ # false positive. ++ fatal_warnings_args = ['-Wl,--fatal-warnings'] ++ if self.has_fatal_warnings_link_arg is None: ++ self.has_fatal_warnings_link_arg = False ++ self.has_fatal_warnings_link_arg = self.has_multi_link_arguments(fatal_warnings_args, env) ++ ++ if self.has_fatal_warnings_link_arg: ++ args = fatal_warnings_args + args ++ + args = self.linker_to_compiler_args(args) + code = 'int main(int argc, char **argv) { return 0; }' + return self.has_arguments(args, env, code, mode='link') +diff --git a/test cases/common/191 has link arg/meson.build b/test cases/common/191 has link arg/meson.build +index 255ff459..e166101a 100644 +--- a/test cases/common/191 has link arg/meson.build ++++ b/test cases/common/191 has link arg/meson.build +@@ -40,3 +40,5 @@ assert(l2.length() == 0, 'First supported did not return empty array.') + assert(not cc.has_multi_link_arguments([isnt_arg, is_arg]), 'Arg that should be broken is not.') + assert(cc.has_multi_link_arguments(is_arg), 'Arg that should have worked does not work.') + assert(cc.has_multi_link_arguments([useless, is_arg]), 'Arg that should have worked does not work.') ++ ++assert(not cc.has_link_argument('-Wl,-z,nodelete42'), 'Did not detect wrong -z linker argument') +-- +2.17.0 + diff --git a/0006-Add-test-to-show-issue.patch b/0006-Add-test-to-show-issue.patch new file mode 100644 index 0000000..657da00 --- /dev/null +++ b/0006-Add-test-to-show-issue.patch @@ -0,0 +1,54 @@ +From 476e307fff0417ee546ef362fe1ae696417d680a Mon Sep 17 00:00:00 2001 +From: Niklas Claesson +Date: Mon, 30 Apr 2018 13:57:52 +0200 +Subject: [PATCH 06/16] Add test to show issue + +--- + .../161 index customtarget/check_args.py | 18 ++++++++++++++++++ + .../common/161 index customtarget/meson.build | 7 +++++++ + 2 files changed, 25 insertions(+) + create mode 100644 test cases/common/161 index customtarget/check_args.py + +diff --git a/test cases/common/161 index customtarget/check_args.py b/test cases/common/161 index customtarget/check_args.py +new file mode 100644 +index 00000000..8663a6fe +--- /dev/null ++++ b/test cases/common/161 index customtarget/check_args.py +@@ -0,0 +1,18 @@ ++#!python3 ++ ++import sys ++from pathlib import Path ++ ++def main(): ++ if len(sys.argv) != 2: ++ print(sys.argv) ++ return 1 ++ if sys.argv[1] != 'gen.c': ++ print(sys.argv) ++ return 2 ++ Path('foo').touch() ++ ++ return 0 ++ ++if __name__ == '__main__': ++ sys.exit(main()) +diff --git a/test cases/common/161 index customtarget/meson.build b/test cases/common/161 index customtarget/meson.build +index 11cb214b..27d28b56 100644 +--- a/test cases/common/161 index customtarget/meson.build ++++ b/test cases/common/161 index customtarget/meson.build +@@ -29,4 +29,11 @@ lib = static_library( + ['lib.c', gen[1]], + ) + ++custom_target( ++ 'foo', ++ input: gen[0], ++ output: 'foo', ++ command: [find_program('check_args.py'), '@INPUT@'], ++) ++ + subdir('subdir') +-- +2.17.0 + diff --git a/0007-Allow-custom_target-do-depend-on-indexed-output-of-c.patch b/0007-Allow-custom_target-do-depend-on-indexed-output-of-c.patch new file mode 100644 index 0000000..55acee9 --- /dev/null +++ b/0007-Allow-custom_target-do-depend-on-indexed-output-of-c.patch @@ -0,0 +1,41 @@ +From 0177d3f6d5c7ef24b9a2d42474288f9072ea7e3f Mon Sep 17 00:00:00 2001 +From: Niklas Claesson +Date: Mon, 30 Apr 2018 13:58:27 +0200 +Subject: [PATCH 07/16] Allow custom_target do depend on indexed output of + custom_target + +Fixes: #3494 +--- + mesonbuild/backend/backends.py | 2 +- + mesonbuild/build.py | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py +index 5a401feb..16b91337 100644 +--- a/mesonbuild/backend/backends.py ++++ b/mesonbuild/backend/backends.py +@@ -762,7 +762,7 @@ class Backend: + fname = [os.path.join(self.build_to_src, target.subdir, i)] + elif isinstance(i, build.BuildTarget): + fname = [self.get_target_filename(i)] +- elif isinstance(i, build.CustomTarget): ++ elif isinstance(i, (build.CustomTarget, build.CustomTargetIndex)): + fname = [os.path.join(self.get_target_dir(i), p) for p in i.get_outputs()] + elif isinstance(i, build.GeneratedList): + fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()] +diff --git a/mesonbuild/build.py b/mesonbuild/build.py +index 352f8572..3d531d18 100644 +--- a/mesonbuild/build.py ++++ b/mesonbuild/build.py +@@ -1974,7 +1974,7 @@ def get_sources_string_names(sources): + s = s.held_object + if isinstance(s, str): + names.append(s) +- elif isinstance(s, (BuildTarget, CustomTarget, GeneratedList)): ++ elif isinstance(s, (BuildTarget, CustomTarget, CustomTargetIndex, GeneratedList)): + names += s.get_outputs() + elif isinstance(s, File): + names.append(s.fname) +-- +2.17.0 + diff --git a/0008-Fix-setting-c_args-and-friends-from-command-line.patch b/0008-Fix-setting-c_args-and-friends-from-command-line.patch new file mode 100644 index 0000000..1eceaf8 --- /dev/null +++ b/0008-Fix-setting-c_args-and-friends-from-command-line.patch @@ -0,0 +1,104 @@ +From d2a770c87428655390a9dfb14afd120d67e00127 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens +Date: Mon, 30 Apr 2018 13:53:40 -0400 +Subject: [PATCH 08/16] Fix setting c_args and friends from command line + +When passing more than one -Dc_args it should override the value +instead of appending. This is how all other options works. + +Value should be split on spaces using shlex just like it does with +CFLAGS environment variable. + +Fixes #3473. +--- + mesonbuild/interpreter.py | 27 +++++++++---------- + mesonbuild/mconf.py | 5 ++-- + .../common/181 initial c_args/meson.build | 2 +- + 3 files changed, 16 insertions(+), 18 deletions(-) + +diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py +index fc97b62e..85634193 100644 +--- a/mesonbuild/interpreter.py ++++ b/mesonbuild/interpreter.py +@@ -2274,24 +2274,21 @@ to directly access options of other subprojects.''') + mlog.log('Native %s compiler: ' % comp.get_display_language(), mlog.bold(' '.join(comp.get_exelist())), version_string, sep='') + + # If _args/_link_args settings are given on the +- # command line, use them. ++ # command line, use them, otherwise take them from env. ++ (preproc_args, compile_args, link_args) = environment.get_args_from_envvars(comp) + for optspec in self.build.environment.cmd_line_options.projectoptions: + (optname, optvalue) = optspec.split('=', maxsplit=1) +- if optname.endswith('_link_args'): +- lang = optname[:-10] +- self.coredata.external_link_args.setdefault(lang, []).append(optvalue) ++ if optname == lang + '_link_args': ++ link_args = shlex.split(optvalue) + elif optname.endswith('_args'): +- lang = optname[:-5] +- self.coredata.external_args.setdefault(lang, []).append(optvalue) +- # Otherwise, look for definitions from environment +- # variables such as CFLAGS. +- (preproc_args, compile_args, link_args) = environment.get_args_from_envvars(comp) +- if not comp.get_language() in self.coredata.external_preprocess_args: +- self.coredata.external_preprocess_args[comp.get_language()] = preproc_args +- if not comp.get_language() in self.coredata.external_args: +- self.coredata.external_args[comp.get_language()] = compile_args +- if not comp.get_language() in self.coredata.external_link_args: +- self.coredata.external_link_args[comp.get_language()] = link_args ++ compile_args = shlex.split(optvalue) ++ if lang not in self.coredata.external_preprocess_args: ++ self.coredata.external_preprocess_args[lang] = preproc_args ++ if lang not in self.coredata.external_args: ++ self.coredata.external_args[lang] = compile_args ++ if lang not in self.coredata.external_link_args: ++ self.coredata.external_link_args[lang] = link_args ++ + self.build.add_compiler(comp) + if need_cross_compiler: + mlog.log('Cross %s compiler: ' % cross_comp.get_display_language(), mlog.bold(' '.join(cross_comp.get_exelist())), ' (%s %s)' % (cross_comp.id, cross_comp.version), sep='') +diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py +index 9a113327..c22b98ff 100644 +--- a/mesonbuild/mconf.py ++++ b/mesonbuild/mconf.py +@@ -15,6 +15,7 @@ + import os + import sys + import argparse ++import shlex + from . import (coredata, mesonlib, build) + + def buildparser(): +@@ -134,14 +135,14 @@ class Conf: + raise ConfException('Unknown language %s in linkargs.' % lang) + # TODO, currently split on spaces, make it so that user + # can pass in an array string. +- newvalue = v.split() ++ newvalue = shlex.split(v) + self.coredata.external_link_args[lang] = newvalue + elif k.endswith('_args'): + lang = k[:-5] + if lang not in self.coredata.external_args: + raise ConfException('Unknown language %s in compile args' % lang) + # TODO same fix as above +- newvalue = v.split() ++ newvalue = shlex.split(v) + self.coredata.external_args[lang] = newvalue + else: + raise ConfException('Unknown option %s.' % k) +diff --git a/test cases/common/181 initial c_args/meson.build b/test cases/common/181 initial c_args/meson.build +index 70a6e7a4..169d2bd5 100644 +--- a/test cases/common/181 initial c_args/meson.build ++++ b/test cases/common/181 initial c_args/meson.build +@@ -1,7 +1,7 @@ + project('options', 'c') + + # Test passing c_args and c_link_args options from the command line. +-assert(get_option('c_args') == ['-march=native', '-funroll-loops'], ++assert(get_option('c_args') == ['-funroll-loops'], + 'Incorrect value for c_args option.') + assert(get_option('c_link_args') == ['-random_linker_option'], + 'Incorrect value for c_link_args option.') +-- +2.17.0 + diff --git a/0009-Made-depfixer-more-robust-on-OSX.-Closes-3493.patch b/0009-Made-depfixer-more-robust-on-OSX.-Closes-3493.patch new file mode 100644 index 0000000..8a0498b --- /dev/null +++ b/0009-Made-depfixer-more-robust-on-OSX.-Closes-3493.patch @@ -0,0 +1,44 @@ +From d7014d1cb27c432ed35290831f7fedd301bb481e Mon Sep 17 00:00:00 2001 +From: Jussi Pakkanen +Date: Sun, 29 Apr 2018 20:45:46 +0300 +Subject: [PATCH 09/16] Made depfixer more robust on OSX. Closes #3493. + +--- + mesonbuild/scripts/depfixer.py | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py +index 41ede1d5..185c76a4 100644 +--- a/mesonbuild/scripts/depfixer.py ++++ b/mesonbuild/scripts/depfixer.py +@@ -347,7 +347,9 @@ def fix_elf(fname, new_rpath, verbose=True): + e.fix_rpath(new_rpath) + + def get_darwin_rpaths_to_remove(fname): +- out = subprocess.check_output(['otool', '-l', fname], universal_newlines=True) ++ out = subprocess.check_output(['otool', '-l', fname], ++ universal_newlines=True, ++ stderr=subprocess.DEVNULL) + result = [] + current_cmd = 'FOOBAR' + for line in out.split('\n'): +@@ -371,9 +373,13 @@ def fix_darwin(fname, new_rpath): + return + try: + for rp in rpaths: +- subprocess.check_call(['install_name_tool', '-delete_rpath', rp, fname]) +- if new_rpath != '': +- subprocess.check_call(['install_name_tool', '-add_rpath', new_rpath, fname]) ++ subprocess.check_call(['install_name_tool', '-delete_rpath', rp, fname], ++ stdout=subprocess.DEVNULL, ++ stderr=subprocess.DEVNULL) ++ if new_rpath: ++ subprocess.check_call(['install_name_tool', '-add_rpath', new_rpath, fname], ++ stdout=subprocess.DEVNULL, ++ stderr=subprocess.DEVNULL) + except Exception as e: + raise + sys.exit(0) +-- +2.17.0 + diff --git a/0010-Always-generate-a-new-Product-GUID.-Closes-2485.-ski.patch b/0010-Always-generate-a-new-Product-GUID.-Closes-2485.-ski.patch new file mode 100644 index 0000000..9620251 --- /dev/null +++ b/0010-Always-generate-a-new-Product-GUID.-Closes-2485.-ski.patch @@ -0,0 +1,38 @@ +From 95ec893ecc205d68e9f04468c6867b8791f3cbab Mon Sep 17 00:00:00 2001 +From: Jussi Pakkanen +Date: Sun, 29 Apr 2018 20:00:01 +0300 +Subject: [PATCH 10/16] Always generate a new Product GUID. Closes #2485. [skip + ci] + +We are taking some shortcuts here. The WiX documentation says that you +should keep the Product GUID the same for "small and minor" upgrades +but change it for major ones. These are not defined in any way and a +change of version number might, or might not, warrant a guid +update. For simplicity we will always regenerate the Product GUID. + +Again we find that naming things is difficult since "product" in +everyday language would mean "the application/library/software" and +all different versions of it. In MSI installer terminology it means +something vague between the two. + +https://www.firegiant.com/wix/tutorial/upgrades-and-modularization/ +--- + msi/createmsi.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/msi/createmsi.py b/msi/createmsi.py +index 499f4b01..8a1bc5b4 100755 +--- a/msi/createmsi.py ++++ b/msi/createmsi.py +@@ -38,7 +38,7 @@ class PackageGenerator: + self.product_name = 'Meson Build System' + self.manufacturer = 'The Meson Development Team' + self.version = coredata.version.replace('dev', '') +- self.guid = 'DF5B3ECA-4A31-43E3-8CE4-97FC8A97212E' ++ self.guid = '*' + self.update_guid = '141527EE-E28A-4D14-97A4-92E6075D28B2' + self.main_xml = 'meson.wxs' + self.main_o = 'meson.wixobj' +-- +2.17.0 + diff --git a/0011-Remove-duplicated-definition-of-D-cmdline-arg.patch b/0011-Remove-duplicated-definition-of-D-cmdline-arg.patch new file mode 100644 index 0000000..eb303ff --- /dev/null +++ b/0011-Remove-duplicated-definition-of-D-cmdline-arg.patch @@ -0,0 +1,77 @@ +From b581c800a89afca4788aede2cd4de35d4a4782f5 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens +Date: Thu, 26 Apr 2018 21:49:00 -0400 +Subject: [PATCH 11/16] Remove duplicated definition of -D cmdline arg + +--- + mesonbuild/coredata.py | 2 ++ + mesonbuild/mconf.py | 10 ++++------ + mesonbuild/mesonmain.py | 2 -- + 3 files changed, 6 insertions(+), 8 deletions(-) + +diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py +index dc702d60..93a9e718 100644 +--- a/mesonbuild/coredata.py ++++ b/mesonbuild/coredata.py +@@ -413,6 +413,8 @@ def add_builtin_argument(p, name): + def register_builtin_arguments(parser): + for n in builtin_options: + add_builtin_argument(parser, n) ++ parser.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option", ++ help='Set the value of an option, can be used several times to set multiple options.') + + builtin_options = { + 'buildtype': [UserComboOption, 'Build type to use.', ['plain', 'debug', 'debugoptimized', 'release', 'minsize'], 'debug'], +diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py +index c22b98ff..f907d752 100644 +--- a/mesonbuild/mconf.py ++++ b/mesonbuild/mconf.py +@@ -22,8 +22,6 @@ def buildparser(): + parser = argparse.ArgumentParser(prog='meson configure') + coredata.register_builtin_arguments(parser) + +- parser.add_argument('-D', action='append', default=[], dest='sets', +- help='Set an option to the given value.') + parser.add_argument('directory', nargs='*') + parser.add_argument('--clearcache', action='store_true', default=False, + help='Clear cached state (e.g. found dependencies)') +@@ -36,10 +34,10 @@ def filter_builtin_options(args, original_args): + if not arg.startswith('--') or arg == '--clearcache': + continue + name = arg.lstrip('--').split('=', 1)[0] +- if any([a.startswith(name + '=') for a in args.sets]): ++ if any([a.startswith(name + '=') for a in args.projectoptions]): + raise mesonlib.MesonException( + 'Got argument {0} as both -D{0} and --{0}. Pick one.'.format(name)) +- args.sets.append('{}={}'.format(name, getattr(args, name))) ++ args.projectoptions.append('{}={}'.format(name, getattr(args, name))) + delattr(args, name) + + +@@ -256,8 +254,8 @@ def run(args): + try: + c = Conf(builddir) + save = False +- if len(options.sets) > 0: +- c.set_options(options.sets) ++ if len(options.projectoptions) > 0: ++ c.set_options(options.projectoptions) + save = True + elif options.clearcache: + c.clear_cache() +diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py +index f4fec95a..9dda4af5 100644 +--- a/mesonbuild/mesonmain.py ++++ b/mesonbuild/mesonmain.py +@@ -32,8 +32,6 @@ def create_parser(): + coredata.register_builtin_arguments(p) + p.add_argument('--cross-file', default=None, + help='File describing cross compilation environment.') +- p.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option", +- help='Set the value of an option, can be used several times to set multiple options.') + p.add_argument('-v', '--version', action='version', + version=coredata.version) + # See the mesonlib.WrapMode enum for documentation +-- +2.17.0 + diff --git a/0012-Fix-warnlevel-being-renamed-to-warning-level-in-late.patch b/0012-Fix-warnlevel-being-renamed-to-warning-level-in-late.patch new file mode 100644 index 0000000..1bf052b --- /dev/null +++ b/0012-Fix-warnlevel-being-renamed-to-warning-level-in-late.patch @@ -0,0 +1,219 @@ +From ed831fc8624d33252771c49f4369e7262d4685ff Mon Sep 17 00:00:00 2001 +From: Xavier Claessens +Date: Thu, 26 Apr 2018 22:18:46 -0400 +Subject: [PATCH 12/16] Fix --warnlevel being renamed to --warning-level in + latest release + +--- + mesonbuild/coredata.py | 54 ++++++++++++++++----- + mesonbuild/mconf.py | 15 +----- + mesonbuild/mesonmain.py | 9 ++-- + run_unittests.py | 39 +++++++++++++++ + test cases/unit/30 command line/meson.build | 1 + + 5 files changed, 87 insertions(+), 31 deletions(-) + create mode 100644 test cases/unit/30 command line/meson.build + +diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py +index 93a9e718..52d3c7d1 100644 +--- a/mesonbuild/coredata.py ++++ b/mesonbuild/coredata.py +@@ -368,12 +368,6 @@ def get_builtin_option_action(optname): + return 'store_true' + return None + +-def get_builtin_option_destination(optname): +- optname = optname.replace('-', '_') +- if optname == 'warnlevel': +- return 'warning_level' +- return optname +- + def get_builtin_option_default(optname, prefix='', noneIfSuppress=False): + if is_builtin_option(optname): + o = builtin_options[optname] +@@ -391,24 +385,32 @@ def get_builtin_option_default(optname, prefix='', noneIfSuppress=False): + else: + raise RuntimeError('Tried to get the default value for an unknown builtin option \'%s\'.' % optname) + ++def get_builtin_option_cmdline_name(name): ++ if name == 'warning_level': ++ return '--warnlevel' ++ else: ++ return '--' + name.replace('_', '-') ++ + def add_builtin_argument(p, name): + kwargs = {} +- k = get_builtin_option_destination(name) +- c = get_builtin_option_choices(k) +- b = get_builtin_option_action(k) +- h = get_builtin_option_description(k) ++ c = get_builtin_option_choices(name) ++ b = get_builtin_option_action(name) ++ h = get_builtin_option_description(name) + if not b: +- h = h.rstrip('.') + ' (default: %s).' % get_builtin_option_default(k) ++ h = h.rstrip('.') + ' (default: %s).' % get_builtin_option_default(name) + else: + kwargs['action'] = b + if c and not b: + kwargs['choices'] = c +- default = get_builtin_option_default(k, noneIfSuppress=True) ++ default = get_builtin_option_default(name, noneIfSuppress=True) + if default is not None: + kwargs['default'] = default + else: + kwargs['default'] = argparse.SUPPRESS +- p.add_argument('--' + name.replace('_', '-'), help=h, **kwargs) ++ kwargs['dest'] = name ++ ++ cmdline_name = get_builtin_option_cmdline_name(name) ++ p.add_argument(cmdline_name, help=h, **kwargs) + + def register_builtin_arguments(parser): + for n in builtin_options: +@@ -416,6 +418,32 @@ def register_builtin_arguments(parser): + parser.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option", + help='Set the value of an option, can be used several times to set multiple options.') + ++def filter_builtin_options(args, original_args): ++ """Filter out any builtin arguments passed as -- instead of -D. ++ ++ Error if an argument is passed with -- and -D ++ """ ++ for name in builtin_options: ++ # Check if user passed --option. Cannot use hasattr(args, name) here ++ # because they are all set with default value if user didn't pass it. ++ cmdline_name = get_builtin_option_cmdline_name(name) ++ has_dashdash = any([a.startswith(cmdline_name) for a in original_args]) ++ ++ # Chekc if user passed -Doption=value ++ has_dashd = any([a.startswith('{}='.format(name)) for a in args.projectoptions]) ++ ++ # Passing both is ambigous, abort ++ if has_dashdash and has_dashd: ++ raise MesonException( ++ 'Got argument {0} as both -D{0} and {1}. Pick one.'.format(name, cmdline_name)) ++ ++ # Pretend --option never existed ++ if has_dashdash: ++ args.projectoptions.append('{}={}'.format(name, getattr(args, name))) ++ if hasattr(args, name): ++ delattr(args, name) ++ ++ + builtin_options = { + 'buildtype': [UserComboOption, 'Build type to use.', ['plain', 'debug', 'debugoptimized', 'release', 'minsize'], 'debug'], + 'strip': [UserBooleanOption, 'Strip targets on install.', False], +diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py +index f907d752..1375b2e0 100644 +--- a/mesonbuild/mconf.py ++++ b/mesonbuild/mconf.py +@@ -28,19 +28,6 @@ def buildparser(): + return parser + + +-def filter_builtin_options(args, original_args): +- """Filter out any args passed with -- instead of -D.""" +- for arg in original_args: +- if not arg.startswith('--') or arg == '--clearcache': +- continue +- name = arg.lstrip('--').split('=', 1)[0] +- if any([a.startswith(name + '=') for a in args.projectoptions]): +- raise mesonlib.MesonException( +- 'Got argument {0} as both -D{0} and --{0}. Pick one.'.format(name)) +- args.projectoptions.append('{}={}'.format(name, getattr(args, name))) +- delattr(args, name) +- +- + class ConfException(mesonlib.MesonException): + pass + +@@ -242,7 +229,7 @@ def run(args): + if not args: + args = [os.getcwd()] + options = buildparser().parse_args(args) +- filter_builtin_options(options, args) ++ coredata.filter_builtin_options(options, args) + if len(options.directory) > 1: + print('%s ' % args[0]) + print('If you omit the build directory, the current directory is substituted.') +diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py +index 9dda4af5..2b6281d7 100644 +--- a/mesonbuild/mesonmain.py ++++ b/mesonbuild/mesonmain.py +@@ -61,11 +61,12 @@ def filter_builtin_options(args, original_args): + if meson_opts: + for arg in meson_opts: + value = arguments[arg] +- if any([a.startswith('--{}'.format(arg)) for a in original_args]): ++ cmdline_name = coredata.get_builtin_option_cmdline_name(arg) ++ if any([a.startswith(cmdline_name) for a in original_args]): + raise MesonException( +- 'Argument "{0}" passed as both --{0} and -D{0}, but only ' +- 'one is allowed'.format(arg)) +- setattr(args, coredata.get_builtin_option_destination(arg), value) ++ 'Argument "{0}" passed as both {1} and -D{0}, but only ' ++ 'one is allowed'.format(arg, cmdline_name)) ++ setattr(args, arg, value) + + # Remove the builtin option from the project args values + args.projectoptions.remove('{}={}'.format(arg, value)) +diff --git a/run_unittests.py b/run_unittests.py +index 3f80f74f..2a466db0 100755 +--- a/run_unittests.py ++++ b/run_unittests.py +@@ -2020,6 +2020,45 @@ recommended as it can lead to undefined behaviour on some platforms''') + self.builddir = exebuilddir + self.assertRebuiltTarget('app') + ++ def test_command_line(self): ++ testdir = os.path.join(self.unit_test_dir, '30 command line') ++ ++ # Verify default values when passing no args ++ self.init(testdir) ++ obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['warning_level'].value, '1') ++ self.wipe() ++ ++ # warning_level is special, it's --warnlevel instead of --warning-level ++ # for historical reasons ++ self.init(testdir, extra_args=['--warnlevel=2']) ++ obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['warning_level'].value, '2') ++ self.setconf('--warnlevel=3') ++ obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['warning_level'].value, '3') ++ self.wipe() ++ ++ # But when using -D syntax, it should be 'warning_level' ++ self.init(testdir, extra_args=['-Dwarning_level=2']) ++ obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['warning_level'].value, '2') ++ self.setconf('-Dwarning_level=3') ++ obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['warning_level'].value, '3') ++ self.wipe() ++ ++ # Mixing --option and -Doption is forbidden ++ with self.assertRaises(subprocess.CalledProcessError) as e: ++ self.init(testdir, extra_args=['--warnlevel=1', '-Dwarning_level=3']) ++ self.assertNotEqual(0, e.returncode) ++ self.assertIn('passed as both', e.stderr) ++ with self.assertRaises(subprocess.CalledProcessError) as e: ++ self.setconf('--warnlevel=1', '-Dwarning_level=3') ++ self.assertNotEqual(0, e.returncode) ++ self.assertIn('passed as both', e.stderr) ++ self.wipe() ++ + + class FailureTests(BasePlatformTests): + ''' +diff --git a/test cases/unit/30 command line/meson.build b/test cases/unit/30 command line/meson.build +new file mode 100644 +index 00000000..2ab21b6e +--- /dev/null ++++ b/test cases/unit/30 command line/meson.build +@@ -0,0 +1 @@ ++project('command line test', 'c') +-- +2.17.0 + diff --git a/0013-Passing-default-library-both-should-override-project.patch b/0013-Passing-default-library-both-should-override-project.patch new file mode 100644 index 0000000..f390283 --- /dev/null +++ b/0013-Passing-default-library-both-should-override-project.patch @@ -0,0 +1,67 @@ +From 73adac113efb54643dd85474d0273391722ac422 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens +Date: Fri, 27 Apr 2018 11:11:22 -0400 +Subject: [PATCH 13/16] Passing --default-library=both should override project + value + +Looks like this has always been broken, had_argument_for() was checking +if we have --default_library instead of --default-library. +--- + mesonbuild/environment.py | 2 +- + run_unittests.py | 10 ++++++++++ + test cases/unit/30 command line/meson.build | 4 +++- + 3 files changed, 14 insertions(+), 2 deletions(-) + +diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py +index 6920b8d6..15b37378 100644 +--- a/mesonbuild/environment.py ++++ b/mesonbuild/environment.py +@@ -373,7 +373,7 @@ class Environment: + return is_library(fname) + + def had_argument_for(self, option): +- trial1 = '--' + option ++ trial1 = coredata.get_builtin_option_cmdline_name(option) + trial2 = '-D' + option + previous_is_plaind = False + for i in self.original_cmd_line_args: +diff --git a/run_unittests.py b/run_unittests.py +index 2a466db0..ff8d7c66 100755 +--- a/run_unittests.py ++++ b/run_unittests.py +@@ -2026,6 +2026,7 @@ recommended as it can lead to undefined behaviour on some platforms''') + # Verify default values when passing no args + self.init(testdir) + obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['default_library'].value, 'static') + self.assertEqual(obj.builtins['warning_level'].value, '1') + self.wipe() + +@@ -2059,6 +2060,15 @@ recommended as it can lead to undefined behaviour on some platforms''') + self.assertIn('passed as both', e.stderr) + self.wipe() + ++ # --default-library should override default value from project() ++ self.init(testdir, extra_args=['--default-library=both']) ++ obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['default_library'].value, 'both') ++ self.setconf('--default-library=shared') ++ obj = mesonbuild.coredata.load(self.builddir) ++ self.assertEqual(obj.builtins['default_library'].value, 'shared') ++ self.wipe() ++ + + class FailureTests(BasePlatformTests): + ''' +diff --git a/test cases/unit/30 command line/meson.build b/test cases/unit/30 command line/meson.build +index 2ab21b6e..1006f49c 100644 +--- a/test cases/unit/30 command line/meson.build ++++ b/test cases/unit/30 command line/meson.build +@@ -1 +1,3 @@ +-project('command line test', 'c') ++project('command line test', 'c', ++ default_options : ['default_library=static'] ++) +-- +2.17.0 + diff --git a/0014-Allow-required-false-for-OpenMP-dependency.patch b/0014-Allow-required-false-for-OpenMP-dependency.patch new file mode 100644 index 0000000..d5e574f --- /dev/null +++ b/0014-Allow-required-false-for-OpenMP-dependency.patch @@ -0,0 +1,33 @@ +From 72e56d63958f323476b16f69ccd38ed09a8fa3e7 Mon Sep 17 00:00:00 2001 +From: David Seifert +Date: Tue, 1 May 2018 14:21:02 +0200 +Subject: [PATCH 14/16] Allow `required : false` for OpenMP dependency + +* Currently `required : true` is implicitly assumed, making + optional use of OpenMP not possible. +--- + mesonbuild/dependencies/misc.py | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py +index d4525b11..cf84123d 100644 +--- a/mesonbuild/dependencies/misc.py ++++ b/mesonbuild/dependencies/misc.py +@@ -253,7 +253,13 @@ class OpenMPDependency(ExternalDependency): + language = kwargs.get('language') + super().__init__('openmp', environment, language, kwargs) + self.is_found = False +- openmp_date = self.compiler.get_define('_OPENMP', '', self.env, [], [self]) ++ try: ++ openmp_date = self.compiler.get_define('_OPENMP', '', self.env, [], [self]) ++ except mesonlib.EnvironmentException as e: ++ mlog.debug('OpenMP support not available in the compiler') ++ mlog.debug(e) ++ openmp_date = False ++ + if openmp_date: + self.version = self.VERSIONS[openmp_date] + if self.compiler.has_header('omp.h', '', self.env, dependencies=[self]): +-- +2.17.0 + diff --git a/0015-Keep-separator-spaces-in-pkg-config-declarations.-Cl.patch b/0015-Keep-separator-spaces-in-pkg-config-declarations.-Cl.patch new file mode 100644 index 0000000..6d0c107 --- /dev/null +++ b/0015-Keep-separator-spaces-in-pkg-config-declarations.-Cl.patch @@ -0,0 +1,91 @@ +From b8554145f1c1766cc94b7772e0f75a211cfb2379 Mon Sep 17 00:00:00 2001 +From: Jussi Pakkanen +Date: Sun, 29 Apr 2018 21:43:24 +0300 +Subject: [PATCH 15/16] Keep separator spaces in pkg-config declarations. + Closes #3479. + +--- + mesonbuild/modules/pkgconfig.py | 6 ++++-- + run_unittests.py | 11 +++++++++++ + test cases/unit/31 pkgconfig format/meson.build | 17 +++++++++++++++++ + test cases/unit/31 pkgconfig format/somelib.c | 5 +++++ + 4 files changed, 37 insertions(+), 2 deletions(-) + create mode 100644 test cases/unit/31 pkgconfig format/meson.build + create mode 100644 test cases/unit/31 pkgconfig format/somelib.c + +diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py +index a3ba973f..419a14c7 100644 +--- a/mesonbuild/modules/pkgconfig.py ++++ b/mesonbuild/modules/pkgconfig.py +@@ -139,8 +139,10 @@ class DependenciesHelper: + if version_reqs: + if name not in self.version_reqs: + self.version_reqs[name] = set() +- # We could have '>=1.0' or '>= 1.0', remove spaces to normalize +- new_vreqs = [s.replace(' ', '') for s in mesonlib.stringlistify(version_reqs)] ++ # Note that pkg-config is picky about whitespace. ++ # 'foo > 1.2' is ok but 'foo>1.2' is not. ++ # foo, bar' is ok, but 'foo,bar' is not. ++ new_vreqs = [s for s in mesonlib.stringlistify(version_reqs)] + self.version_reqs[name].update(new_vreqs) + + def split_version_req(self, s): +diff --git a/run_unittests.py b/run_unittests.py +index ff8d7c66..6773bbd1 100755 +--- a/run_unittests.py ++++ b/run_unittests.py +@@ -2983,6 +2983,17 @@ endian = 'little' + self.init(os.path.join(testdirbase, 'app')) + self.build() + ++ @unittest.skipIf(shutil.which('pkg-config') is None, 'Pkg-config not found.') ++ def test_pkgconfig_formatting(self): ++ testdir = os.path.join(self.unit_test_dir, '31 pkgconfig format') ++ self.init(testdir) ++ myenv = os.environ.copy() ++ myenv['PKG_CONFIG_PATH'] = self.privatedir ++ ro = subprocess.run(['pkg-config', '--libs', 'libsomething'], stdout=subprocess.PIPE, ++ env=myenv) ++ self.assertEqual(ro.returncode, 0) ++ self.assertIn(b'-lgobject-2.0', ro.stdout) ++ self.assertIn(b'-lgio-2.0', ro.stdout) + + class LinuxArmCrossCompileTests(BasePlatformTests): + ''' +diff --git a/test cases/unit/31 pkgconfig format/meson.build b/test cases/unit/31 pkgconfig format/meson.build +new file mode 100644 +index 00000000..bbd3b125 +--- /dev/null ++++ b/test cases/unit/31 pkgconfig format/meson.build +@@ -0,0 +1,17 @@ ++project('pkgformat', 'c', ++ version : '1.0') ++ ++gio = dependency('gio-2.0', required: false) ++if not gio.found() ++ error('MESON_SKIP_TEST glib not found.') ++endif ++ ++pkgg = import('pkgconfig') ++ ++l = shared_library('something', 'somelib.c') ++ ++pkgg.generate(libraries: l, ++ version: '1.0', ++ name: 'libsomething', ++ description: 'A library that does something', ++ requires: 'gobject-2.0 >= 2.54, gio-2.0 >= 2.54') +diff --git a/test cases/unit/31 pkgconfig format/somelib.c b/test cases/unit/31 pkgconfig format/somelib.c +new file mode 100644 +index 00000000..6d876c8f +--- /dev/null ++++ b/test cases/unit/31 pkgconfig format/somelib.c +@@ -0,0 +1,5 @@ ++#include ++ ++int some_func() { ++ return 0; ++} +-- +2.17.0 + diff --git a/0016-pkgconfig-Don-t-expose-internal-libraries-in-.pc-fil.patch b/0016-pkgconfig-Don-t-expose-internal-libraries-in-.pc-fil.patch new file mode 100644 index 0000000..8d037e3 --- /dev/null +++ b/0016-pkgconfig-Don-t-expose-internal-libraries-in-.pc-fil.patch @@ -0,0 +1,132 @@ +From a3b2ae8ebcdcebd68b8a217d03102c6d03fcb766 Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan +Date: Tue, 1 May 2018 17:54:54 +0530 +Subject: [PATCH 16/16] pkgconfig: Don't expose internal libraries in .pc files + +Libraries that have been linked with link_whole: are internal +implementation details and should never be exposed to the outside +world in either Libs: or Libs.private: + +Closes https://github.com/mesonbuild/meson/issues/3509 +--- + mesonbuild/build.py | 12 +++++++++--- + mesonbuild/modules/pkgconfig.py | 4 ++-- + run_unittests.py | 11 ++++++----- + test cases/unit/31 pkgconfig format/meson.build | 5 +++-- + test cases/unit/31 pkgconfig format/somelib.c | 4 +++- + test cases/unit/31 pkgconfig format/someret.c | 3 +++ + 6 files changed, 26 insertions(+), 13 deletions(-) + create mode 100644 test cases/unit/31 pkgconfig format/someret.c + +diff --git a/mesonbuild/build.py b/mesonbuild/build.py +index 3d531d18..a2d024ae 100644 +--- a/mesonbuild/build.py ++++ b/mesonbuild/build.py +@@ -817,16 +817,22 @@ This will become a hard error in a future Meson release.''') + def get_extra_args(self, language): + return self.extra_args.get(language, []) + +- def get_dependencies(self, exclude=None): ++ def get_dependencies(self, exclude=None, internal=True): + transitive_deps = [] + if exclude is None: + exclude = [] +- for t in itertools.chain(self.link_targets, self.link_whole_targets): ++ if internal: ++ link_targets = itertools.chain(self.link_targets, self.link_whole_targets) ++ else: ++ # We don't want the 'internal' libraries when generating the ++ # `Libs:` and `Libs.private:` lists in pkg-config files. ++ link_targets = self.link_targets ++ for t in link_targets: + if t in transitive_deps or t in exclude: + continue + transitive_deps.append(t) + if isinstance(t, StaticLibrary): +- transitive_deps += t.get_dependencies(transitive_deps + exclude) ++ transitive_deps += t.get_dependencies(transitive_deps + exclude, internal) + return transitive_deps + + def get_source_subdir(self): +diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py +index 419a14c7..365d3cd3 100644 +--- a/mesonbuild/modules/pkgconfig.py ++++ b/mesonbuild/modules/pkgconfig.py +@@ -123,10 +123,10 @@ class DependenciesHelper: + if not hasattr(obj, 'generated_pc'): + obj.generated_pc = self.name + if isinstance(obj, build.StaticLibrary) and public: +- self.add_pub_libs(obj.get_dependencies()) ++ self.add_pub_libs(obj.get_dependencies(internal=False)) + self.add_pub_libs(obj.get_external_deps()) + else: +- self.add_priv_libs(obj.get_dependencies()) ++ self.add_priv_libs(obj.get_dependencies(internal=False)) + self.add_priv_libs(obj.get_external_deps()) + elif isinstance(obj, str): + processed_libs.append(obj) +diff --git a/run_unittests.py b/run_unittests.py +index 6773bbd1..befba2d1 100755 +--- a/run_unittests.py ++++ b/run_unittests.py +@@ -2989,11 +2989,12 @@ endian = 'little' + self.init(testdir) + myenv = os.environ.copy() + myenv['PKG_CONFIG_PATH'] = self.privatedir +- ro = subprocess.run(['pkg-config', '--libs', 'libsomething'], stdout=subprocess.PIPE, +- env=myenv) +- self.assertEqual(ro.returncode, 0) +- self.assertIn(b'-lgobject-2.0', ro.stdout) +- self.assertIn(b'-lgio-2.0', ro.stdout) ++ stdo = subprocess.check_output(['pkg-config', '--libs-only-l', 'libsomething'], env=myenv) ++ deps = [b'-lgobject-2.0', b'-lgio-2.0', b'-lglib-2.0', b'-lsomething'] ++ if is_windows() or is_cygwin(): ++ # On Windows, libintl is a separate library ++ deps.append(b'-lintl') ++ self.assertEqual(set(deps), set(stdo.split())) + + class LinuxArmCrossCompileTests(BasePlatformTests): + ''' +diff --git a/test cases/unit/31 pkgconfig format/meson.build b/test cases/unit/31 pkgconfig format/meson.build +index bbd3b125..ea00f5df 100644 +--- a/test cases/unit/31 pkgconfig format/meson.build ++++ b/test cases/unit/31 pkgconfig format/meson.build +@@ -8,10 +8,11 @@ endif + + pkgg = import('pkgconfig') + +-l = shared_library('something', 'somelib.c') ++s = static_library('returner', 'someret.c') ++l = library('something', 'somelib.c', link_whole: s) + + pkgg.generate(libraries: l, + version: '1.0', + name: 'libsomething', + description: 'A library that does something', +- requires: 'gobject-2.0 >= 2.54, gio-2.0 >= 2.54') ++ requires: 'gobject-2.0 >= 2.0, gio-2.0 >= 2.0') +diff --git a/test cases/unit/31 pkgconfig format/somelib.c b/test cases/unit/31 pkgconfig format/somelib.c +index 6d876c8f..0558024b 100644 +--- a/test cases/unit/31 pkgconfig format/somelib.c ++++ b/test cases/unit/31 pkgconfig format/somelib.c +@@ -1,5 +1,7 @@ + #include + ++int get_returnvalue (void); ++ + int some_func() { +- return 0; ++ return get_returnvalue(); + } +diff --git a/test cases/unit/31 pkgconfig format/someret.c b/test cases/unit/31 pkgconfig format/someret.c +new file mode 100644 +index 00000000..69f42992 +--- /dev/null ++++ b/test cases/unit/31 pkgconfig format/someret.c +@@ -0,0 +1,3 @@ ++int get_returnvalue (void) { ++ return 0; ++} +-- +2.17.0 + diff --git a/meson.spec b/meson.spec index af207be..d3bdaca 100644 --- a/meson.spec +++ b/meson.spec @@ -4,12 +4,29 @@ Name: meson Version: 0.46.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: High productivity build system License: ASL 2.0 URL: http://mesonbuild.com/ Source0: https://github.com/mesonbuild/meson/archive/%{version}/%{name}-%{version}.tar.gz +# Patches from 0.46 branch +Patch0001: 0001-guess_external_link_dependencies-deduplicate-search-.patch +Patch0002: 0002-CCompiler-Cache-result-of-get_library_dirs.patch +Patch0003: 0003-New-argument-profile-self-for-profiling-performance.patch +Patch0004: 0004-Install-generated-gdbus-header-with-old-glib-version.patch +Patch0005: 0005-has_multi_link_arguments-Some-compilers-needs-Wl-fat.patch +Patch0006: 0006-Add-test-to-show-issue.patch +Patch0007: 0007-Allow-custom_target-do-depend-on-indexed-output-of-c.patch +Patch0008: 0008-Fix-setting-c_args-and-friends-from-command-line.patch +Patch0009: 0009-Made-depfixer-more-robust-on-OSX.-Closes-3493.patch +Patch0010: 0010-Always-generate-a-new-Product-GUID.-Closes-2485.-ski.patch +Patch0011: 0011-Remove-duplicated-definition-of-D-cmdline-arg.patch +Patch0012: 0012-Fix-warnlevel-being-renamed-to-warning-level-in-late.patch +Patch0013: 0013-Passing-default-library-both-should-override-project.patch +Patch0014: 0014-Allow-required-false-for-OpenMP-dependency.patch +Patch0015: 0015-Keep-separator-spaces-in-pkg-config-declarations.-Cl.patch +Patch0016: 0016-pkgconfig-Don-t-expose-internal-libraries-in-.pc-fil.patch BuildArch: noarch Obsoletes: %{name}-gui < 0.31.0-3 @@ -30,7 +47,7 @@ BuildRequires: mono-core mono-devel BuildRequires: rust # No ldc as of RHEL7 and on non-ldc arches %if ! 0%{?rhel} || 0%{?rhel} > 7 -# Since the build is noarch, we can't use %ifarch +# Since the build is noarch, we can't use %%ifarch #%%ifarch %%{ldc_arches} #BuildRequires: ldc #%%endif @@ -79,7 +96,6 @@ unit tests, coverage reports, Valgrind, CCache and the like. %prep %autosetup -p1 -find -type f -name '*.py' -executable -exec sed -i -e '1s|.*|#!%{__python3}|' {} ';' # Remove MPI tests for now because it is complicated to run rm -rf "test cases/frameworks/17 mpi" @@ -113,6 +129,9 @@ export MESON_PRINT_TEST_OUTPUT=1 %{rpmmacrodir}/macros.%{name} %changelog +* Fri May 04 2018 Igor Gnatenko - 0.46.0-2 +- Backport upstream fixes + * Tue Apr 24 2018 Igor Gnatenko - 0.46.0-1 - Update to 0.46.0