summaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-10-05 15:58:45 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-10-08 01:02:13 +0530
commitee8b3b12a067c52efcfb7c05c638023fbe0495c8 (patch)
tree85deebaf86566e3ba393611c194af70a5188189d /test cases
parent71eddecdc7e82b16c5e454137d641f2a5f7c9c94 (diff)
downloadmeson-ee8b3b12a067c52efcfb7c05c638023fbe0495c8.tar.gz
Add cross-platform PIC support for static libraries
With C/C++, on Windows you don't need to pass any arguments for a static library to be PIC. On UNIX platforms you need to pass -fPIC. Other languages such as D have compiler-specific PIC arguments required for PIC support in static libraries on UNIX platforms. This kwarg allows people to specify which static libraries should be built with PIC support. This is usually used for static libraries that will be linked into shared libraries.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/62 exe static shared/meson.build5
-rw-r--r--test cases/common/62 exe static shared/prog.c7
-rw-r--r--test cases/common/62 exe static shared/shlib2.c7
-rw-r--r--test cases/common/62 exe static shared/subdir/exports.h12
-rw-r--r--test cases/common/62 exe static shared/subdir/shlib.c11
5 files changed, 29 insertions, 13 deletions
diff --git a/test cases/common/62 exe static shared/meson.build b/test cases/common/62 exe static shared/meson.build
index 3c753910a..8631e68f1 100644
--- a/test cases/common/62 exe static shared/meson.build
+++ b/test cases/common/62 exe static shared/meson.build
@@ -1,6 +1,7 @@
project('statchain', 'c')
subdir('subdir')
-statlib = static_library('stat', 'stat.c', link_with : shlib)
-exe = executable('prog', 'prog.c', link_with : statlib)
+statlib = static_library('stat', 'stat.c', link_with : shlib, pic : true)
+shlib2 = shared_library('shr2', 'shlib2.c', link_with : statlib)
+exe = executable('prog', 'prog.c', link_with : shlib2)
test('runtest', exe)
diff --git a/test cases/common/62 exe static shared/prog.c b/test cases/common/62 exe static shared/prog.c
index 4f82a6b16..26603b694 100644
--- a/test cases/common/62 exe static shared/prog.c
+++ b/test cases/common/62 exe static shared/prog.c
@@ -1,5 +1,10 @@
+int shlibfunc2();
int statlibfunc();
int main(int argc, char **argv) {
- return statlibfunc() == 42 ? 0 : 1;
+ if (statlibfunc() != 42)
+ return 1;
+ if (shlibfunc2() != 24)
+ return 1;
+ return 0;
}
diff --git a/test cases/common/62 exe static shared/shlib2.c b/test cases/common/62 exe static shared/shlib2.c
new file mode 100644
index 000000000..e26d11c73
--- /dev/null
+++ b/test cases/common/62 exe static shared/shlib2.c
@@ -0,0 +1,7 @@
+#include "subdir/exports.h"
+
+int statlibfunc(void);
+
+int DLL_PUBLIC shlibfunc2(void) {
+ return statlibfunc() - 18;
+}
diff --git a/test cases/common/62 exe static shared/subdir/exports.h b/test cases/common/62 exe static shared/subdir/exports.h
new file mode 100644
index 000000000..c89ccb23b
--- /dev/null
+++ b/test cases/common/62 exe static shared/subdir/exports.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_PUBLIC __declspec(dllexport)
+#else
+ #if defined __GNUC__
+ #define DLL_PUBLIC __attribute__ ((visibility("default")))
+ #else
+ #pragma message ("Compiler does not support symbol visibility.")
+ #define DLL_PUBLIC
+ #endif
+#endif
diff --git a/test cases/common/62 exe static shared/subdir/shlib.c b/test cases/common/62 exe static shared/subdir/shlib.c
index d649c7d24..002c83f92 100644
--- a/test cases/common/62 exe static shared/subdir/shlib.c
+++ b/test cases/common/62 exe static shared/subdir/shlib.c
@@ -1,13 +1,4 @@
-#if defined _WIN32 || defined __CYGWIN__
- #define DLL_PUBLIC __declspec(dllexport)
-#else
- #if defined __GNUC__
- #define DLL_PUBLIC __attribute__ ((visibility("default")))
- #else
- #pragma message ("Compiler does not support symbol visibility.")
- #define DLL_PUBLIC
- #endif
-#endif
+#include "exports.h"
int DLL_PUBLIC shlibfunc() {
return 42;