Merge pull request #2826 from bredelings/fix-clang-on-linux

Fix linking with clang++ on linux if install_rpath.
pull/2832/head
Jussi Pakkanen 7 years ago committed by GitHub
commit d0d07a6fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      mesonbuild/compilers/compilers.py
  2. 7
      run_unittests.py
  3. 9
      test cases/unit/11 build_rpath/meson.build
  4. 8
      test cases/unit/11 build_rpath/prog.cc

@ -863,6 +863,11 @@ class Compiler:
# Not needed on Windows or other platforms that don't use RPATH # Not needed on Windows or other platforms that don't use RPATH
# https://github.com/mesonbuild/meson/issues/1897 # https://github.com/mesonbuild/meson/issues/1897
lpaths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths]) lpaths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths])
# 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] args += ['-Wl,-rpath-link,' + lpaths]
return args return args

@ -2288,11 +2288,18 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '11 build_rpath') testdir = os.path.join(self.unit_test_dir, '11 build_rpath')
self.init(testdir) self.init(testdir)
self.build() self.build()
# C program RPATH
build_rpath = get_rpath(os.path.join(self.builddir, 'prog')) build_rpath = get_rpath(os.path.join(self.builddir, 'prog'))
self.assertEqual(build_rpath, '$ORIGIN/sub:/foo/bar') self.assertEqual(build_rpath, '$ORIGIN/sub:/foo/bar')
self.install() self.install()
install_rpath = get_rpath(os.path.join(self.installdir, 'usr/bin/prog')) install_rpath = get_rpath(os.path.join(self.installdir, 'usr/bin/prog'))
self.assertEqual(install_rpath, '/baz') 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): def test_pch_with_address_sanitizer(self):
testdir = os.path.join(self.common_test_dir, '13 pch') testdir = os.path.join(self.common_test_dir, '13 pch')

@ -1,4 +1,4 @@
project('build rpath', 'c') project('build rpath', 'c', 'cpp')
subdir('sub') subdir('sub')
executable('prog', 'prog.c', executable('prog', 'prog.c',
@ -7,3 +7,10 @@ executable('prog', 'prog.c',
install_rpath : '/baz', install_rpath : '/baz',
install : true, install : true,
) )
executable('progcxx', 'prog.cc',
link_with : l,
build_rpath : '/foo/bar',
install_rpath : 'baz',
install : true,
)

@ -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;
}
Loading…
Cancel
Save