aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2019-11-22 13:26:53 -0500
committerXavier Claessens <xclaesse@gmail.com>2019-11-25 20:34:37 -0500
commit7dd302773dd2d6443ab52d608d1c86aef578f280 (patch)
treedd4d9b9ab16ab831265b93a4e0b691fdbdb397e2 /test cases
parentf0565e6dc80c857b6035b9a754b0495137db64ae (diff)
downloadmeson-7dd302773dd2d6443ab52d608d1c86aef578f280.zip
meson-7dd302773dd2d6443ab52d608d1c86aef578f280.tar.gz
meson-7dd302773dd2d6443ab52d608d1c86aef578f280.tar.bz2
Fix link_whole with a custom target
t.pic won't be defined. We can only hope it has been built with -fPIC. Linker will complain otherwise any way. t.extract_all_objects_recurse() won't be defined. We could support this case by extracting the archive somewhere and pick object files.
Diffstat (limited to 'test cases')
-rwxr-xr-xtest cases/common/215 link custom/custom_stlib.py8
-rw-r--r--test cases/common/215 link custom/lib.c7
-rw-r--r--test cases/common/215 link custom/meson.build2
3 files changed, 17 insertions, 0 deletions
diff --git a/test cases/common/215 link custom/custom_stlib.py b/test cases/common/215 link custom/custom_stlib.py
index 2e61ac9..0157fb1 100755
--- a/test cases/common/215 link custom/custom_stlib.py
+++ b/test cases/common/215 link custom/custom_stlib.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import shutil, sys, subprocess, argparse, pathlib
+import platform
parser = argparse.ArgumentParser()
@@ -15,6 +16,12 @@ void flob(void) {
}
'''
+def get_pic_args():
+ platname = platform.system().lower()
+ if platname in ['windows', 'mingw', 'darwin'] or platname.startswith('cygwin'):
+ return []
+ return ['-fPIC']
+
def generate_lib_gnulike(outfile, c_file, private_dir, compiler_array):
if shutil.which('ar'):
static_linker = 'ar'
@@ -26,6 +33,7 @@ def generate_lib_gnulike(outfile, c_file, private_dir, compiler_array):
sys.exit('Could not detect a static linker.')
o_file = c_file.with_suffix('.o')
compile_cmd = compiler_array + ['-c', '-g', '-O2', '-o', str(o_file), str(c_file)]
+ compile_cmd += get_pic_args()
subprocess.check_call(compile_cmd)
out_file = pathlib.Path(outfile)
if out_file.exists():
diff --git a/test cases/common/215 link custom/lib.c b/test cases/common/215 link custom/lib.c
new file mode 100644
index 0000000..585b6c9
--- /dev/null
+++ b/test cases/common/215 link custom/lib.c
@@ -0,0 +1,7 @@
+void flob(void);
+
+int foo(void)
+{
+ flob();
+ return 0;
+}
diff --git a/test cases/common/215 link custom/meson.build b/test cases/common/215 link custom/meson.build
index c8d3a6d..013da04 100644
--- a/test cases/common/215 link custom/meson.build
+++ b/test cases/common/215 link custom/meson.build
@@ -46,6 +46,8 @@ d_i = declare_dependency(link_with: clib[0])
exe2_i = executable('prog2_i', 'prog.c', dependencies: d_i)
test('linkcustom2_i', exe2_i)
+shared_library('lib1', 'lib.c', link_whole: clib)
+
# Link whole tests
exe3_i = executable('prog3_i', 'prog.c', link_whole: clib[0])