summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-06-18 12:10:55 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2019-06-22 15:54:09 +0530
commit654d91322cd749038a28b90fce2031cc4e8d3a53 (patch)
tree8a2d8f106586b70f9849feceb50b584329833a8e
parentd1dd6df37b3061d3595a25a2c12f04de235449a8 (diff)
downloadmeson-nirbheek/fix-objc-bitcode.tar.gz
compilers: Fix bitcode and other options for objc codenirbheek/fix-objc-bitcode
We were setting the base options for the Objective-C compiler manually, due to which options such as b_bitcode and b_ndebug were not getting set at all. The base options here are the same as for C code with the Clang compiler, so just use the same inherited list. Also expand the bitcode test to ObjC and ObjC++ so this doesn't happen again.
-rw-r--r--mesonbuild/compilers/objc.py1
-rw-r--r--mesonbuild/compilers/objcpp.py1
-rwxr-xr-xrun_unittests.py17
-rw-r--r--test cases/osx/7 bitcode/libbar.mm7
-rw-r--r--test cases/osx/7 bitcode/libfile.c5
-rw-r--r--test cases/osx/7 bitcode/libfoo.m7
-rw-r--r--test cases/osx/7 bitcode/meson.build10
-rw-r--r--test cases/osx/7 bitcode/vis.h6
8 files changed, 45 insertions, 9 deletions
diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py
index f9ca793be..b45f75b7d 100644
--- a/mesonbuild/compilers/objc.py
+++ b/mesonbuild/compilers/objc.py
@@ -74,4 +74,3 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler):
'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py
index 2e81b4c39..f74bbd8fe 100644
--- a/mesonbuild/compilers/objcpp.py
+++ b/mesonbuild/compilers/objcpp.py
@@ -75,4 +75,3 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler):
'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
diff --git a/run_unittests.py b/run_unittests.py
index 90d4a6289..36f7f3999 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -4093,18 +4093,21 @@ class DarwinTests(BasePlatformTests):
when it is false. This can't be an ordinary test case because we need
to inspect the compiler database.
'''
- testdir = os.path.join(self.common_test_dir, '4 shared')
- # Try with bitcode enabled
- out = self.init(testdir, extra_args='-Db_bitcode=true')
+ testdir = os.path.join(self.platform_test_dir, '7 bitcode')
env = get_fake_env(testdir, self.builddir, self.prefix)
cc = env.detect_c_compiler(MachineChoice.HOST)
if cc.id != 'clang':
raise unittest.SkipTest('Not using Clang on OSX')
+ # Try with bitcode enabled
+ out = self.init(testdir, extra_args='-Db_bitcode=true')
# Warning was printed
self.assertRegex(out, 'WARNING:.*b_bitcode')
# Compiler options were added
- compdb = self.get_compdb()
- self.assertIn('-fembed-bitcode', compdb[0]['command'])
+ for compdb in self.get_compdb():
+ if 'module' in compdb['file']:
+ self.assertNotIn('-fembed-bitcode', compdb['command'])
+ else:
+ self.assertIn('-fembed-bitcode', compdb['command'])
build_ninja = os.path.join(self.builddir, 'build.ninja')
# Linker options were added
with open(build_ninja, 'r', encoding='utf-8') as f:
@@ -4115,8 +4118,8 @@ class DarwinTests(BasePlatformTests):
self.setconf('-Db_bitcode=false')
# Regenerate build
self.build()
- compdb = self.get_compdb()
- self.assertNotIn('-fembed-bitcode', compdb[0]['command'])
+ for compdb in self.get_compdb():
+ self.assertNotIn('-fembed-bitcode', compdb['command'])
build_ninja = os.path.join(self.builddir, 'build.ninja')
with open(build_ninja, 'r', encoding='utf-8') as f:
contents = f.read()
diff --git a/test cases/osx/7 bitcode/libbar.mm b/test cases/osx/7 bitcode/libbar.mm
new file mode 100644
index 000000000..22c4dd49d
--- /dev/null
+++ b/test cases/osx/7 bitcode/libbar.mm
@@ -0,0 +1,7 @@
+#import <stdio.h>
+#import "vis.h"
+
+int EXPORT_PUBLIC libbar(int arg) {
+ return 0;
+}
+
diff --git a/test cases/osx/7 bitcode/libfile.c b/test cases/osx/7 bitcode/libfile.c
new file mode 100644
index 000000000..cc87aa0a1
--- /dev/null
+++ b/test cases/osx/7 bitcode/libfile.c
@@ -0,0 +1,5 @@
+#include "vis.h"
+
+int EXPORT_PUBLIC libfunc() {
+ return 3;
+}
diff --git a/test cases/osx/7 bitcode/libfoo.m b/test cases/osx/7 bitcode/libfoo.m
new file mode 100644
index 000000000..7981ab409
--- /dev/null
+++ b/test cases/osx/7 bitcode/libfoo.m
@@ -0,0 +1,7 @@
+#import <stdio.h>
+#import "vis.h"
+
+int EXPORT_PUBLIC libfoo(int arg) {
+ return 0;
+}
+
diff --git a/test cases/osx/7 bitcode/meson.build b/test cases/osx/7 bitcode/meson.build
new file mode 100644
index 000000000..f94bf9d3d
--- /dev/null
+++ b/test cases/osx/7 bitcode/meson.build
@@ -0,0 +1,10 @@
+project('bitcode test', 'c', 'objc', 'objcpp')
+
+both_libraries('alib', 'libfoo.m')
+shared_module('amodule', 'libfoo.m')
+
+both_libraries('blib', 'libbar.mm')
+shared_module('bmodule', 'libbar.mm')
+
+both_libraries('clib', 'libfile.c')
+shared_module('cmodule', 'libfile.c')
diff --git a/test cases/osx/7 bitcode/vis.h b/test cases/osx/7 bitcode/vis.h
new file mode 100644
index 000000000..fa252b4ce
--- /dev/null
+++ b/test cases/osx/7 bitcode/vis.h
@@ -0,0 +1,6 @@
+#if defined __GNUC__
+ #define EXPORT_PUBLIC __attribute__ ((visibility("default")))
+#else
+ #pragma message ("Compiler does not support symbol visibility.")
+ #define EXPORT_PUBLIC
+#endif