summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2013-03-05 10:50:15 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-07 11:14:36 +0000
commit3be1c1251b593b7509d12245dde4ff3daec882f1 (patch)
tree15420bb5ea7a58db41604c82e2200338f9bd706f /meta
parent14cd284ce1b65d3ddd2aa2a15e0c1a8543cea27f (diff)
downloadpoky-3be1c1251b593b7509d12245dde4ff3daec882f1.tar.gz
sanity.bbclass:check if necessary to add march to BUILD_CFLAGS
1, There are a set of GCC built-in functions for atomic memory access. The definition given in the Intel documentation allows only for the use of the types int, long, long long as well as their unsigned counterparts. GCC will allow any integral scalar or pointer type that is 1, 2, 4, 8 or 16 bytes in length, suffix `_n' where n is the size of the data type.Such as: __sync_fetch_and_add_n __sync_fetch_and_sub_n __sync_fetch_and_or_n __sync_fetch_and_and_n __sync_fetch_and_xor_n __sync_fetch_and_nand_n The above builtins are intended to be compatible with those described in the Intel Itanium Processor-specific Application Binary Interface, section 7.4. 2, The glib-2.0-native and qemu-native invoke the above builtin function with suffix `_4', and glib-2.0-native uses __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to test the existance. 3, Not all above builtin functions are supported by all target processors.Such as i386 does not support the functions with suffix `_4', but i486 or later support. 4, Prior to GCC 4.5, on the Intel's processor, the default arch is i386 unless GCC is built with the --with-arch switch. Since GCC 4.5 the default arch is implied by the target. 5, If your host GCC is older than 4.5 and it is built without the --with-arch switch, when you use the GCC to compile target, you should specify -march to tell GCC what the target's arch is, otherwise i386 is used as default. Above all, when use older GCC to compile glib-2.0-native or glib-2.0-native, and the GCC incorrectly uses i386 as default, the above builtin function with suffix `_4' is not referenced. We should have a check in sanity.bbclass to tell the user if necessary to add march to BUILD_CFLAGS in this situation. http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins http://gcc.gnu.org/ml/gcc-help/2009-06/msg00037.html http://gcc.gnu.org/gcc-4.5/changes.html http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460 http://llvm.org/bugs/show_bug.cgi?id=11174 http://download.intel.com/design/itanium/downloads/245370.pdf [YOCTO #3563] (From OE-Core rev: 38042ed8586b3abe427af33debc2402caeca52cb) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/sanity.bbclass29
1 files changed, 29 insertions, 0 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 06e95e3562..8cdb06e185 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -309,6 +309,31 @@ def check_sanity_validmachine(sanity_data):
309 309
310 return messages 310 return messages
311 311
312# Checks if necessary to add option march to host gcc
313def check_gcc_march(sanity_data):
314 result = False
315
316 # Check if -march not in BUILD_CFLAGS
317 if sanity_data.getVar("BUILD_CFLAGS",True).find("-march") < 0:
318
319 # Construct a test file
320 f = file("gcc_test.c", "w")
321 f.write("int main (){ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4; return 0;}\n")
322 f.close()
323 import commands
324
325 # Check if GCC could work without march
326 status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc gcc_test.c -o gcc_test")
327 if status != 0:
328 # Check if GCC could work with march
329 status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc -march=native gcc_test.c -o gcc_test")
330 if status == 0:
331 result = True
332
333 os.remove("gcc_test.c")
334 os.remove("gcc_test")
335
336 return result
312 337
313def check_sanity(sanity_data): 338def check_sanity(sanity_data):
314 import subprocess 339 import subprocess
@@ -416,6 +441,10 @@ def check_sanity(sanity_data):
416 if not check_app_exists("qemu-arm", sanity_data): 441 if not check_app_exists("qemu-arm", sanity_data):
417 messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH" 442 messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH"
418 443
444 if check_gcc_march(sanity_data):
445 messages = messages + "Your gcc version is older than 4.5, please add the following param to local.conf\n \
446 BUILD_CFLAGS_append = \" -march=native\"\n"
447
419 paths = sanity_data.getVar('PATH', True).split(":") 448 paths = sanity_data.getVar('PATH', True).split(":")
420 if "." in paths or "" in paths: 449 if "." in paths or "" in paths:
421 messages = messages + "PATH contains '.' or '' (empty element), which will break the build, please remove this.\n" 450 messages = messages + "PATH contains '.' or '' (empty element), which will break the build, please remove this.\n"