diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2021-05-20 23:12:38 +0100 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2021-05-21 14:19:35 +0100 |
commit | f76c6b8d0a7966ab43d826dc3e19de4ccaa1f7e4 (patch) | |
tree | b2fdc506838b986473de03f51995f08a793f5185 | |
parent | 91aeae558d018717bba367ec3f427b21206df8fb (diff) | |
download | meson-f76c6b8d0a7966ab43d826dc3e19de4ccaa1f7e4.zip meson-f76c6b8d0a7966ab43d826dc3e19de4ccaa1f7e4.tar.gz meson-f76c6b8d0a7966ab43d826dc3e19de4ccaa1f7e4.tar.bz2 |
Fix LTO test on Cygwin
This partially reverts commit add502c6483bde9dc6a0ba80b3c79163304465a4.
In 'linkshared' test, annotate cppfunc() as imported, so an indirection
through an import stub is generated, avoiding a relocation size error
when building using gcc for Cygwin with LTO on.
Align with the example of how to write this portably in [1].
The 'c' language part of that test already gets this right.
[1] http://gcc.gnu.org/wiki/Visibility
-rwxr-xr-x | run_unittests.py | 2 | ||||
-rw-r--r-- | test cases/common/6 linkshared/cpplib.cpp | 7 | ||||
-rw-r--r-- | test cases/common/6 linkshared/cpplib.h | 12 | ||||
-rw-r--r-- | test cases/common/6 linkshared/cppmain.cpp | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/run_unittests.py b/run_unittests.py index f65eba3..ed8de78 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3075,8 +3075,6 @@ class AllPlatformTests(BasePlatformTests): @skip_if_not_base_option('b_lto_threads') def test_lto_threads(self): - if is_cygwin(): - raise unittest.SkipTest('LTO is broken on Cygwin.') testdir = os.path.join(self.common_test_dir, '6 linkshared') env = get_fake_env(testdir, self.builddir, self.prefix) diff --git a/test cases/common/6 linkshared/cpplib.cpp b/test cases/common/6 linkshared/cpplib.cpp index 395859d..247f820 100644 --- a/test cases/common/6 linkshared/cpplib.cpp +++ b/test cases/common/6 linkshared/cpplib.cpp @@ -1,8 +1,5 @@ -#if defined _WIN32 - #define DLL_PUBLIC __declspec(dllexport) -#else - #define DLL_PUBLIC __attribute__ ((visibility ("default"))) -#endif +#define BUILDING_DLL +#include "cpplib.h" int DLL_PUBLIC cppfunc(void) { return 42; diff --git a/test cases/common/6 linkshared/cpplib.h b/test cases/common/6 linkshared/cpplib.h new file mode 100644 index 0000000..e2b0206 --- /dev/null +++ b/test cases/common/6 linkshared/cpplib.h @@ -0,0 +1,12 @@ +/* See http://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support */ +#if defined(_WIN32) || defined(__CYGWIN__) + #ifdef BUILDING_DLL + #define DLL_PUBLIC __declspec(dllexport) + #else + #define DLL_PUBLIC __declspec(dllimport) + #endif +#else + #define DLL_PUBLIC __attribute__ ((visibility ("default"))) +#endif + +int DLL_PUBLIC cppfunc(void); diff --git a/test cases/common/6 linkshared/cppmain.cpp b/test cases/common/6 linkshared/cppmain.cpp index 8e16485..29e9a44 100644 --- a/test cases/common/6 linkshared/cppmain.cpp +++ b/test cases/common/6 linkshared/cppmain.cpp @@ -1,4 +1,4 @@ -int cppfunc(void); +#include "cpplib.h" int main(void) { return cppfunc() != 42; |