Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -Wl,-rpath-link for secondary dependencies #5647

Merged
merged 2 commits into from
Sep 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test case for secondary dependencies
SoapGentoo committed Sep 5, 2019
commit 6b5a26933732f83501a1d775e20285204def15e8
39 changes: 39 additions & 0 deletions run_unittests.py
Original file line number Diff line number Diff line change
@@ -5291,6 +5291,45 @@ def test_pkgconfig_internal_libraries(self):
override_envvars={'PKG_CONFIG_PATH': pkg_dir})
self.build()

@skipIfNoPkgconfig
def test_pkgconfig_secondary_dependencies(self):
'''
Check that Meson gets -Wl,-rpath-link right for secondary dependencies

This test requires at least two libraries, as -Wl,-rpath-link is only
required for dependencies of dependencies (i.e. secondary dependencies).
'''
with tempfile.TemporaryDirectory() as tempdirname:
testdirbase = os.path.join(self.unit_test_dir, '63 rpath-link secondary')

# build libA
testdirlibA = os.path.join(testdirbase, 'libA')
testlibAprefix = os.path.join(tempdirname, 'libAprefix')
self.init(testdirlibA, extra_args=['--prefix=' + testlibAprefix,
'--libdir=lib',
'--default-library=shared'], default_args=False)
self.build()
self.install(use_destdir=False)

# build libB (uses libA)
pkg_dir = [os.path.join(testlibAprefix, 'lib/pkgconfig')]
self.new_builddir()
testdirlibB = os.path.join(testdirbase, 'libB')
testlibBprefix = os.path.join(tempdirname, 'libBprefix')
self.init(testdirlibB, extra_args=['--prefix=' + testlibBprefix,
'--libdir=lib',
'--default-library=shared'], default_args=False,
override_envvars={'PKG_CONFIG_PATH': ':'.join(pkg_dir)})
self.build()
self.install(use_destdir=False)

# build executable (uses libB, secondary dependency on libA)
pkg_dir.append(os.path.join(testlibBprefix, 'lib/pkgconfig'))
self.new_builddir()
self.init(os.path.join(testdirbase, 'app'),
override_envvars={'PKG_CONFIG_PATH': ':'.join(pkg_dir)})
self.build()

@skipIfNoPkgconfig
def test_pkgconfig_formatting(self):
testdir = os.path.join(self.unit_test_dir, '38 pkgconfig format')
4 changes: 4 additions & 0 deletions test cases/unit/63 rpath-link secondary/app/app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <stdio.h>
#include <libb.h>

int main() { printf("The answer is: %d\n", libB_func()); }
5 changes: 5 additions & 0 deletions test cases/unit/63 rpath-link secondary/app/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('app', ['c'])

b = dependency('test-b')

executable('app', 'app.c', dependencies : [b])
1 change: 1 addition & 0 deletions test cases/unit/63 rpath-link secondary/libA/liba.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int libA_func() { return 42; }
1 change: 1 addition & 0 deletions test cases/unit/63 rpath-link secondary/libA/liba.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int libA_func();
14 changes: 14 additions & 0 deletions test cases/unit/63 rpath-link secondary/libA/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project('lib', ['c'])

a = library('test-a', 'liba.c', install: true)

install_headers(files('liba.h'))

import('pkgconfig').generate(
a,
version: '0.0',
description: 'test library',
filebase: 'test-a',
name: 'test library',
subdirs: ['.']
)
3 changes: 3 additions & 0 deletions test cases/unit/63 rpath-link secondary/libB/libb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <liba.h>

int libB_func() { return libA_func(); }
1 change: 1 addition & 0 deletions test cases/unit/63 rpath-link secondary/libB/libb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int libB_func();
16 changes: 16 additions & 0 deletions test cases/unit/63 rpath-link secondary/libB/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
project('lib', ['c'])

libA_dep = dependency('test-a')

b = library('test-b', 'libb.c', install: true, dependencies : libA_dep)

install_headers(files('libb.h'))

import('pkgconfig').generate(
b,
version: '0.0',
description: 'test library',
filebase: 'test-b',
name: 'test library',
subdirs: ['.']
)