aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Disabler.md2
-rw-r--r--mesonbuild/build.py2
-rw-r--r--mesonbuild/compilers/compilers.py7
-rwxr-xr-xrun_unittests.py7
-rw-r--r--test cases/unit/11 build_rpath/meson.build9
-rw-r--r--test cases/unit/11 build_rpath/prog.cc8
6 files changed, 31 insertions, 4 deletions
diff --git a/docs/markdown/Disabler.md b/docs/markdown/Disabler.md
index bd2b322..81417f6 100644
--- a/docs/markdown/Disabler.md
+++ b/docs/markdown/Disabler.md
@@ -63,4 +63,4 @@ endif
This concentrates the handling of this option in one place and other
build definition files do not need to be sprinkled with `if`
-statements. \ No newline at end of file
+statements.
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 7757300..4a35bec 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1776,7 +1776,7 @@ class CustomTargetIndex:
def __repr__(self):
return '<CustomTargetIndex: {!r}[{}]>'.format(
- self.target, self.target.output.index(self.output))
+ self.target, self.target.get_outputs().index(self.output))
def get_outputs(self):
return [self.output]
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 3d50eb0..24ae3c9 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -863,7 +863,12 @@ class Compiler:
# Not needed on Windows or other platforms that don't use RPATH
# https://github.com/mesonbuild/meson/issues/1897
lpaths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths])
- args += ['-Wl,-rpath-link,' + lpaths]
+
+ # clang expands '-Wl,rpath-link,' to ['-rpath-link'] instead of ['-rpath-link','']
+ # This eats the next argument, which happens to be 'ldstdc++', causing link failures.
+ # We can dodge this problem by not adding any rpath_paths if the argument is empty.
+ if lpaths.strip() != '':
+ args += ['-Wl,-rpath-link,' + lpaths]
return args
diff --git a/run_unittests.py b/run_unittests.py
index 9706b45..17badae 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2288,11 +2288,18 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '11 build_rpath')
self.init(testdir)
self.build()
+ # C program RPATH
build_rpath = get_rpath(os.path.join(self.builddir, 'prog'))
self.assertEqual(build_rpath, '$ORIGIN/sub:/foo/bar')
self.install()
install_rpath = get_rpath(os.path.join(self.installdir, 'usr/bin/prog'))
self.assertEqual(install_rpath, '/baz')
+ # C++ program RPATH
+ build_rpath = get_rpath(os.path.join(self.builddir, 'progcxx'))
+ self.assertEqual(build_rpath, '$ORIGIN/sub:/foo/bar')
+ self.install()
+ install_rpath = get_rpath(os.path.join(self.installdir, 'usr/bin/progcxx'))
+ self.assertEqual(install_rpath, 'baz')
def test_pch_with_address_sanitizer(self):
testdir = os.path.join(self.common_test_dir, '13 pch')
diff --git a/test cases/unit/11 build_rpath/meson.build b/test cases/unit/11 build_rpath/meson.build
index b84c259..c0bc3bd 100644
--- a/test cases/unit/11 build_rpath/meson.build
+++ b/test cases/unit/11 build_rpath/meson.build
@@ -1,4 +1,4 @@
-project('build rpath', 'c')
+project('build rpath', 'c', 'cpp')
subdir('sub')
executable('prog', 'prog.c',
@@ -7,3 +7,10 @@ executable('prog', 'prog.c',
install_rpath : '/baz',
install : true,
)
+
+executable('progcxx', 'prog.cc',
+ link_with : l,
+ build_rpath : '/foo/bar',
+ install_rpath : 'baz',
+ install : true,
+ )
diff --git a/test cases/unit/11 build_rpath/prog.cc b/test cases/unit/11 build_rpath/prog.cc
new file mode 100644
index 0000000..c7c2123
--- /dev/null
+++ b/test cases/unit/11 build_rpath/prog.cc
@@ -0,0 +1,8 @@
+#include <string>
+#include <iostream>
+
+int main(int argc, char **argv) {
+ std::string* s = new std::string("Hello");
+ delete s;
+ return 0;
+}