fix native package compile error with gcc 4.3.4 on x86 host
v4 cover fix native package compile error with gcc 4.3.4 on x86 host
Change from V3: as Richard suggested, patch sanity.bbclass to test if necessary to add march to BUILD_CFLAG when the gcc version is older than 4.5
Test case:
:~> bitbake packagegroup-toolset-native
WARNING: Host distribution "SUSE Linux Enterprise Desktop 11" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
ERROR: OE-core's config sanity checker detected a potential misconfiguration. Either fix the cause of this error or at your own risk disable the checker(see sanity.conf).
Following is the list of potential problems / advisories:
Your gcc version is older than 4.5, please add the following param to local.conf
BUILD_CFLAGS_append = " -march=native"
[YOCTO #3563]
The following changes since commit 7ed45239631796086c78546776096f62ea090718:
bitbake: siggen: add quotes around variable values to see whitespace (2013-03-04 11:38:30 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib hongxu/sanity-check-march
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/sanity-check-march
Hongxu Jia (1):
sanity.bbclass:check if necessary to add march to BUILD_CFLAGS
meta/classes/sanity.bbclass | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
Signature · 1 line
1.7.10.4
PATCH v4 1/1 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]
--- meta/classes/sanity.bbclass | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
meta/classes/sanity.bbclass +29 -0
@@ -309,6 +309,31 @@ def check_sanity_validmachine(sanity_data): return messages +# Checks if necessary to add option march to host gcc +def check_gcc_march(sanity_data): + result = False + + # Check if -march not in BUILD_CFLAGS + if sanity_data.getVar("BUILD_CFLAGS",True).find("-march") < 0: + + # Construct a test file + f = file("gcc_test.c", "w") + f.write("int main (){ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4; return 0;}\n") + f.close() + import commands + + # Check if GCC could work without march + status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc gcc_test.c -o gcc_test") + if status != 0: + # Check if GCC could work with march + status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc -march=native gcc_test.c -o gcc_test") + if status == 0: + result = True + + os.remove("gcc_test.c") + os.remove("gcc_test") + + return result def check_sanity(sanity_data): import subprocess
@@ -416,6 +441,10 @@ def check_sanity(sanity_data): if not check_app_exists("qemu-arm", sanity_data): messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH" + if check_gcc_march(sanity_data): + messages = messages + "Your gcc version is older than 4.5, please add the following param to local.conf\n \ + BUILD_CFLAGS_append = \" -march=native\"\n" + paths = sanity_data.getVar('PATH', True).split(":") if "." in paths or "" in paths: messages = messages + "PATH contains '.' or '' (empty element), which will break the build, please remove this.\n"
Signature · 1 line
1.7.10.4