diff options
author | Rafael Ăvila de EspĂndola <rafael@espindo.la> | 2018-07-25 09:40:54 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-07-25 19:40:54 +0300 |
commit | c7360dd426f06c67c9ceca85c0e36e02ae61c18b (patch) | |
tree | 856cf53bb348c77d834f92dffe7214b1ecd28ac1 | |
parent | 10a1a39961613a2a77604ef287df42efd441574c (diff) | |
download | meson-c7360dd426f06c67c9ceca85c0e36e02ae61c18b.zip meson-c7360dd426f06c67c9ceca85c0e36e02ae61c18b.tar.gz meson-c7360dd426f06c67c9ceca85c0e36e02ae61c18b.tar.bz2 |
Make the rpath order deterministic. (#3932)
-rw-r--r-- | mesonbuild/backend/backends.py | 2 | ||||
-rwxr-xr-x | run_unittests.py | 19 | ||||
-rw-r--r-- | test cases/unit/35 rpath order/meson.build | 11 | ||||
-rw-r--r-- | test cases/unit/35 rpath order/myexe.c | 3 | ||||
-rw-r--r-- | test cases/unit/35 rpath order/subprojects/sub1/lib.c | 0 | ||||
-rw-r--r-- | test cases/unit/35 rpath order/subprojects/sub1/meson.build | 5 | ||||
-rw-r--r-- | test cases/unit/35 rpath order/subprojects/sub2/lib.c | 0 | ||||
-rw-r--r-- | test cases/unit/35 rpath order/subprojects/sub2/meson.build | 5 |
8 files changed, 44 insertions, 1 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 354d25a..0e2389d 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -376,7 +376,7 @@ class Backend: def determine_rpath_dirs(self, target): link_deps = target.get_all_link_deps() - result = set() + result = OrderedSet() for ld in link_deps: if ld is target: continue diff --git a/run_unittests.py b/run_unittests.py index 912c843..1e5ce99 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3600,6 +3600,25 @@ endian = 'little' return raise RuntimeError('Could not find the build rule') + def test_deterministic_rpath_order(self): + ''' + Test that the rpaths are always listed in a deterministic order. + ''' + if is_cygwin(): + raise unittest.SkipTest('rpath are not used on Cygwin') + testdir = os.path.join(self.unit_test_dir, '35 rpath order') + self.init(testdir) + if is_osx(): + rpathre = re.compile('-rpath,.*/subprojects/sub1.*-rpath,.*/subprojects/sub2') + else: + rpathre = re.compile('-rpath,\$\$ORIGIN/subprojects/sub1:\$\$ORIGIN/subprojects/sub2') + with open(os.path.join(self.builddir, 'build.ninja')) as bfile: + for line in bfile: + if '-rpath' in line: + self.assertRegex(line, rpathre) + return + raise RuntimeError('Could not find the rpath') + @skipIfNoPkgconfig def test_usage_external_library(self): ''' diff --git a/test cases/unit/35 rpath order/meson.build b/test cases/unit/35 rpath order/meson.build new file mode 100644 index 0000000..a722894 --- /dev/null +++ b/test cases/unit/35 rpath order/meson.build @@ -0,0 +1,11 @@ +project('myexe', 'c') + +sub1 = subproject('sub1') +sub1_dep = sub1.get_variable('sub1_dep') + +sub2 = subproject('sub2') +sub2_dep = sub2.get_variable('sub2_dep') + +executable('myexe', + 'myexe.c', + dependencies: [sub1_dep, sub2_dep]) diff --git a/test cases/unit/35 rpath order/myexe.c b/test cases/unit/35 rpath order/myexe.c new file mode 100644 index 0000000..03b2213 --- /dev/null +++ b/test cases/unit/35 rpath order/myexe.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/unit/35 rpath order/subprojects/sub1/lib.c b/test cases/unit/35 rpath order/subprojects/sub1/lib.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/35 rpath order/subprojects/sub1/lib.c diff --git a/test cases/unit/35 rpath order/subprojects/sub1/meson.build b/test cases/unit/35 rpath order/subprojects/sub1/meson.build new file mode 100644 index 0000000..4dd5d08 --- /dev/null +++ b/test cases/unit/35 rpath order/subprojects/sub1/meson.build @@ -0,0 +1,5 @@ +project('sub1', 'c') + +sub1_lib = library('sub1', 'lib.c') + +sub1_dep = declare_dependency(link_with : sub1_lib) diff --git a/test cases/unit/35 rpath order/subprojects/sub2/lib.c b/test cases/unit/35 rpath order/subprojects/sub2/lib.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/35 rpath order/subprojects/sub2/lib.c diff --git a/test cases/unit/35 rpath order/subprojects/sub2/meson.build b/test cases/unit/35 rpath order/subprojects/sub2/meson.build new file mode 100644 index 0000000..bc3510d --- /dev/null +++ b/test cases/unit/35 rpath order/subprojects/sub2/meson.build @@ -0,0 +1,5 @@ +project('sub2', 'c') + +sub2_lib = library('sub2', 'lib.c') + +sub2_dep = declare_dependency(link_with : sub2_lib) |