aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-09-05 15:17:02 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2015-09-05 15:17:02 +0300
commit2e3bd006d319aca659cfbd8a31894e641a7a79e6 (patch)
treea8b37e0f8e3236c4d10e481bc18b16ead56555b5
parentad5795ed2e2afcd32d89fae68a8682fb647dd194 (diff)
downloadmeson-2e3bd006d319aca659cfbd8a31894e641a7a79e6.zip
meson-2e3bd006d319aca659cfbd8a31894e641a7a79e6.tar.gz
meson-2e3bd006d319aca659cfbd8a31894e641a7a79e6.tar.bz2
Converted alignment check to work also when cross compiling.
-rw-r--r--compilers.py39
-rw-r--r--cross/iphone.txt4
-rw-r--r--cross/ubuntu-armhf.txt4
3 files changed, 22 insertions, 25 deletions
diff --git a/compilers.py b/compilers.py
index 56b2c8a..f457cf3 100644
--- a/compilers.py
+++ b/compilers.py
@@ -361,7 +361,28 @@ int main(int argc, char **argv) {
raise EnvironmentException('Could not run sizeof test binary.')
return int(res.stdout)
+ def cross_alignment(self, typename, env):
+ templ = '''#include<stddef.h>
+struct tmp {
+ char c;
+ %s target;
+};
+
+int testarray[%d-offsetof(struct tmp, target)];
+'''
+ try:
+ extra_args = env.cross_info.config['properties'][self.language + '_args']
+ except KeyError:
+ pass
+ for i in range(1, 1024):
+ code = templ % (typename, i)
+ if self.compiles(code, extra_args):
+ return i
+ raise EnvironmentException('Cross checking offsetof overflowed.')
+
def alignment(self, typename, env):
+ if self.is_cross:
+ return self.cross_alignment(typename, env)
templ = '''#include<stdio.h>
#include<stddef.h>
@@ -375,23 +396,7 @@ int main(int argc, char **argv) {
return 0;
}
'''
- varname = 'alignment ' + typename
- varname = varname.replace(' ', '_')
- if self.is_cross:
- val = env.cross_info.config['properties'][varname]
- if val is not None:
- if isinstance(val, int):
- return val
- raise EnvironmentException('Cross variable {0} is not an integer.'.format(varname))
- cross_failed = False
- try:
- res = self.run(templ % typename)
- except CrossNoRunException:
- cross_failed = True
- if cross_failed:
- message = '''Can not determine alignment of {0} because cross compiled binaries are not runnable.
-Please define the corresponding variable {1} in your cross compilation definition file.'''.format(typename, varname)
- raise EnvironmentException(message)
+ res = self.run(templ % typename)
if not res.compiled:
raise EnvironmentException('Could not compile alignment test.')
if res.returncode != 0:
diff --git a/cross/iphone.txt b/cross/iphone.txt
index b37a931..de48551 100644
--- a/cross/iphone.txt
+++ b/cross/iphone.txt
@@ -16,10 +16,6 @@ cpp_args = ['-arch', 'armv7', '-miphoneos-version-min=8.0', '-isysroot', '/Appli
c_link_args = ['-arch', 'armv7', '-miphoneos-version-min=8.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk']
cpp_link_args = ['-arch', 'armv7', '-miphoneos-version-min=8.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk']
-alignment_char = 1
-alignment_void* = 4
-alignment_double = 4 # Don't know if this is correct...
-
has_function_printf = true
has_function_hfkerhisadf = false
diff --git a/cross/ubuntu-armhf.txt b/cross/ubuntu-armhf.txt
index e8bd912..d15780e 100644
--- a/cross/ubuntu-armhf.txt
+++ b/cross/ubuntu-armhf.txt
@@ -10,10 +10,6 @@ pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'
[properties]
root = '/usr/arm-linux-gnueabihf'
-alignment_char = 1
-alignment_void* = 4
-alignment_double = 4 # Don't know if this is correct...
-
has_function_printf = true
has_function_hfkerhisadf = false